You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "raminqaf (via GitHub)" <gi...@apache.org> on 2026/07/29 14:00:01 UTC

[PR] [FLINK-40255][table-planner] Fix compiled plan serde for VARIANT type [flink]

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

   ## What is the purpose of the change                                                                                                                                                       
                                                                                                                                                                                              
   VARIANT plans and executes correctly, but serializing a plan containing it throws. `COMPILE PLAN`, `StatementSet#compilePlan` and `TableEnvironment#compilePlanSql` are unusable with VARIANT, as is plan restore.                                                                                                                                                               
   Two `RelDataType` ⇄ `LogicalType` converters exist and only one knew VARIANT. `FlinkTypeFactory`, used during planning, handles it. `LogicalRelDataTypeConverter`, used only by plan serde, had no VARIANT handling at all. Nothing forces the two to agree. A VARIANT-typed `RexNode`, for example the return type of `PARSE_JSON` in a projection, failed with `Unsupported RelDataType: VARIANT` on compile and `Logical type 'VARIANT' cannot be converted to a RelDataType` on restore. Independently, VARIANT was missing from `CompactSerializationChecker`, so a VARIANT in an `ExecNode` output type fell back to generic serialization and failed with `Unable to serialize logical type 'VARIANT'`.                                                      
                                                                                                                                                                                              
   ## Brief change log                                                                                                                                                                        
                                                                                                                                                                                              
     - `LogicalRelDataTypeConverter` converts VARIANT in both directions                                                                                                                      
     - `CompactSerializationChecker` reports VARIANT as compactly serializable. This is what fixes serialization: the compact path already round-trips VARIANT through `LogicalTypeParser`    
     - `LogicalTypeJsonSerializer` and `LogicalTypeJsonDeserializer` get explicit VARIANT cases so the two switches stay symmetric and a plan that spells VARIANT out as an object still restores                                                                                                                                                                                   
                                                                                                                                                                                              
   ## Verifying this change                                                                                                                                                                   
                                                                                                                                                                                              
   This change added tests and can be verified as follows:                                                                                                                                    
                                                                                                                                                                                              
     - Added VARIANT to `LogicalTypeJsonSerdeTest`, `RelDataTypeJsonSerdeTest`, `DataTypeJsonSerdeTest` and `LogicalRelDataTypeConverterTest`, standalone and nested in `ARRAY`/`MULTISET`/`MAP`/`ROW`, nullable and `NOT NULL`                                                                                                                                    
     - Added a VARIANT input ref and a VARIANT-typed `ITEM` call to `RexNodeJsonSerdeTest`                                                                                                    
     - Added the `calc-variant` restore program to `CalcRestoreTest`. Its compiled plan carries VARIANT both as the return type of a `PARSE_JSON` call and in the `ExecNode` output type, so it covers both reported symptoms end to end                                                                                                                                                
     - Each of the five test classes fails on `master` with the errors quoted above and passes with the fix. Reverting only the `src/main` changes makes `calc-variant` fail at plan load, confirming the restore direction is guarded                                                                                                                                                
   VARIANT had zero plan serde coverage before this change. `VariantSemanticTest` cannot catch this class of bug because `SemanticTestBase` never serializes a plan.                          
                                                                                                                                                                                              
   ## 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 (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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40255][table-planner] Fix compiled plan serde for VARIANT type [flink]

Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #28841:
URL: https://github.com/apache/flink/pull/28841#discussion_r3676121374


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/CalcRestoreTest.java:
##########
@@ -43,6 +43,7 @@ public List<TableTestProgram> programs() {
                 CalcTestPrograms.CALC_UDF_SIMPLE,
                 CalcTestPrograms.CALC_UDF_COMPLEX,
                 CalcTestPrograms.CALC_CURRENT_TIMESTAMP,
-                CalcTestPrograms.COALESCE);
+                CalcTestPrograms.COALESCE,
+                CalcTestPrograms.CALC_VARIANT);

Review Comment:
   nit: could be also added to CalcBatchRestoreTest but I guess we have basically no variant coverage for batch yet



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40255][table-planner] Fix compiled plan serde for VARIANT type [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #28841:
URL: https://github.com/apache/flink/pull/28841#issuecomment-5118898172

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "cb141575b23be30ca05b4d8baf67ef9fdf0c028f",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "cb141575b23be30ca05b4d8baf67ef9fdf0c028f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * cb141575b23be30ca05b4d8baf67ef9fdf0c028f UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-40255][table-planner] Fix compiled plan serde for VARIANT type [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin merged PR #28841:
URL: https://github.com/apache/flink/pull/28841


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org