Support correlated subquery in UPDATE assignments (SET)#8286
Support correlated subquery in UPDATE assignments (SET)#8286Praveen2112 merged 9 commits intotrinodb:masterfrom
Conversation
68af1d5 to
836ba76
Compare
There was a problem hiding this comment.
We could merge it with the previous tests but for HDP 3.1 it throws an IO Excpetion (https://issues.apache.org/jira/browse/HIVE-22318)
Happy to apply a workaround for it
cc: @losipiuk
There was a problem hiding this comment.
We could merge it with the previous tests but for HDP 3.1 it throws an IO Excpetion
is the test run for any other Hive version than 3?
There was a problem hiding this comment.
Please merge the test back, so that it's easier to see changes.
see // TODO (https://github.com/trinodb/trino/issues/8268) for the problem you're hitting.
836ba76 to
604e777
Compare
...rino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveTransactionalTable.java
Outdated
Show resolved
Hide resolved
...rino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveTransactionalTable.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Please merge the test back, so that it's easier to see changes.
see // TODO (https://github.com/trinodb/trino/issues/8268) for the problem you're hitting.
core/trino-main/src/test/java/io/trino/sql/planner/TestLogicalPlanner.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/optimizations/BeginTableWrite.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/optimizations/BeginTableWrite.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
nit: I would love to see in the commit description why this check is no longer needed :)
There was a problem hiding this comment.
Now with support for correlated queries for assignment...we would translate them to a LEFT JOIN with a non SCALAR build source.
fb737bc to
4055b11
Compare
|
@sopel39 can you take a look at property derivations? |
These look good |
core/trino-main/src/main/java/io/trino/sql/planner/optimizations/BeginTableWrite.java
Outdated
Show resolved
Hide resolved
...rino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveTransactionalTable.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Any particular reason to move this test case around?
Please keep it here for smaller diff
There was a problem hiding this comment.
Add a comment hinting why this test case is interesting
There was a problem hiding this comment.
There is a comment above which specifies the interesting reason for it.
There was a problem hiding this comment.
i see a blank line above this query, which comment are you referring to?
There was a problem hiding this comment.
I was referring the comment in Line 1420.
...rino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveTransactionalTable.java
Outdated
Show resolved
Hide resolved
4055b11 to
73e3911
Compare
|
@Praveen2112 do you consider this still a |
1f28f71 to
6125f3c
Compare
core/trino-main/src/main/java/io/trino/sql/analyzer/Analyzer.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/analyzer/Analysis.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/analyzer/Analysis.java
Outdated
Show resolved
Hide resolved
6125f3c to
8d471a6
Compare
|
@martint AC |
8d471a6 to
003984f
Compare
core/trino-main/src/main/java/io/trino/sql/analyzer/QueryType.java
Outdated
Show resolved
Hide resolved
This would remove the Analysis#resetUpdateType as the update type should never even be set to Update/delete for explain analyze queries
This makes the check if a table is update target or not independent on current state of the update type.
003984f to
b2173e0
Compare
|
@martint AC |
b2173e0 to
93e9caf
Compare
There was a problem hiding this comment.
This is used when creating a TableScanNode to set the updateTarget flag. Is it intentional that after this change we set the flag to true for ANALYZE, CREATE MATERIALIZED VIEW etc., while before this change it was set only for UPDATE and DELETE queries?
There was a problem hiding this comment.
It will be still set only for UPDATE and DELETE queries - as targetTable is set only for those two types of queries and isUpdateTarget will return false if the targetTable is Optional#empty
core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/test/PlanBuilder.java
Outdated
Show resolved
Hide resolved
Optimizer could flip the join and we don't want to apply the delete/update for incorrect table.
When we pass a correlated query as an assignment to a column we would translate them to a LEFT JOIN with a non SCALAR build source so current restriction is removed.
93e9caf to
06b408d
Compare
|
@kasiafi Thanks for the review. AC |
Additionally we support
MarkDistinctandAssignUniqueIdfor Update node. It works only for broadcast join and there will be a follow up PR that flips the Join toBROADCASTlike we do join SemiJoinNode in Delete operation