Skip to content

Commit d51335f

Browse files
committed
chore(syntax-receipts): place errno 1002 syntax error messages as syntax
Errno 1002 (SQLSTATE 42601) was refused as having no established phase. Snowflake raises it from the parser for some malformed statements, with a message that itself starts with "syntax error", such as ALTER WAREHOUSE ... ADD TABLES with no table list: "syntax error line At least one table name is required for ADD TABLES operations ...". Errno 1002 is now a syntax error only when its message starts with "syntax error"; any other 1002 message stays refused.
1 parent 9635cbb commit d51335f

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎docs/syntax-coverage.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ that edits or removes a committed one.
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
178178
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`.
179180
5. Any other error is refused unless its errno is a reviewed one, which is a `semantic_error`.
180181

181182
A reviewed errno is one whose message shows that Snowflake parsed the statement and then

‎scripts/syntax_receipts/_helpers/receipts.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
MISSING_OBJECT,
1212
MISSING_OBJECT_MESSAGE,
1313
OTHER_REASON,
14+
PARSER_SYNTAX_ERRNO,
1415
REASON_BY_ERRNO,
1516
RECEIPT_FORMAT,
1617
REVIEWED_SEMANTIC_ERRNOS,
1718
RUNTIME_ERRNO_FLOOR,
1819
SYNTAX_ERRNO,
20+
SYNTAX_MESSAGE_PREFIX,
1921
SYNTAX_OR_ACCESS_SQLSTATE_CLASS,
2022
UNCATEGORIZED_PHASES,
2123
UNCAUGHT_PREFIX,
@@ -46,6 +48,8 @@ def classify(
4648
compiled: bool = message.lower().startswith(COMPILATION_PREFIX.lower())
4749
if errno == SYNTAX_ERRNO and compiled:
4850
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"
4953
if errno is not None and compiled:
5054
return "semantic_error", f"errno {errno} compilation error after parsing"
5155
if errno in REVIEWED_SEMANTIC_ERRNOS:

‎scripts/syntax_receipts/constants.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
{"accepted", "syntax_error", "semantic_error", "runtime_error", "unsupported_feature"}
88
)
99
SYNTAX_ERRNO: int = 1003
10+
PARSER_SYNTAX_ERRNO: int = 1002
11+
SYNTAX_MESSAGE_PREFIX: str = "syntax error"
1012
UNSUPPORTED_ERRNO: int = 2
1113
COMPILATION_PREFIX: str = "SQL compilation error"
1214
UNCAUGHT_PREFIX: str = "Uncaught exception of type"

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,23 @@
194194
message="External table identifier cannot be empty",
195195
expected_classification=None,
196196
),
197+
ClassifyTestCase(
198+
description="errno 1002 whose message says syntax error is a syntax error",
199+
errno=1002,
200+
sqlstate="42601",
201+
message=(
202+
"syntax error line At least one table name is required for ADD TABLES operations"
203+
" at position {1} unexpected '{2}'."
204+
),
205+
expected_classification=("syntax_error", "errno 1002 parser syntax error"),
206+
),
207+
ClassifyTestCase(
208+
description="errno 1002 with any other message is not established",
209+
errno=1002,
210+
sqlstate="42601",
211+
message="Invalid argument for the operation.",
212+
expected_classification=None,
213+
),
197214
ClassifyTestCase(
198215
description="a syntax error without the compilation prefix is not established",
199216
errno=1003,

0 commit comments

Comments
 (0)