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

Functions in ExplodeFunctionUtil should handle null data to avoid NPE

    XMLWordPrintableJSON

    Details

      Description

      The following test case will encounter NPE:

          val t = tEnv.fromValues(
            DataTypes.ROW(
              DataTypes.FIELD("a", DataTypes.INT()),
              DataTypes.FIELD("b", DataTypes.ARRAY(DataTypes.STRING()))
            ),
            row(1, Array("aa", "bb", "cc")),
            row(2, null),
            row(3, Array("dd"))
          )
          tEnv.registerTable("T", t)
      
          tEnv.executeSql("SELECT a, s FROM T, UNNEST(T.b) as A (s)").print()
      

      Exception is

      Caused by: java.lang.NullPointerException
      	at scala.collection.mutable.ArrayOps$ofRef$.length$extension(ArrayOps.scala:192)
      	at scala.collection.mutable.ArrayOps$ofRef.length(ArrayOps.scala:192)
      	at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:32)
      	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
      	at org.apache.flink.table.planner.plan.utils.ObjectExplodeTableFunc.eval(ExplodeFunctionUtil.scala:34)
      

      The reason is functions in ExplodeFunctionUtil do not handle null data. Since 1.12, the bug is fixed, see https://issues.apache.org/jira/browse/FLINK-18528

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                godfreyhe godfrey he
                Reporter:
                godfreyhe godfrey he
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: