Skip to content

Commit dfbf647

Browse files
committed
chore(syntax-receipts): refuse errno 1002 in any other form
Errno 1002 under the SQL compilation error prefix was placed as semantic, and inside an uncaught exception as runtime. As a parser errno, either could be a syntax error published under the wrong phase, so both are now refused, the same way 1003 inside an uncaught exception is. The docs list the 1002 rule on its own and say it reads the message in any case and ignores SQLSTATE.
1 parent d51335f commit dfbf647

3 files changed

Lines changed: 24 additions & 7 deletions

File tree

‎docs/syntax-coverage.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,15 @@ that edits or removes a committed one.
170170
`unsupported_feature`.
171171
- `phase_basis`: why the importer chose the phase. The importer applies these rules in order:
172172
1. An uncaught exception raised while a block ran is a `runtime_error`, unless its errno is
173-
1003, which is refused.
173+
1002 or 1003, which is refused.
174174
2. Errno 2 `Unsupported feature` is an `unsupported_feature`.
175175
3. An errno of 100000 or more is a `runtime_error`, unless its SQLSTATE is in class 42. Then it
176176
is refused unless the errno is a reviewed one, which is a `semantic_error`.
177177
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-
Errno 1002 is a `syntax_error` only when its message itself starts with `syntax error`.
180-
5. Any other error is refused unless its errno is a reviewed one, which is a `semantic_error`.
178+
under that prefix except 1002 is a `semantic_error`, a compilation error after parsing.
179+
5. Errno 1002 is a `syntax_error` when its message itself starts with `syntax error`, in any
180+
case and whatever its SQLSTATE; any other errno 1002 is refused.
181+
6. Any other error is refused unless its errno is a reviewed one, which is a `semantic_error`.
181182

182183
A reviewed errno is one whose message shows that Snowflake parsed the statement and then
183184
refused it. Examples are a duplicate secret name (509008), a missing object to undrop (90025),

‎scripts/syntax_receipts/_helpers/receipts.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def classify(
3434
) -> tuple[str, str] | None:
3535
"""The phase of a Snowflake error, or None when the recorded fields do not establish one."""
3636
if message.startswith(UNCAUGHT_PREFIX):
37-
if errno == SYNTAX_ERRNO:
37+
if errno in (SYNTAX_ERRNO, PARSER_SYNTAX_ERRNO):
3838
return None
3939
return "runtime_error", "uncaught exception raised while the block ran"
4040
if errno == UNSUPPORTED_ERRNO and message.startswith(UNSUPPORTED_PREFIX):
@@ -48,8 +48,10 @@ def classify(
4848
compiled: bool = message.lower().startswith(COMPILATION_PREFIX.lower())
4949
if errno == SYNTAX_ERRNO and compiled:
5050
return "syntax_error", "errno 1003 SQL compilation syntax error"
51-
if errno == PARSER_SYNTAX_ERRNO and message.lower().startswith(SYNTAX_MESSAGE_PREFIX):
52-
return "syntax_error", "errno 1002 parser syntax error"
51+
if errno == PARSER_SYNTAX_ERRNO:
52+
if message.lower().startswith(SYNTAX_MESSAGE_PREFIX):
53+
return "syntax_error", "errno 1002 parser syntax error"
54+
return None
5355
if errno is not None and compiled:
5456
return "semantic_error", f"errno {errno} compilation error after parsing"
5557
if errno in REVIEWED_SEMANTIC_ERRNOS:

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,20 @@
204204
),
205205
expected_classification=("syntax_error", "errno 1002 parser syntax error"),
206206
),
207+
ClassifyTestCase(
208+
description="errno 1002 under the compilation prefix is not established",
209+
errno=1002,
210+
sqlstate="42601",
211+
message="SQL compilation error:\nsyntax error line 1 at position 4",
212+
expected_classification=None,
213+
),
214+
ClassifyTestCase(
215+
description="errno 1002 raised while a block runs is not established",
216+
errno=1002,
217+
sqlstate="42601",
218+
message="Uncaught exception of type 'STATEMENT_ERROR' : syntax error line 1",
219+
expected_classification=None,
220+
),
207221
ClassifyTestCase(
208222
description="errno 1002 with any other message is not established",
209223
errno=1002,

0 commit comments

Comments
 (0)