Add SELECT * EXCLUDE, SELECT * EXCEPT support#6481
Add SELECT * EXCLUDE, SELECT * EXCEPT support#6481mustafasrepo merged 9 commits intoapache:mainfrom synnada-ai:feature/exclude_support
Conversation
comphead
left a comment
There was a problem hiding this comment.
Can we also have test cases for negative scenarios, like exclude non existent columns, or exclude what is included, or exclude duplicated cols
I have extended to cover negative scenarios, thanks for the suggestion @comphead. |
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
|
Because of the issue in #6495. CI fails, I will fix CI problem, once that issue is resolved. |
|
|
||
| # EXCEPT, or EXCLUDE can only be used after wildcard * | ||
| # below query should give 4 columns, a1, b1, b, c, d | ||
| query IIIII |
There was a problem hiding this comment.
that is very interesting scenario, so if the col a aliased as a1 then except/exclude won't exclude it, but in the same time won't fail.
| # EXCEPT, or EXCLUDE shouldn't contain duplicate column names | ||
| statement error DataFusion error: Error during planning: EXCLUDE or EXCEPT contains duplicate column names | ||
| SELECT * EXCLUDE(a, a) | ||
| FROM table1 |
There was a problem hiding this comment.
what if scenario?
SELECT a EXCLUDE(a)
FROM table1
There was a problem hiding this comment.
AFAIK EXCLUDE can only be used to modify the wildcard, so that query wouldn't be valid
There was a problem hiding this comment.
okay, what if
select * exclude (a) from (select a from table1) x
There was a problem hiding this comment.
I think that's a good test!
alamb
left a comment
There was a problem hiding this comment.
Looks really nice to me. Thank you @mustafasrepo and @ozankabak
|
Here is a proposed addition to the user guide for this feature: #6512 |
Which issue does this PR close?
Closes #6439.
Rationale for this change
With this PR we can run
SELECTqueries withEXCLUDEwhere all the columns exceptEXCLUDEcolumns are projected, such as below.Similar behavior can be obtained using EXCEPT clause also. Query below can also be run with this PR
What changes are included in this PR?
Are these changes tested?
Yes new tests are added
select.sltfile, to check whether query produces expected columns.Are there any user-facing changes?