Guides
Reading diagnostics
What a SQLBabel diagnostic says, and the two kinds of problem it reports.
Every problem SQLBabel reports is a coded diagnostic, underlined in the source as rustc does:
error[SBL0004]: SQLBabel doesn't know this name --> query.sql:1:15 |1 | SELECT a FROM orders | ^^^^^^ relation `ORDERS` has no known columns | = help: declare the relation and its columns in a source file of the project (`sources/*.yml`)The first line has the code and the message. The arrow gives the file, line and column. The caret
line underlines the exact span and carries a label for this occurrence. = note: and = help:
lines follow when the code has them.
Two kinds of problem
Section titled “Two kinds of problem”| Kind | Codes | What to do |
|---|---|---|
| The SQL is not valid Snowflake | SBL0001, SBL01xx, SBL02xx |
Fix the SQL. sqlbabel check finds these without a schema. |
| Valid SQL that can’t be translated safely | SBL0002 to SBL0008 |
Declare the schema, change the policy, or rewrite the construct. |
sqlbabel check reports only the first kind. sqlbabel convert reports both: a statement that
does not parse, or that Snowflake rejects, is refused before conversion is tried.
JSON output
Section titled “JSON output”With --json, each diagnostic is an object:
{ "severity": "error", "code": "SBL0203", "name": "qualify_without_window", "alias": null, "message": "QUALIFY needs a window function", "span": { "start": 9, "end": 16, "line": 1, "column": 10, "end_line": 1, "end_column": 17 }, "label": "QUALIFY is used without a window function in the SELECT list or QUALIFY", "notes": [], "help": "move the condition to WHERE or HAVING, or filter on a window function's result"}| Field | Meaning |
|---|---|
code |
SBL and four digits. Never reused or renumbered. |
name |
The code’s stable name, such as unresolved_name. |
alias |
A parser guard’s former E_GUARD_* name, or null. |
message |
The code’s title, sometimes with the construct. |
span |
Character start and end, then one-based line, column, end_line and end_column. Absent only for problems outside the SQL, such as session parameters. |
label |
What is wrong at this span. |
notes, help |
Context, and what to change. |
Every code is listed in the diagnostic reference. To read one in the terminal, by code or by name:
sqlbabel explain SBL0203sqlbabel explain qualify_without_windowIt prints the code’s title, explanation, help and an example that draws it, and exits 2 for an unknown code.