-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Use Node as isDeleteTarget argument #6296
Conversation
presto-main/src/main/java/io/prestosql/sql/analyzer/Analysis.java
Outdated
Show resolved
Hide resolved
make sure all tests pass (I think complex delete is tested also in raptor) |
099cf73
to
98685f4
Compare
@martint We probably want this one for 348 still. |
Sure. Any proposals for extra coverage to be added are welcome. |
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.
LGTM
This fixes two problems:
-
VIEW that contains unqalified names inside
- thanks for the test with Presto VIEW
- please add tests with Hive VIEW as well, to rule out any other implications -- this bug is fixed, but it uncovered general gap in our testing of views
-
DELERE FROM t
that usest
in subquery as well- please add a test for that as well (i think there might have been no end-user visible effect of the bug ("innocent bug") though)
I don't think this is addressed as long as Analysis performs the check by
The only effect so far of tagging a TableScanNode incorrectly as the delete target is that a certain optimization is disabled in that branch of plan (namely, the rewrite of filtering semi-join to inner). However, the flag I think that not taking this flag into consideration is a more serious issue than setting it where it doesn't belong. |
98685f4
to
b93adfa
Compare
Today. But this could change in the future. Would it be possible to have a validator that verifies the flag is properly set and retained during optimizations? (i don't mean the validator should be part of this PR) |
b93adfa
to
749a01f
Compare
749a01f
to
85b3f66
Compare
@@ -98,6 +98,7 @@ | |||
private final Statement root; | |||
private final Map<NodeRef<Parameter>, Expression> parameters; | |||
private String updateType; | |||
// TODO Reference by NodeRef instead name so we can distinguish actual target from other references to same table in the query |
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.
We should fix this, not just leave a TODO. Otherwise, any query such as DELETE FROM t WHERE t.v IN (SELECT ... FROM t WHERE ...)
will do the wrong thing. That's actually a regression from how this used to work before isDeleteTarget
was added.
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.
@martint yes, we discussed that.
We want to fix the user-visible bug for views first (this PR)
and i then the (currently user-invisible) bug will be follow up
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.
That's actually a regression from how this used to work before isDeleteTarget was added.
Currently this flag prevents semi_join->join
rewrite, so when it's true
for target table scans, previous behavior is preserved.
@losipiuk you mixed up commits from other PR |
thanks :) |
a847554
to
85b3f66
Compare
Fixes: #6294
Replaces: #6288
As a followup we probably should pursue an approach to store
Analysis.target
as aNodeRef
insteadQualifiedObjectName
. There is a chance that a single query contains a table that is a delete target more than once. We should not treat all those occurrences as delete target.