Skip to content

CLI commands

sqlbabel check

Check that Snowflake SQL parses and holds nothing Snowflake rejects, without converting it.

sqlbabel check parses Snowflake SQL and reports what Snowflake would reject. It needs no schema and no policy, and it converts nothing.

sqlbabel check [OPTIONS] [PATH]
sqlbabel check query.sql
echo "SELECT 1 QUALIFY TRUE" | sqlbabel check --json

PATH is a SQL file. Without one, or with -, check reads standard input.

$ sqlbabel check query.sql
error[SBL0201]: Snowflake does not support INTERSECT, EXCEPT or MINUS with ALL
--> query.sql:1:29
|
1 | SELECT order_id FROM orders INTERSECT ALL SELECT order_id FROM orders
| ^^^^^^^^^^^^^ Snowflake does not support INTERSECT with ALL
|
= help: drop ALL to compare distinct rows; only UNION accepts ALL in Snowflake
sqlbabel check: found 1 problem
  • SQL that does not parse: SBL0001, with the span where the parser stopped.
  • Input beyond the parser’s limits: the SBL01xx codes.
  • SQL that parses but that Snowflake rejects, such as INTERSECT ALL, FOR UPDATE WAIT, QUALIFY without a window function, or a * ILIKE REPLACE or RENAME of a column the pattern removes: the SBL02xx codes.
Option Meaning
--format text|json Print the report as text for people or JSON for programs. Default text.
--json The same as --format json.
--color auto|always|never Colour diagnostics. Default auto: only on a terminal, honouring NO_COLOR and CLICOLOR_FORCE.
--max-call-depth <n> Refuse function calls nested more than n deep with SBL0107. Default 256, at most 512, the parser’s fixed nesting limit.

With --json, check prints {"ok": …, "diagnostics": [...]}. See JSON output.

Code Meaning
0 No problem found.
1 At least one problem found.
2 The input holds no SQL, can’t be read, or an option is invalid, such as --max-call-depth above 512.