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

Nullable ArrayData should not be Object[]

    XMLWordPrintableJSON

Details

    Description

      sql:

      "INSERT INTO %s "
      + " (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) values ("
      + "1,'dim',cast(20.2007 as double),false,652482,cast('2020-07-08' as date),'source_test',cast('2020-07-10 16:28:07.737' as timestamp),"
      + "cast(8.58965 as float),cast(ARRAY [464,98661,32489] as array<int>),cast(ARRAY [8589934592,8589934593,8589934594] as array<bigint>),"
      + "ARRAY[cast(8.58967 as float),cast(96.4667 as float),cast(9345.16 as float)], ARRAY [cast(587897.4646746 as double),cast(792343.646446 as double),cast(76.46464 as double)],"
      + "cast(ARRAY [true,true,false,true] as array<boolean>),cast(ARRAY ['monday','saturday','sunday'] as array<STRING>),true,cast(8119.21 as numeric(6,2)), cast('2020-07-10 16:28:07.737' as timestamp)"
      + ")";

      error:

      Caused by: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Integer;
      at org.apache.flink.table.data.GenericArrayData.toIntArray(GenericArrayData.java:297) ~[flink-table-common]

      related codegen result:

      objArray$81 = new Object[result$76.size()];
      for ( i$82 = 0; i$82 < result$76.size(); i$82++) {
      if (!result$76.isNullAt(i$82)) {
      objArray$81[i$82] = result$76.getBoolean(i$82);

      cause:
      ArrayToArrayCastRule#arrayElementType use Object when a column is nullable, but GenericArrayData only accepts array with specific
      types, like Integer[], I think we should follow CodeGenUtils#boxedTypeTermForType

      slinkydeveloper

      Attachments

        Issue Links

          Activity

            People

              slinkydeveloper Francesco Guardiani
              wenlong.lwl Wenlong Lyu
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: