Skip to content

fix: raise ProgrammingError for CREATE MACRO instead of creating it as a side effect#350

Open
mdz wants to merge 1 commit into
tekumara:mainfrom
mdz:claude/determined-hopper-c7c5a1
Open

fix: raise ProgrammingError for CREATE MACRO instead of creating it as a side effect#350
mdz wants to merge 1 commit into
tekumara:mainfrom
mdz:claude/determined-hopper-c7c5a1

Conversation

@mdz

@mdz mdz commented Jun 29, 2026

Copy link
Copy Markdown

What changed

CREATE MACRO is DuckDB-only DDL that Snowflake doesn't support. Previously fakesnow would silently pass it through to DuckDB, actually creating the macro as a side effect (and in server mode, also raising a ProgrammingError when result post-processing tried to DESCRIBE the raw DDL string).

Per the reviewer's position in #344, the right behavior is for CREATE MACRO to fail cleanly rather than succeeding with a DuckDB-only side effect.

How

Added an early guard in FakeSnowflakeCursor._execute (fakesnow/cursor.py) that detects CREATE ... MACRO (sqlglot parses this as an opaque exp.Command) and raises a ProgrammingError with errno=2 / sqlstate=0A000 (feature not supported) before DuckDB ever executes it.

Test plan

  • CREATE OR REPLACE MACRO raises ProgrammingError: SQL compilation error: Unsupported feature 'CREATE MACRO'.
  • The macro is not created in DuckDB — calling the macro name after the error also raises an error
  • Existing cursor tests pass (uv run pytest tests/test_cursor.py)

🤖 Generated with Claude Code

…ting 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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant