Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-33523

DataType ARRAY<INT NOT NULL> fails to cast into Object[]

    XMLWordPrintableJSON

Details

    Description

      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:

      Exception in thread "main" java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
      at FlinkArrayIntNotNullTest.main(FlinkArrayIntNotNullTest.java:18)
      

      Repro:

      
        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));
          }
        }
      
      

      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[].

      Attachments

        Issue Links

          Activity

            People

              martijnvisser Martijn Visser
              prabhujoseph Prabhu Joseph
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: