-
-
Notifications
You must be signed in to change notification settings - Fork 750
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
Spark3: Support for INSERT [TABLE]
data manipulation statements
#2290
Conversation
This error: means that your dialect changes have affected what the resulting parse output looks like. This isn't necessarily a problem with your code. Rather, this is a check to ensure we don't accidentally change the parse output. To get past this build error, run the following command locally:
This will modify some (possibly a lot) of existing |
There are a few issues I've found in this PR. Opened an issue #2298 for one and will open the other shortly. The major problem I'm having is matching (in a non-brittle way) for the commented-out test case in -- TODO
---- Insert Using a FROM Statement
--INSERT INTO students
-- FROM applicants SELECT name, address, id applicants WHERE qualified = true;
-- FROM applicants SELECT name, address, id WHERE qualified = true; Two things happening here:
|
You may not be able to reuse parts of the ANSI dialect. That's not necessarily bad, but it does mean the PR will be bigger. I suggest that you initially focus on getting things to parse, even if it requires creating brand-new segments or copy/paste/modifying parts from the ANSI dialect. Once it's working, then you can look at possible ways to reduce the amount of new code (e.g. potentially by reusing more things from ANSI). |
Codecov Report
@@ Coverage Diff @@
## main #2290 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 161 161
Lines 11486 11490 +4
=========================================
+ Hits 11486 11490 +4
Continue to review full report at Codecov.
|
add overwrite test cases rename file to better reflect usage
INSERT TABLE
data manipulation statementsINSERT TABLE
data manipulation statements
INSERT TABLE
data manipulation statementsINSERT [TABLE]
data manipulation statements
…7l208/spark3-dml-insert
INSERT INTO students | ||
FROM applicants | ||
SELECT | ||
--name, address, id | ||
applicants | ||
WHERE qualified = TRUE; |
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.
Is this right? If selecting from applicants
then how can you select applicants
?
INSERT INTO students | |
FROM applicants | |
SELECT | |
--name, address, id | |
applicants | |
WHERE qualified = TRUE; | |
INSERT INTO students | |
FROM applicants | |
SELECT | |
name, address, id | |
WHERE qualified = TRUE; |
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.
It's odd syntax but valid. Additional info on comment above
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.
What does that mean out of curiosity? Select all the columns out of that table?
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.
I pulled this one from the Issue which was pulled from the docs. Seemed odd so ran it, tested it and it worked.
I ran it past a few other people on my team and think it's just a very, poorly named column alias rather than a table reference.
Going to remove it from the code and test cases for now. If it turns out that it's a table reference, it won't be hard to add back in when/if someone opens an issue.
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.
also the columns were commented out which they shouldn't have been. fixed that as well 😁
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.
Well if not commented out then I'm guessing it just gives the last (id
) column the alias applicants
. Yeah super confusing. Glad we figured that out and removed it before merging!
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
# TODO is there a less brittle way to do this using an existing class(es)? | ||
# TODO if not, how to best construct a new class for `SELECT` match? |
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.
Let's remove these, as can't honestly think of a better way to do this, other than splitting up Select Segment hugely which seems overkill for this one usecase.
# TODO is there a less brittle way to do this using an existing class(es)? | |
# TODO if not, how to best construct a new class for `SELECT` match? |
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.
👍
Brief summary of the change made
Fixes #1932
Are there any other side effects of this change that we should be aware of?
N/A. Opening Draft PR for feedback
Pull Request checklist
Please confirm you have completed any of the necessary steps below.
Included test cases to demonstrate any code changes, which may be one or more of the following:
.yml
rule test cases intest/fixtures/rules/std_rule_cases
..sql
/.yml
parser test cases intest/fixtures/dialects
(note YML files can be auto generated withtox -e generate-fixture-yml
).test/fixtures/linter/autofix
.Added appropriate documentation for the change.
Created GitHub issues for any relevant followup/future enhancements if appropriate.