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

Can not access inner/nested objects in MATCH_RECOGNIZE DEFINE clause and in Aggregate function

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • 1.17.1
    • None
    • Library / CEP
    • None
    • Implemented everything in java maven project on a Windows 11

    • Important

    Description

      Note: we are implementing everything in java.

      example event

       

       

      {
        "config": "conf1",
        "id": 1,
        "action": "login",
        "size": 10,
        "message": {
          "action": "login",
          "size": 10,
          "event": {
             "action": "login", "size": 10,
             "event": {
          }
        }
      }

      we are tried to run query, it does not works and gives bellow exception

      SELECT * FROM Log
      MATCH_RECOGNIZE (
        PARTITION BY config
        ORDER BY time_ltz
        MEASURES
          A.id AS aID,
          COUNT(B.id) AS cnt
        AFTER MATCH SKIP PAST LAST ROW
        PATTERN (A B+ C)
        DEFINE
          A AS A.message.event.action = 'login'
          B AS B.message.event.action = 'data' AND SUM(B.message.event.size) >= 20"
      );

       

      Exception in thread "main" org.apache.flink.table.api.ValidationException: SQL validation failed. From line 11, column 22 to line 11, column 26: Table 'event' not found
          at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:187)
          at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:113)
          at org.apache.flink.table.planner.operations.SqlToOperationConverter.convert(SqlToOperationConverter.java:281)
          at org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:106)
          at org.apache.flink.table.api.internal.TableEnvironmentImpl.sqlQuery(TableEnvironmentImpl.java:738)
          at org.abs.security.StaticRuleEvaluator.main(StaticRuleEvaluator.java:151)
      Caused by: org.apache.calcite.runtime.CalciteContextException: From line 11, column 22 to line 11, column 26: Table 'event' not found
          at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
          at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:505)
          at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:932)
          at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:917)
          at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5163)
          at org.apache.calcite.sql.validate.DelegatingScope.fullyQualify(DelegatingScope.java:344)  

      The problem here is that if I try to run the same query replacing A.message.event.action with A.message.action without Aggregate function it works with Aggregate function it does not works and if I replace A.message.event.action with A.action with Aggregate function it works fine.

       

      without Aggregate function:

      • A.action
      • A.message.action
      • A.message.event.action

      with Aggregate function:

      • A.action
      • A.message.action
      • A.message.event.action

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            krutikgadhiya Krutik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: