osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jira] [Created] (FLINK-10197) flink CEP error when use sql


sean.miao created FLINK-10197:
---------------------------------

             Summary: flink CEP error when use sql
                 Key: FLINK-10197
                 URL: https://issues.apache.org/jira/browse/FLINK-10197
             Project: Flink
          Issue Type: Bug
          Components: CEP
    Affects Versions: 1.6.0
            Reporter: sean.miao


When I used sql to write the flink cep task, I encountered some problems. However, calcite-1.16 supports the use of match_recognize to write cep.

my code :
{code:java}
// set up execution environment
      ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
      BatchTableEnvironment tEnv = TableEnvironment.getTableEnvironment(env);


      DataSet<WC> input = env.fromElements(
         new WC("1", 1),
         new WC("2", 2),
         new WC("1", 3),
         new WC("2", 3),
         new WC("2", 2),
         new WC("1", 1));

      // register the DataSet as table "WordCount"
      tEnv.registerDataSet("t", input, "word, id");
      final String sql = "select * \n"
            + "  from t match_recognize \n"
            + "  (\n"
            + "       measures STRT.word as  start_word ,"
            + "    FINAL LAST(A.id) as A_id \n"
            + "    pattern (STRT A+) \n"
            + "    define \n"
            + "      A AS A.word = '1' \n"
            + "  ) mr";
//     run a SQL query on the Table and retrieve the result as a new Table
//    Table table = tEnv.sqlQuery(
//       "SELECT word, SUM(frequency) as frequency FROM WordCount GROUP BY word");
//    tEnv.sqlUpdate(sql);
      tEnv.sqlQuery(sql);
{code}
ERROR:
{code:java}
Exception in thread "main" org.apache.flink.table.api.ValidationException: SQL validation failed. From line 0, column 0 to line 7, column 17: No match found for function signature PREV(<CHARACTER>, <NUMERIC>)
at org.apache.flink.table.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:91)
at org.apache.flink.table.api.TableEnvironment.sqlQuery(TableEnvironment.scala:652)
at TableSQL.WordCountSQL.main(WordCountSQL.java:71)
Caused by: org.apache.calcite.runtime.CalciteContextException: From line 0, column 0 to line 7, column 17: No match found for function signature PREV(<CHARACTER>, <NUMERIC>)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:803)
at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:788)
at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4706)
at org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1690)
at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:278)
at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223)
at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5432)
at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5419)
at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138)
at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1606)
at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1591)
at org.apache.calcite.sql.type.InferTypes$1.inferOperandTypes(InferTypes.java:51)
at org.apache.calcite.sql.validate.SqlValidatorImpl.inferUnknownTypes(SqlValidatorImpl.java:1777)
at org.apache.calcite.sql.validate.SqlValidatorImpl.inferUnknownTypes(SqlValidatorImpl.java:1783)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateDefinitions(SqlValidatorImpl.java:5030)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateMatchRecognize(SqlValidatorImpl.java:4903)
at org.apache.calcite.sql.validate.MatchRecognizeNamespace.validateImpl(MatchRecognizeNamespace.java:38)
at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:947)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:928)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:2975)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:2960)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3219)
at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:947)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:928)
at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:226)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:903)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:613)
at org.apache.flink.table.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:87)
... 2 more
Caused by: org.apache.calcite.sql.validate.SqlValidatorException: No match found for function signature PREV(<CHARACTER>, <NUMERIC>)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:572)
... 33 more
{code}
 

 

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)