Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2739

NPE will thrown if the DEFINE statement contains IN in MATCH_RECOGNIZE

    XMLWordPrintableJSON

Details

    Description

      For the following query:

      select *
      from emp
      match_recognize(
        partition by job, sal
        order by job asc, sal desc, empno
        pattern (strt down+ up+)
        define
         down as down.mgr in (0, 1),
         up as up.mgr > prev(up.mgr)
      ) as mr";
      

      the following exception will be thrown:

      java.lang.NullPointerException
      at java.util.Objects.requireNonNull(Objects.java:203)
      at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:4495)
      at org.apache.calcite.sql2rel.StandardConvertletTable.lambda$new$9(StandardConvertletTable.java:204)
      at org.apache.calcite.sql2rel.SqlNodeToRexConverterImpl.convertCall(SqlNodeToRexConverterImpl.java:63)
      at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:4673)
      at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:3978)
      at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138)
      at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:4542)
      at org.apache.calcite.sql2rel.SqlToRelConverter.convertMatchRecognize(SqlToRelConverter.java:2261)
      at org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:1954)
      at org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:1959)
      at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:644)
      at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:625)
      at org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3065)
      at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:561)
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dian.fu Dian Fu
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m