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

   ## What is the purpose of the change
   
   When a source supports nested projection push-down, a `NOT NULL` field of a 
nullable `ROW` column was pushed into the scan with its declared `NOT NULL` 
type, although it is nullable when read through the nullable `ROW`. This made 
planning fail with `type mismatch: INTEGER NOT NULL vs INTEGER` (e.g. `SELECT 
ns.v, ns.w FROM T`), or, if the field only appeared inside an expression, 
produced wrong results because null checks were optimized away (e.g. `ns.v IS 
NULL` returned `false` for a NULL `ns`).
   
   A pushed nested field is now nullable if the field or any `ROW` on its 
access path is nullable.
   
   ## Brief change log
   
     - `PushProjectIntoTableSourceScanRule`: make the projected type of each 
pushed field nullable if any `ROW` on its path is nullable. This applies to the 
new produced type and to `ProjectPushDownSpec#projectedPhysicalType`, so the 
source is told the correct type.
     - `PushProjectIntoTableSourceScanRule`: rewrite the project with the typed 
`NestedProjectionUtil.rewrite` overload (already used by the join and filter 
rewrites), so the new input refs match the new scan row type. The overload is 
made public.
     - `TestValuesTableFactory`: nested projection no longer fails with an NPE 
when a parent `ROW` is NULL (separate commit).
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - `TableSourceITCase` (stream): NULL `ROW` values with `ns.v`, `ns.v + 1` 
and `ns.v IS NULL` / `COALESCE(ns.v, -1)`. The plain query and the `IS NULL` 
query fail without the fix.
     - `TableSourceITCase` (batch): same data, plus a `NOT NULL` ROW nested in 
a nullable ROW.
     - `PushProjectIntoTableSourceScanRuleTest`: plan tests with 
`verifyRelPlanWithType` for a `NOT NULL` field of a nullable `ROW` and one 
below a nullable `ROW`. Both fail without the fix.
   
   ## 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 (Sonnet 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