Skip to content

Commit 86e0f7e

Browse files
committed
fix(syntax-receipts): document the phase rules in order and keep timeouts refused
The phase paragraph now follows the importer's checks in order. Tests keep internal errors and statement timeouts refused, and a missing object to undrop gets the missing-object reason.
1 parent 196bb32 commit 86e0f7e

3 files changed

Lines changed: 30 additions & 10 deletions

File tree

‎docs/syntax-coverage.md‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,21 @@ that edits or removes a committed one.
168168
- `outcome`, `errno` and `sqlstate`.
169169
- `phase`: one of `accepted`, `syntax_error`, `semantic_error`, `runtime_error` or
170170
`unsupported_feature`.
171-
- `phase_basis`: why the importer chose the phase.
172-
An error number of 100000 or more is an execution-time code, unless its SQLSTATE is in class
173-
42; errno 1003 under the `SQL compilation error` prefix is a syntax error, and any other errno
174-
under that prefix is a compilation error after parsing. Any other error is refused unless its
175-
errno is one the importer lists as reviewed: Snowflake's message for it shows that it parsed the
176-
statement and refused it on a rule about what it says, such as a duplicate secret name
177-
(509008), a missing object to undrop (90025), access control (3001), a required property
178-
(3172), an account restriction (93171) or an application-only operation (98620). Internal
179-
errors (603), statement timeouts (630) and errors that may come from the parser itself stay
180-
refused.
171+
- `phase_basis`: why the importer chose the phase. The importer applies these rules in order:
172+
1. An uncaught exception raised while a block ran is a `runtime_error`, unless its errno is
173+
1003, which is refused.
174+
2. Errno 2 `Unsupported feature` is an `unsupported_feature`.
175+
3. An errno of 100000 or more is a `runtime_error`, unless its SQLSTATE is in class 42. Then it
176+
is refused unless the errno is a reviewed one, which is a `semantic_error`.
177+
4. Errno 1003 under the `SQL compilation error` prefix is a `syntax_error`. Any other errno
178+
under that prefix is a `semantic_error`, a compilation error after parsing.
179+
5. Any other error is refused unless its errno is a reviewed one, which is a `semantic_error`.
180+
181+
A reviewed errno is one whose message shows that Snowflake parsed the statement and then
182+
refused it. Examples are a duplicate secret name (509008), a missing object to undrop (90025),
183+
access control (3001), a required property (3172), an account restriction (93171) and an
184+
application-only operation (98620). Internal errors (603), statement timeouts (630) and errors
185+
that may come from the parser itself stay refused.
181186
- `raw_record_sha256`, `run_audit_sha256` and `packet_sha256`: the hashes of the private raw
182187
record, the private run audit and the submitted packet.
183188
- Optional provenance: `case_hash`, `input_sha256`, `statement_index`, `statements_in_input`,

‎scripts/syntax_receipts/constants.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
2142,
8484
2211,
8585
3620,
86+
90025,
8687
90080,
8788
91083,
8889
91085,

‎tests/unit/scripts/syntax_receipts/test_import_runs.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,20 @@
162162
"errno 90025 SQLSTATE 02000, reviewed as semantic",
163163
),
164164
),
165+
ClassifyTestCase(
166+
description="an internal error is not established",
167+
errno=603,
168+
sqlstate="XX000",
169+
message="SQL execution internal error:\nProcessing aborted due to error 300010:1",
170+
expected_classification=None,
171+
),
172+
ClassifyTestCase(
173+
description="a statement timeout is not established",
174+
errno=630,
175+
sqlstate="57014",
176+
message="Statement reached its statement or warehouse timeout of 30 second(s).",
177+
expected_classification=None,
178+
),
165179
ClassifyTestCase(
166180
description="an unreviewed errno without the compilation prefix is not established",
167181
errno=926,

0 commit comments

Comments
 (0)