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

ASF GitHub Bot updated FLINK-40606:
-----------------------------------
    Labels: pull-request-available  (was: )

> Casting binary arrays generates invalid Java array allocation
> -------------------------------------------------------------
>
>                 Key: FLINK-40606
>                 URL: https://issues.apache.org/jira/browse/FLINK-40606
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 2.4.0
>            Reporter: dylanhz
>            Priority: Major
>              Labels: pull-request-available
>
> Casting an array to {{ARRAY<VARBINARY(1)>}} fails during generated code 
> compilation.
> Reproduced on community master ({{e57428cafc9}}, Flink {{2.4-SNAPSHOT}}, Java 
> 17):
> {code:sql}
> SELECT event_id,
>        CAST(ARRAY[byte_a, byte_b] AS ARRAY<VARBINARY(1)>)
> FROM (VALUES
>   ('a', CAST(X'01' AS BYTES), CAST(X'0203' AS BYTES)),
>   ('b', CAST(X'0405' AS BYTES), CAST(X'06' AS BYTES))
> ) AS v(event_id, byte_a, byte_b);
> {code}
> *Expected:* Two rows with each binary array element truncated to at most one 
> byte.
> *Actual:*
> {noformat}
> CompileException: Line 80, Column 44: '{' expected instead of '['
> {noformat}
> {{ArrayToArrayCastRule}} calls {{CastRuleUtils.newArray()}} with element type 
> {{byte[]}}, producing:
> {code:java}
> byte[][] objArray$8 = new byte[][arraySize$7];
> {code}
> The allocation should be {{new byte[arraySize$7][]}}.
> Casting to {{ARRAY<BYTES>}} does not expose this on current master because 
> {{IdentityCastRule}} bypasses the element conversion.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to