Summary
Snowflake COPY statements are misclassified as "Unknown" statement type, causing them to be rejected when sql_statement_permissions is configured with Copy: true and Unknown: false.
Expected Behavior
When executing a Snowflake COPY statement with Copy: true in permissions, the statement should be recognized as type "Copy" and allowed to execute.
Actual Behavior
The statement is classified as "Unknown" and rejected. Setting Unknown: true is required as a workaround.
Steps to Reproduce
-
Configure tools_config.yaml with:
sql_statement_permissions:
- Copy: true
- Unknown: false
-
Execute a Snowflake COPY statement:
COPY INTO @MY_STAGE.EXPORTS/sales_export.csv.gz
FROM (
SELECT * FROM MY_DATABASE.PUBLIC.ORDERS LIMIT 10
)
FILE_FORMAT = (TYPE = CSV COMPRESSION = GZIP)
HEADER = TRUE
OVERWRITE = TRUE
MAX_FILE_SIZE = 52428800
SINGLE = TRUE;
-
Observe that the query is rejected
-
Change config to Unknown: true — the query now executes (confirming misclassification)
Additional Context
The issue appears to be in mcp_server_snowflake/query_manager/tools.py where sqlglot.parse_one() is called without specifying dialect="snowflake". This causes the parser to fail on Snowflake-specific syntax.
Verification script:
import sqlglot
COPY_QUERY = """COPY INTO @MY_STAGE.EXPORTS/sales_export.csv.gz
FROM (SELECT * FROM MY_DATABASE.PUBLIC.ORDERS LIMIT 10)
FILE_FORMAT = (TYPE = CSV COMPRESSION = GZIP) HEADER = TRUE OVERWRITE = TRUE
MAX_FILE_SIZE = 52428800 SINGLE = TRUE;"""
# Without dialect - raises ParseError
try:
result = sqlglot.parse_one(COPY_QUERY)
except sqlglot.errors.ParseError:
print("Classified as: Unknown")
# With Snowflake dialect - parses correctly
result = sqlglot.parse_one(COPY_QUERY, dialect="snowflake")
print(f"Classified as: {type(result).__name__}") # Prints "Copy"
Summary
Snowflake COPY statements are misclassified as "Unknown" statement type, causing them to be rejected when
sql_statement_permissionsis configured withCopy: trueandUnknown: false.Expected Behavior
When executing a Snowflake COPY statement with
Copy: truein permissions, the statement should be recognized as type "Copy" and allowed to execute.Actual Behavior
The statement is classified as "Unknown" and rejected. Setting
Unknown: trueis required as a workaround.Steps to Reproduce
Configure
tools_config.yamlwith:Execute a Snowflake COPY statement:
Observe that the query is rejected
Change config to
Unknown: true— the query now executes (confirming misclassification)Additional Context
The issue appears to be in
mcp_server_snowflake/query_manager/tools.pywheresqlglot.parse_one()is called without specifyingdialect="snowflake". This causes the parser to fail on Snowflake-specific syntax.Verification script: