Support correlated subqueries for DELETE #9447
Conversation
core/trino-main/src/main/java/io/trino/sql/planner/optimizations/ReplicateJoinInDelete.java
Outdated
Show resolved
Hide resolved
a6c538d to
86e81bd
Compare
|
@kasiafi AC |
|
@Praveen2112 please rebase |
7e1f08e to
1136816
Compare
...-main/src/main/java/io/trino/sql/planner/optimizations/ReplicateJoinAndSemiJoinInDelete.java
Outdated
Show resolved
Hide resolved
|
Hi, is there any progress on this? We are facing a similar case and would like to fix the issue if possible. |
|
Sorry for the delay, will rebase and apply the comments by this week. |
1136816 to
98f0e28
Compare
|
@Praveen2112 did you have a chance to look at https://github.com/trinodb/trino/pull/9447/files#r756968059 ? |
|
@findepi Yes. I think we could implement it by re-wiriting only the probe side (for INNER and LEFT join) and leave build side part of the plan. Is my understanding is correct ? I have updated the PR based on this above mentioned approach. |
|
@Praveen2112 can you please check the build status? |
|
@findepi The build is now green. |
c7b3865 to
c726f4d
Compare
|
(squashed a fixup) |
findepi
left a comment
There was a problem hiding this comment.
"Support correlated EXISTS subquery for DELETE"
...-main/src/main/java/io/trino/sql/planner/optimizations/ReplicateJoinAndSemiJoinInDelete.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
I don't understand why ReplicateSemiJoinInDelete/ReplicateJoinAndSemiJoinInDelete needs to be run before ReorderJoins.
I think ReplicateSemiJoinInDelete/ReplicateJoinAndSemiJoinInDelete would undo distirbution type picked by ReorderJoins. What am i missing?
There was a problem hiding this comment.
Since ReorderJoins can flip the JoinNode - we would like to avoid it for the PlanNode between Delete and TableScan. So we run them before applying these optimizer.
There was a problem hiding this comment.
This is not a good way to solve this issue. Optimizer rules need to be able to run regardless of which order they are applied (i.e., correctness of the plan should not depend on the order of rule application -- only query performance should be affected).
How is this PR different from what we did for #8286 ?
...-main/src/main/java/io/trino/sql/planner/optimizations/ReplicateJoinAndSemiJoinInDelete.java
Outdated
Show resolved
Hide resolved
...-main/src/main/java/io/trino/sql/planner/optimizations/ReplicateJoinAndSemiJoinInDelete.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
i guess this should be:
if (isDeleteQuery) {
verify(joinType == INNER || joinType == LEFT
There was a problem hiding this comment.
UPDATE can be applied in a follow up PR.
There was a problem hiding this comment.
i guess this should be:
if (isDeleteQuery) { verify(joinType == INNER || joinType == LEFT
has this been resolved?
or, am i being wrong here?
testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java
Outdated
Show resolved
Hide resolved
|
Which connectors support these? Should we add test cases to |
Hive currently supports this.
|
c726f4d to
da82491
Compare
|
@findepi AC. Except migration of tests from BCT - which we might address in a different PR. WDYT ? |
core/trino-main/src/main/java/io/trino/sql/planner/optimizations/ReplicateSemiJoinInDelete.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
i guess this should be:
if (isDeleteQuery) { verify(joinType == INNER || joinType == LEFT
has this been resolved?
or, am i being wrong here?
testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java
Outdated
Show resolved
Hide resolved
...-main/src/main/java/io/trino/sql/planner/optimizations/ReplicateJoinAndSemiJoinInDelete.java
Outdated
Show resolved
Hide resolved
...-main/src/main/java/io/trino/sql/planner/optimizations/ReplicateJoinAndSemiJoinInDelete.java
Outdated
Show resolved
Hide resolved
...-main/src/main/java/io/trino/sql/planner/optimizations/ReplicateJoinAndSemiJoinInDelete.java
Outdated
Show resolved
Hide resolved
7366f38 to
6d3fd8d
Compare
|
@findepi Thanks for the review. AC |
|
thanks for the update pending comments |
|
I wasn't able to add the comment there. So will add it here This would make the query to fail a bit early at @findepi WDYT ? |
|
Oh, this is because #9447 (comment) remains outstanding. |
i take this back. |
True.
It comes when we translate correlated subqueries |
Joins distribution would be set to BROADCAST in case of DELETE
6d3fd8d to
c081884
Compare
|
@martint Sorry for continuing it here as I’am unable to add comments in that there. The main issue here is that - This PR is kind of an enhancement to #8286, #8286 solves the issue which was bcoz of |
|
CI failed (https://github.com/trinodb/trino/runs/7542141425?check_suite_focus=true). I rerun it. |
|
@Praveen2112 - could you propose a release note for this fix? |
|
I have updated in PR message. |
|
re #9447 (comment) (can't reply inline..)
That's an oversimplification. There are some dependencies. For example
Absolutely. I want to stress this out, this is paramount. (BTW I was convinced this isn't the case here.) |
Description
Support correlated subqueries for DELETE
Improvement for DELETE operations
Core Query Engine
Related issues, pull requests, and links
Documentation
(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
(x) Release notes entries required with the following suggested text: