SEPURI-SAI-KRISHNA opened a new pull request, #29263:
URL: https://github.com/apache/flink/pull/29263

   ## What is the purpose of the change
   
   `generateMapGet` assumes every non-`BinaryMapData` map is a `GenericMapData`:
   
   ```scala
   if ($mapTerm instanceof $BINARY_MAP) { ... } else { ($GENERIC_MAP) $mapTerm 
... }
   ```
   
   `MapDataContainer` is a third `MapData` implementation, returned by 
`MAP_FROM_ARRAYS`, `MAP_FROM_ENTRIES` and `MAP_UNION`, so key access on their 
results fails at runtime:
   
   ```
   SELECT MAP_FROM_ARRAYS(k, v)['a'] FROM src;
   -> ClassCastException: MapDataContainer cannot be cast to GenericMapData
        at BatchExecCalc$21.processElement(Unknown Source)
   ```
   
   Only key access breaks. `CARDINALITY`, `MAP_KEYS`, `MAP_VALUES`, 
`MAP_ENTRIES`, `CAST` and equality all work, because they go through the 
`MapData` interface. A map literal is unaffected.
   
   ## Brief change log
   
     - Guard the `GenericMapData` fast path with `instanceof` and route every 
other `MapData` through `keyArray()` / `valueArray()`. `BinaryMapData` now 
takes the generic path, which it already did structurally.
     - Rename the generated `binaryMap` local to `mapData`, since it is no 
longer binary-specific.
     - Add `testMapItemAccessOnMapReturningFunctions` to 
`ConstructedAccessFunctionsITCase`.
   
   ## Verifying this change
   
   This change added a test and can be verified as follows:
   
     - the new test fails on master with the `ClassCastException` above and 
passes with this change
     - it covers all three functions, plus `MAP['x', 9]['x']` for the 
`GenericMapData` path and a missing key still returning NULL
     - the map is built from table columns, not literals, so the expression is 
not constant-folded
   
   841 tests green locally: `MapFunctionITCase` (169), 
`CollectionFunctionsITCase` (624), `ConstructedAccessFunctionsITCase` (8), 
`FieldAccessFromTableITCase` (24), `VariantSemanticTest` (16).
   
   ## 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): **yes**, 
generated map key access. The `GenericMapData` hash lookup is preserved; 
`BinaryMapData` keeps the same array scan, now reached through the `MapData` 
interface.
     - 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)
   


-- 
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