[
https://issues.apache.org/jira/browse/FLINK-33523?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Martijn Visser closed FLINK-33523.
----------------------------------
Resolution: Fixed
Fixed in apache/flink
master: fcc7bc2e5e529b135aee28d732b8c5a6769afdae
release-1.18: 674d3a746417ceb36f74ccebb6a713549af59033
> DataType ARRAY<INT NOT NULL> fails to cast into Object[]
> --------------------------------------------------------
>
> Key: FLINK-33523
> URL: https://issues.apache.org/jira/browse/FLINK-33523
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / API
> Affects Versions: 1.18.0
> Reporter: Prabhu Joseph
> Assignee: Martijn Visser
> Priority: Blocker
> Labels: pull-request-available
> Fix For: 1.18.1
>
>
> When upgrading Iceberg's Flink version to 1.18, we found the Flink-related
> unit test case broken due to this issue. The below code used to work fine in
> Flink 1.17 but failed after upgrading to 1.18. DataType ARRAY<INT NOT NULL>
> fails to cast into Object[].
> *Error:*
> {code}
> Exception in thread "main" java.lang.ClassCastException: [I cannot be cast to
> [Ljava.lang.Object;
> at FlinkArrayIntNotNullTest.main(FlinkArrayIntNotNullTest.java:18)
> {code}
> *Repro:*
> {code}
> import org.apache.flink.table.data.ArrayData;
> import org.apache.flink.table.data.GenericArrayData;
> import org.apache.flink.table.api.EnvironmentSettings;
> import org.apache.flink.table.api.TableEnvironment;
> import org.apache.flink.table.api.TableResult;
> public class FlinkArrayIntNotNullTest {
> public static void main(String[] args) throws Exception {
> EnvironmentSettings settings =
> EnvironmentSettings.newInstance().inBatchMode().build();
> TableEnvironment env = TableEnvironment.create(settings);
> env.executeSql("CREATE TABLE filesystemtable2 (id INT, data ARRAY<INT
> NOT NULL>) WITH ('connector' = 'filesystem', 'path' =
> '/tmp/FLINK/filesystemtable2', 'format'='json')");
> env.executeSql("INSERT INTO filesystemtable2 VALUES (4,ARRAY [1,2,3])");
> TableResult tableResult = env.executeSql("SELECT * from
> filesystemtable2");
> ArrayData actualArrayData = new GenericArrayData((Object[])
> tableResult.collect().next().getField(1));
> }
> }
> {code}
> *Analysis:*
> 1. The code works fine with ARRAY<INT> datatype. The issue happens when using
> ARRAY<INT NOT NULL>.
> 2. The code works fine when casting into int[] instead of Object[].
--
This message was sent by Atlassian Jira
(v8.20.10#820010)