Skip to content

Commit bcc7178

Browse files
committed
fix(syntax-receipts): place reviewed errors whose message shows Snowflake parsed the statement
Errors without the SQL compilation error prefix, and compilation errors above 100000 under SQLSTATE class 42, were refused as having no established phase. Where Snowflake's message shows it parsed the statement and refused it on a rule about what it says (secret and option checks, a storage URL, a missing object to undrop, access control, a required property, an account restriction, an application-only operation), the errno is now reviewed as semantic. Internal errors, statement timeouts and errors that may come from the parser itself stay refused.
1 parent b284ea0 commit bcc7178

4 files changed

Lines changed: 47 additions & 1 deletion

File tree

‎docs/syntax-coverage.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ that edits or removes a committed one.
169169
- `phase`: one of `accepted`, `syntax_error`, `semantic_error`, `runtime_error` or
170170
`unsupported_feature`.
171171
- `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.
172181
- `raw_record_sha256`, `run_audit_sha256` and `packet_sha256`: the hashes of the private raw
173182
record, the private run audit and the submitted packet.
174183
- Optional provenance: `case_hash`, `input_sha256`, `statement_index`, `statements_in_input`,

‎scripts/syntax_receipts/_helpers/receipts.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ def classify(
4848
return "syntax_error", "errno 1003 SQL compilation syntax error"
4949
if errno is not None and compiled:
5050
return "semantic_error", f"errno {errno} compilation error after parsing"
51+
if errno in REVIEWED_SEMANTIC_ERRNOS:
52+
return "semantic_error", f"errno {errno} SQLSTATE {sqlstate}, reviewed as semantic"
5153
return None
5254

5355

‎scripts/syntax_receipts/constants.py‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,25 @@
1313
UNSUPPORTED_PREFIX: str = "Unsupported feature"
1414
RUNTIME_ERRNO_FLOOR: int = 100000
1515
SYNTAX_OR_ACCESS_SQLSTATE_CLASS: str = "42"
16-
REVIEWED_SEMANTIC_ERRNOS: frozenset[int] = frozenset({391858, 392002, 506005, 506034, 506035})
16+
REVIEWED_SEMANTIC_ERRNOS: frozenset[int] = frozenset(
17+
{
18+
3001,
19+
3172,
20+
90025,
21+
93171,
22+
98620,
23+
391858,
24+
392002,
25+
393941,
26+
506005,
27+
506034,
28+
506035,
29+
509000,
30+
509001,
31+
509008,
32+
509013,
33+
}
34+
)
1735
SCRIPTING_SUBMISSION: str = "anonymous block, as-is"
1836
EXPLAIN_METHOD: str = "EXPLAIN USING TEXT, once"
1937
CAPTURE_EXECUTE: str = "execute"

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,23 @@
152152
"errno 391858 SQLSTATE 42601, reviewed as semantic",
153153
),
154154
),
155+
ClassifyTestCase(
156+
description="a reviewed errno without the compilation prefix is semantic",
157+
errno=90025,
158+
sqlstate="02000",
159+
message="Dynamic_table V1 did not exist or was purged.",
160+
expected_classification=(
161+
"semantic_error",
162+
"errno 90025 SQLSTATE 02000, reviewed as semantic",
163+
),
164+
),
165+
ClassifyTestCase(
166+
description="an unreviewed errno without the compilation prefix is not established",
167+
errno=926,
168+
sqlstate="42601",
169+
message="External table identifier cannot be empty",
170+
expected_classification=None,
171+
),
155172
ClassifyTestCase(
156173
description="a syntax error without the compilation prefix is not established",
157174
errno=1003,

0 commit comments

Comments
 (0)