-
Notifications
You must be signed in to change notification settings - Fork 63
Adds support for DML INSERT's WHERE/ALIAS in Parser, AST, and Plans #1061
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
Conformance comparison report
Number passing in both: 4271 Number failing in both: 113 Number passing in Base (ef2847e) but now fail: 0 Number failing in Base (ef2847e) but now pass: 0 |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1061 +/- ##
============================================
+ Coverage 74.93% 74.96% +0.02%
Complexity 2334 2334
============================================
Files 249 249
Lines 18559 18537 -22
Branches 3360 3354 -6
============================================
- Hits 13907 13896 -11
+ Misses 3627 3617 -10
+ Partials 1025 1024 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
While this does satisfy #1038 and #1043 issues, we don't have a solution for #1052 yet in this PR. I was hoping we could delete this line, in order to preserve DML in the original plan. We'd also have to delete this function so as to avoid rewriting DML into an SFW query at all. Doing this would allow your customers to do whatever interesting things they want with DML, with the benefit that you don't have to expose the logical-resolved plan as API, and your customers for whom DML-as-SFW won't work don't have to jump thru hoops with trying to rewrite the DML-as-SFW query into something usable. |
I also think that |
Modifies how DML is compiled
I completely agree with retaining the structure of the DML within the physical plan and have consulted @am357 about it as well. I've just added recent changes to reflect our position. If you'll notice, I didn't remove the DML |
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 did not review every detail--but I did bring in my DML rewrite WIP into this branch on my local machine to verify that this would be sufficient to meet my use case, and it looks like it is. So, overall, this LGTM.
However, I did accidentally discover that inclusion of the VALUE <expr>
clause (which I'm pretty sure was a mistake from the past since it's redundant with VALUES << <expr> >>
), causes an internal error caused by a ClassCastException
within the ANTLR AST -> PartiQL AST visitor. (We have to keep around the VALUE
clause for backward compatibility...)
i.e. this query will reproduce the issue: INSERT INTO foo VALUE { 'id': 42 } ON CONFLICT DO REPLACE EXCLUDED WHERE TRUE
@dlurton -- regarding the query for reproducing the issue. It seems that this actually has to do with the mixing-and-matching of the "legacy" INSERT command with the "current" ON CONFLICT clause. The grammar says: insertCommand
: INSERT INTO pathSimple VALUE value=expr ( AT pos=expr )? onConflictClause? # InsertLegacy
| INSERT INTO symbolPrimitive asIdent? value=expr onConflictClause? # Insert
;
onConflictClause
: ON CONFLICT WHERE expr DO NOTHING # OnConflictLegacy
| ON CONFLICT conflictTarget? conflictAction # OnConflict
; While the grammar says we can mix-and-match the "legacy" and "current" commands/clauses, we actually don't allow it in the visitor. Ideally, this should be expressed more explicitly within our grammar. I spoke to @am357 , and it seems that we are maintaining the "legacy" insert and "legacy" on-conflict clauses for backward-compatibility. Anyways, this issue is present in |
…1061) * Adds support for DML INSERT's WHERE/ALIAS in Parser, AST, and Plans * Replaces physical dml_query with dedicated note (dml)
Relevant Issues
project
operators #1052Description
Changes
as_alias
to theinsert
AST node.target_alias
property to thedml_insert
,dml_replace
, anddml_update
nodes within theLogical and Logical Resolved plans
ON CONFLICT DO [REPLACE|UPDATE] EXCLUDED WHERE <condition>
condition
to the AST nodes ofdo_replace
anddo_update
condition
property to thedml_replace
anddml_update
nodes within theLogical and Logical Resolved plans
dml_query
from the physical plan and adds thestatement.dml
anddml_operation
to the physical plan.dml_query
-- which was effectively just a struct with key-value pairs.Note: The pipeline currently doesn't support the physical plan for
ON CONFLICT DO UPDATE EXCLUDED
. This PR still provides the changes for this clause, but it does not complete the required physical plan changes to support full planning of this statement.Testing
table_unique_id
androws
expressions. These cases are covered by the integration tests underIntegrationTests.kt
.To Check
For the PR reviewer, you can use these features by starting up the experimental planner in the CLI and adding an empty table to the global environment:
Then, explain the
ast
,logical
,logical_resolved
, andphysical
plans for example queries. For example, here is thelogical_resolved
:Other Information
partiql.ion
has modifications. See the CHANGELOG.License Information
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.