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

   ## What is the purpose of the change
   
   An INSERT with a column list fails when an omitted column is of type VARIANT 
or BITMAP.
   
   ```sql
   CREATE TABLE snk (k INT, v VARIANT, b BITMAP) WITH ('connector' = 
'blackhole');
   
   INSERT INTO snk (k) SELECT k FROM src;
   ```
   
   | Omitted column type                                                   | 
Before                                                                    | 
After              |
   
|-----------------------------------------------------------------------|---------------------------------------------------------------------------|--------------------|
   | `VARIANT`, `ARRAY<VARIANT>`, `ROW<f VARIANT>`, `MAP<STRING, VARIANT>` | 
`SQL validation failed. Unsupported type when convertTypeToSpec: VARIANT` | 
filled with `NULL` |
   | `BITMAP`, `ARRAY<BITMAP>`, `ROW<f BITMAP>`                            | 
`SQL validation failed. Unsupported type when convertTypeToSpec: OTHER`   | 
filled with `NULL` |
   
   `PreValidateReWriter` pads every omitted column with `CAST(NULL AS <column 
type>)`. The cast target comes from `SqlTypeUtil#convertTypeToSpec`, which had 
no branch for either type.
   
   ## Brief change log
   
   Both changes are in Flink's copy of `SqlTypeUtil`:
     - VARIANT: backport of CALCITE-7293, which adds VARIANT to `isAtomic`.
     - BITMAP: `convertTypeToSpec` maps `BitmapRelDataType` to 
`SqlBitmapTypeNameSpec`.
   
   Notes for reviewers:
     - The VARIANT line is the same one the Calcite 1.42.0 upgrade in #28981 
brings for FLINK-40001. Whichever PR merges second resolves a one-line 
conflict, and the backport marker can then go.
     - Flink disables Calcite's implicit type coercion, so the `isAtomic` 
change has no effect outside `convertTypeToSpec`.
     - Calcite cannot fix BITMAP. `BitmapRelDataType` reports 
`SqlTypeName.OTHER`, so it needs a Flink branch.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - `SqlTypeUtilTest` converts VARIANT and BITMAP to a type spec and 
unparses it. It covers nullable and NOT NULL, and both types nested in ARRAY, 
ROW and MAP.
     - `VariantSemanticTest` and `BitmapSemanticTest` run `INSERT INTO sink_t 
(k) SELECT k FROM t` end to end and check that the omitted columns arrive as 
`NULL`.
     - Without the fix, all 11 new cases fail with the errors above.
   
   ## 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 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