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: [email protected]

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

Reply via email to