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

Cannot register a view with MATCH_RECOGNIZE clause

    XMLWordPrintableJSON

Details

    Description

      		TableEnvironment env = TableEnvironment.create(EnvironmentSettings.newInstance()
      			.useBlinkPlanner()
      			.build());
      
      		env.executeSql("" +
      			"CREATE TEMPORARY TABLE data (\n" +
      			"    id INT,\n" +
      			"    ts AS PROCTIME()\n" +
      			") WITH (\n" +
      			"    'connector' = 'datagen',\n" +
      			"    'rows-per-second' = '3',\n" +
      			"    'fields.id.kind' = 'sequence',\n" +
      			"    'fields.id.start' = '1000000',\n" +
      			"    'fields.id.end' = '2000000'\n" +
      			")");
      
      		env.executeSql("" +
      			"CREATE TEMPORARY VIEW events AS \n" +
      			"SELECT 1 AS key, id, MOD(id, 10) AS measurement, ts \n" +
      			"FROM data");
      
      		env.executeSql("" +
      			"CREATE TEMPORARY VIEW foo AS \n" +
      			"SELECT * \n" +
      			"FROM events MATCH_RECOGNIZE (\n" +
      			"    PARTITION BY key \n" +
      			"    ORDER BY ts ASC \n" +
      			"    MEASURES \n" +
      			"      this_step.id as startId,\n" +
      			"      next_step.id as nextId,\n" +
      			"      this_step.ts AS ts1,\n" +
      			"      next_step.ts AS ts2,\n" +
      			"      next_step.measurement - this_step.measurement AS diff \n" +
      			"    AFTER MATCH SKIP TO NEXT ROW \n" +
      			"    PATTERN (this_step next_step)\n" +
      			"    DEFINE this_step AS TRUE,\n" +
      			"    next_step AS TRUE\n" +
      			")");
      
      		env.executeSql("SELECT * FROM foo");
      

      fails with:

      java.lang.AssertionError
      	at org.apache.calcite.sql.SqlMatchRecognize$SqlMatchRecognizeOperator.createCall(SqlMatchRecognize.java:274)
      	at org.apache.calcite.sql.util.SqlShuttle$CallCopyingArgHandler.result(SqlShuttle.java:117)
      	at org.apache.calcite.sql.util.SqlShuttle$CallCopyingArgHandler.result(SqlShuttle.java:101)
      	at org.apache.calcite.sql.util.SqlShuttle.visit(SqlShuttle.java:67)
      	at org.apache.flink.table.planner.utils.Expander$Expanded$1.visit(Expander.java:153)
      	at org.apache.flink.table.planner.utils.Expander$Expanded$1.visit(Expander.java:130)
      	at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139)
      	at org.apache.calcite.sql.util.SqlShuttle$CallCopyingArgHandler.visitChild(SqlShuttle.java:134)
      	at org.apache.calcite.sql.util.SqlShuttle$CallCopyingArgHandler.visitChild(SqlShuttle.java:101)
      	at org.apache.calcite.sql.SqlOperator.acceptCall(SqlOperator.java:879)
      	at org.apache.calcite.sql.SqlSelectOperator.acceptCall(SqlSelectOperator.java:133)
      	at org.apache.calcite.sql.util.SqlShuttle.visit(SqlShuttle.java:66)
      	at org.apache.flink.table.planner.utils.Expander$Expanded$1.visit(Expander.java:153)
      	at org.apache.flink.table.planner.utils.Expander$Expanded$1.visit(Expander.java:130)
      	at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139)
      	at org.apache.flink.table.planner.utils.Expander$Expanded.substitute(Expander.java:168)
      	at org.apache.flink.table.planner.operations.SqlToOperationConverter.convertViewQuery(SqlToOperationConverter.java:728)
      	at org.apache.flink.table.planner.operations.SqlToOperationConverter.convertCreateView(SqlToOperationConverter.java:699)
      	at org.apache.flink.table.planner.operations.SqlToOperationConverter.convert(SqlToOperationConverter.java:226)
      	at org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:78)
      	at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeSql(TableEnvironmentImpl.java:658)
      	at org.apache.flink.table.planner.runtime.stream.table.FunctionITCase.test(FunctionITCase.java:165)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
      	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
      	at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
      	at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
      	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
      	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
      	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
      	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
      	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
      	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
      

      Attachments

        Issue Links

          Activity

            People

              dwysakowicz Dawid Wysakowicz
              dwysakowicz Dawid Wysakowicz
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: