From ed3156f6f55a9bdd44022908fb58557ac1302d4b Mon Sep 17 00:00:00 2001 From: Matt Zimmerman Date: Mon, 29 Jun 2026 10:17:56 -0700 Subject: [PATCH] fix: raise ProgrammingError for CREATE MACRO instead of silently creating it Snowflake doesn't support CREATE MACRO, so fakesnow shouldn't either. Previously the DuckDB-only DDL would slip through and actually create the macro as a side effect. Now we detect it early and raise a clean ProgrammingError before DuckDB executes anything. Co-Authored-By: Claude Sonnet 4.6 --- fakesnow/cursor.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fakesnow/cursor.py b/fakesnow/cursor.py index cc76342..796dbd0 100644 --- a/fakesnow/cursor.py +++ b/fakesnow/cursor.py @@ -355,6 +355,17 @@ def _execute(self, transformed: Expr, params: MutableParams | None = None) -> No if not sql: raise NotImplementedError(transformed.sql(dialect="snowflake")) + if ( + cmd == "CREATE" + and isinstance(transformed, exp.Command) + and re.search(r"\bMACRO\b", transformed.expression, re.IGNORECASE) + ): + raise snowflake.connector.errors.ProgrammingError( + msg="SQL compilation error:\nUnsupported feature 'CREATE MACRO'.", + errno=2, + sqlstate="0A000", + ) + if sfqid := transformed.args.get("result_scan_sfqid"): value = self._conn.results_cache.get(sfqid) if value is None: