Jark Wu created FLINK-24204:
-------------------------------

             Summary: Failed to insert nested types using value constructed 
functions 
                 Key: FLINK-24204
                 URL: https://issues.apache.org/jira/browse/FLINK-24204
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / API
    Affects Versions: 1.13.2
            Reporter: Jark Wu


{code}
Flink SQL> CREATE TABLE nested_type (
>     row_type ROW<id BIGINT, data STRING>,
>     map_type MAP<STRING, BIGINT>,
>     array_type ARRAY<BIGINT>
> ) WITH ('connector'='print');
[INFO] Execute statement succeed.

Flink SQL> INSERT INTO nested_type VALUES ((1, 'data'), MAP['key', 1], 
ARRAY[1,2,3])
> ;
[INFO] Submitting SQL update statement to the cluster...
[ERROR] Could not execute SQL statement. Reason:
org.apache.flink.table.planner.codegen.CodeGenException: Unsupported cast from 
'MAP<CHAR(3) NOT NULL, INT NOT NULL> NOT NULL' to 'MAP<STRING, BIGINT>'.
{code}

The query works if we change the sink table definition to :

{code}
CREATE TABLE nested_type (
    row_type ROW<id BIGINT, data STRING>,
    map_type MAP<STRING, INT>,
    array_type ARRAY<INT>
) WITH (
     'connector'='print'
);
{code}

Therefore, I think the root cause of this problem is Flink SQL doesn't support 
cast for nested types when code generation. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to