[ 
https://issues.apache.org/jira/browse/FLINK-41332?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Yuepeng Pan updated FLINK-41332:
--------------------------------
    Fix Version/s: 2.4.0

> COMPILE PLAN fails for a query with a UUID literal
> --------------------------------------------------
>
>                 Key: FLINK-41332
>                 URL: https://issues.apache.org/jira/browse/FLINK-41332
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table SQL / Planner
>    Affects Versions: 2.4.0
>            Reporter: Ramin Gharib
>            Priority: Critical
>             Fix For: 2.4.0
>
>
> A compiled plan cannot hold a {{UUID}} literal, so {{COMPILE PLAN}} fails for 
> every statement that contains one.
> {code:sql}
> CREATE TABLE src (k INT) WITH ('connector' = 'datagen', 'number-of-rows' = 
> '6');
> CREATE TABLE snk (u UUID, s STRING) WITH ('connector' = 'blackhole');
> COMPILE PLAN '/tmp/uuid-plan.json' FOR
> INSERT INTO snk SELECT UUID '550e8400-e29b-41d4-a716-446655440000', 'x' FROM 
> src;
> {code}
> {noformat}
> org.apache.flink.table.api.TableException: Literal type 'UUID' is not 
> supported for serializing value '550e8400-e29b-41d4-a716-446655440000'.
> {noformat}
> ||Statement||Compiles||
> |{{UUID}} literal in the projection|no|
> |{{WHERE u = UUID '...'}}|no|
> |{{WHERE u IN (UUID '...', UUID '...')}}, serialized as a SARG|no|
> |{{CAST('550e8400-e29b-41d4-a716-446655440000' AS UUID)}}|yes|
> |{{GROUP BY u}}, {{UUID_V4()}} or {{CAST(u AS VARIANT)}}, with no 
> literal|yes, and the plan loads and runs|
> The Table API builds the same Calcite literal for {{lit(java.util.UUID)}}, so 
> it fails the same way.
> h3. Cause
> {{RexNodeJsonSerializer.serializeLiteralValue}} has no {{UUID}} case and 
> falls into the default branch. 
> {{RexNodeJsonDeserializer.deserializeLiteralValue}} has none either, so both 
> directions need one. The literal value is a {{java.util.UUID}}. Its canonical 
> string fits JSON and reads back with {{UUID.fromString}}.
> The type serde already handles {{UUID}}. Only literals are missing.
> h3. Tests
> * A {{UUID}} literal and a SARG over {{UUID}} literals in 
> {{RexNodeJsonSerdeTest}}.
> * A restore test with a {{UUID}} literal in a projection and in a filter. No 
> restore test covers {{UUID}} today.
> Workaround: write {{CAST('...' AS UUID)}} instead of the literal.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to