Skip to content

[SPARK-47344] Extend INVALID_IDENTIFIER error beyond catching '-' in an unquoted identifier and fix "IS ! NULL" et al. - #45470

Closed
srielau wants to merge 9 commits into
apache:masterfrom
srielau:SPARK-47344
Closed

srielau wants to merge 9 commits into
apache:masterfrom
srielau:SPARK-47344

Conversation

@srielau

@srielau srielau commented Mar 12, 2024 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

In this PR we propose to extend the lexing of IDENTIFIER beyond what is legitimate for unquoted identifiers to include
"plausible" identifiers. We then use the "exit" hook in the parser raise INVALID_IDENTIFIER error which is more meaningful than a syntax error.

Specifically we allow:

  • general letters beyond the ASCII a-z. This will catch locale specific names
  • URIs which are used for table's represented by a path.

As part of this PR we also found that rolling NOT and ! into one token is a "bad idea".
We allow:

CREATE TABLE t(c1 INT ! NULL); etc.
This is clearly not intended.

! is now ONLY allowed as a boolean prefix operator.

Why are the changes needed?

This change improves the user experience in case of an error by returning a more meaningful error.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Existing test suite + new unit tests

Was this patch authored or co-authored using generative AI tooling?

No

@github-actions github-actions Bot added the SQL label Mar 12, 2024
@srielau srielau changed the title [SPARK=47344] Extend INVALID_IDENTIFIER [WIP] [SPARK-47344] Extend INVALID_IDENTIFIER Mar 12, 2024
@github-actions github-actions Bot added the DOCS label Mar 12, 2024
@srielau
srielau force-pushed the SPARK-47344 branch 2 times, most recently from 7632ecc to b95d012 Compare March 12, 2024 17:48
@srielau srielau changed the title [WIP] [SPARK-47344] Extend INVALID_IDENTIFIER [SPARK-47344] Extend INVALID_IDENTIFIER error beyond catching '-' in an unquoted identifier Mar 12, 2024
Comment thread sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseLexer.g4 Outdated
@srielau srielau changed the title [SPARK-47344] Extend INVALID_IDENTIFIER error beyond catching '-' in an unquoted identifier [SPARK-47344] Extend INVALID_IDENTIFIER error beyond catching '-' in an unquoted identifier and fix "IS ! NULL" et al. Mar 13, 2024
@gengliangwang

Copy link
Copy Markdown
Member

Thanks, merging to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants