-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-43980][SQL] introducing select * except syntax
#43843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2ea05b3 to
18dd5b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making a PR, @milastdbx . Could you provide some references for this syntax in other SQL environments?
When you say other SQL environments, what exactly are you referring to ? |
|
Popular ones like |
I don't think any other platform supports it. I maybe rushed the comment saying its ansii standard. I'll update PR description |
dongjoon-hyun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apache Spark community want to be as compatible as possible other SQL environments in order to avoid potential lock-ins effects. Given that context, this new syntax looks too esoteric to be accepted from my perspective.
Some other Apache Spark committers may have different opinions.
|
Yeah, i wouldn't add this as a dialect but better stick to other DBMSes or ANSI standard |
|
I think this is a useful feature, see https://stackoverflow.com/questions/29095281/select-all-the-columns-of-a-table-except-one-column and https://dba.stackexchange.com/questions/1957/sql-select-all-columns-except-some In fact, Spark already has a If we have to follow an example, Databricks SQL supports this syntax: https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-select.html |
|
im okay if we already have the variant. |
|
Bigquery supports On the other hand, Snowflake and DuckDB use
For what it's worth, I do things like My app's DB (not spark) doesn't support the |
sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4
Outdated
Show resolved
Hide resolved
sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4
Outdated
Show resolved
Hide resolved
sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/resources/sql-tests/results/selectExcept.sql.out
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/resources/sql-tests/results/selectExcept.sql.out
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/resources/sql-tests/results/selectExcept.sql.out
Outdated
Show resolved
Hide resolved
|
there is a test failure: |
|
The error in docker-integration-tests is unrelated, thanks, merging to master! |
What changes were proposed in this pull request?
Changing parser to support new syntax when using * to fetch columns from source.
Introducing new expression
UnresolvedStarExceptin visit method when newly introduced syntax is created.Expansion of this expression is core logic of feature.
Why are the changes needed?
Introducing new
SELECT * EXCEPT (col1, col2)Does this PR introduce any user-facing change?
Yes, this PR introduces new SQL syntax, which is used to explicitly exclude columns from star projection.
How was this patch tested?
Unit tests.
Generated new golden files.
Was this patch authored or co-authored using generative AI tooling?
No