[
https://issues.apache.org/jira/browse/FLINK-41648?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated FLINK-41648:
-----------------------------------
Labels: pull-request-available (was: )
> Push nested field accesses below semi and anti joins
> ----------------------------------------------------
>
> Key: FLINK-41648
> URL: https://issues.apache.org/jira/browse/FLINK-41648
> Project: Flink
> Issue Type: Improvement
> Components: Table SQL / Planner
> Reporter: Fabian Hueske
> Assignee: Fabian Hueske
> Priority: Major
> Labels: pull-request-available
>
> FLINK-41410 added ProjectNestedFieldJoinTransposeRule, which pushes
> referenced leaf fields of ROW columns below a join so that the join shuffles
> and stores only the leaves it uses. The rule skips SEMI and ANTI joins.
> Queries that become semi/anti joins (IN, NOT IN, EXISTS, NOT EXISTS) still
> carry whole structs through the join.
> Example:
>
> {code:java}
> CREATE TABLE Orders (id INT, customer ROW<name STRING, address ROW<zip
> STRING, city STRING, ...>, ...>, ...);
> CREATE TABLE Blocked (customer ROW<id INT, reason STRING, details ROW<...>>,
> ...);{code}
> {code:java}
> SELECT o.id, o.customer.name
> FROM Orders o
> WHERE o.customer.address.zip IN (SELECT b.customer.details.zip FROM Blocked
> b);
> {code}
>
> Both join inputs carry their full ROW columns, although only `customer.name`,
> `customer.address.zip` and `customer.details.zip` are used. The join state
> and the shuffle contain the whole structs.
> h3. Why the rule skips these joins
> A semi/anti join outputs only the left columns, but its condition references
> left and right fields. The rule treats the join output as `left ++ right` and
> rewrites the top projection and the join condition in that single index
> space. For semi/anti joins the output row type has no right fields, so the
> projection and the condition use different index spaces.
> h3. Proposed change
> Amend ProjectNestedFieldJoinTransposeRule instead of adding a new rule:
> * Use the concatenation of the two input row types as the row type for
> rewriteForJoin and hasPrunableNestedLeaf when the join type is SEMI or ANTI.
> The projection only references left indices, which are the same in both
> spaces.
> * Remove the projectsRight() check in matches().
> * Check that the keep-alive column logic and the typeFixer still behave
> correctly, since the new join outputs only the left leaf columns.
> h3. Things to verify
> * Interaction with FlinkSemiAntiJoinProjectTransposeRule,
> FlinkSemiAntiJoinFilterTransposeRule and subquery decorrelation, and that the
> HEP fixpoint argument still holds with these rules in the loop.
> * Correct typing and nullability of leaves in conditions, including
> null-aware anti joins (NOT IN) and NULL structs.
> * Results unchanged for all of: IN, NOT IN, EXISTS, NOT EXISTS, with nested
> accesses in the condition only, in the projection only, and in both.
> h3. Tests
> * Plan tests in ProjectNestedFieldJoinTransposeRuleTest: semi and anti with
> nested condition, a leaf used only in the condition, NOT IN. The existing
> semi-join case, which asserts that the rule does nothing, changes.
> * One ITCase for result correctness with NULL structs, covering anti and NOT
> IN.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)