fhueske opened a new pull request, #30238:
URL: https://github.com/apache/flink/pull/30238

   ## What is the purpose of the change
   
   `ProjectNestedFieldJoinTransposeRule` (FLINK-41410) pushes the leaves of ROW 
columns that a query reads below a join, so that the join shuffles and stores 
only these leaves. The rule skipped SEMI and ANTI joins, so queries with `IN`, 
`NOT IN`, `EXISTS` or `NOT EXISTS` still carried whole structs through the 
join. For example, in
   
   ```sql
   SELECT L.nested.name FROM L WHERE L.id IN (SELECT R.id FROM R)
   ```
   
   the semi join carried the whole `nested` column although only `nested.name` 
is read.
   
   The rule skipped these joins because the output of a SEMI or ANTI join has 
only the left columns, while its condition reads both inputs. The rule rewrote 
the project and the condition over the join output row type, which has no right 
columns for these joins.
   
   This PR makes the rule work over the columns of both join inputs for all 
join types.
   
   ## Brief change log
   
     - `NestedProjectionUtil.rewriteForJoin` takes only the row types of the 
two join inputs, not the join output row type. It concatenates them with unique 
field names, because the columns are identified by name: both inputs may have a 
column `id`. The nullability that an outer join adds was already applied 
through the `generatesNullsOn*` flags, so the output row type is not needed.
     - New overload `NestedProjectionUtil.hasPrunableNestedLeaf(projects, 
condition, leftRowType, rightRowType, typeFactory)` for joins, which uses the 
same row type.
     - `ProjectNestedFieldJoinTransposeRule` no longer skips SEMI and ANTI 
joins.
     - Two `[hotfix]` commits from #30222 (FLINK-39804) are included, so that 
the new tests can use the renamed ITCase and the corrected test helpers. They 
become no-ops when this PR or #30222 is rebased after the other is merged:
       - Rename `NestedFieldJoinProjectionITCase` to 
`NestedFieldProjectionITCase`
       - Use SQL struct kinds in `NestedProjectionUtilJoinTest`
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - `ProjectNestedFieldJoinTransposeRuleTest`: plan tests for `IN` with 
nested accesses in the projection, in the condition, and only in the condition, 
and for `EXISTS`, `NOT EXISTS` and `NOT IN` (null-aware anti join). The former 
test that asserted that the rule does not fire for a semi join now shows the 
pushed-down leaves. It also covers inputs that both have a column `id`. Without 
unique field names, the condition `L.id = R.id` was silently rewritten to `IS 
NOT NULL($0)`. The test program now also contains 
`ProjectSemiAntiJoinTransposeRule`, as the production rule set does.
     - `NestedProjectionUtilJoinTest`: unit tests for the rewrite of a semi 
join condition that reads both inputs, and for `hasPrunableNestedLeaf` with 
inputs that have the same schema.
     - `NestedFieldProjectionITCase`: results for `IN`, `NOT IN`, `NOT EXISTS` 
and `EXISTS` with NULL structs and NULL leaves, including `NOT IN` with a NULL 
in the subquery. Each case also asserts that no struct column reaches the join. 
These tests fail without the change.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Claude Opus 5.5)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to