espertechinc / esper

Esper Complex Event Processing, Streaming SQL and Event Series Analysis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

match_recognize converts known schema type to mapped type

icholy opened this issue · comments

The a.value expression cannot be resolved:

create schema EventA ( value string );

-- Failed to resolve property 'a.value' (property 'a' is a mapped property and requires keyed access)
select a.value
from EventA match_recognize(
  measures a as a
  pattern (a)
);

Using mapped property access resolves the compiler error, but loses type information.

select a("value")
from EventA match_recognize(
  measures a as a
  pattern (a)
);

Exception:

Exception in thread "main" com.espertech.esper.compiler.client.EPCompileException: Failed to validate select-clause expression 'a.value': Failed to resolve property 'a.value' (property 'a' is a mapped property and requires keyed access) [select a.value from EventA match_recognize(   measures a as a   pattern (a) )]
      at com.espertech.esper.compiler.internal.util.CompilerHelperModuleProvider.compileToBytes(CompilerHelperModuleProvider.java:152)
      at com.espertech.esper.compiler.internal.util.CompilerHelperModuleProvider.compile(CompilerHelperModuleProvider.java:85)
      at com.espertech.esper.compiler.internal.util.EPCompilerImpl.compile(EPCompilerImpl.java:166)
      at com.accipiterradar.server.CompiledDefinition.<init>(CompiledDefinition.java:29)
      at com.accipiterradar.server.EventServer.main(EventServer.java:61)
    Caused by: com.espertech.esper.compiler.client.EPCompileExceptionItem: Failed to validate select-clause expression 'a.value': Failed to resolve property 'a.value' (property 'a' is a mapped property and requires keyed access)
      at com.espertech.esper.compiler.internal.util.CompilerHelperModuleProvider.compileToBytes(CompilerHelperModuleProvider.java:127)
      ... 4 more
    Caused by: com.espertech.esper.common.internal.compile.stage2.StatementSpecCompileException: Failed to validate select-clause expression 'a.value': Failed to resolve property 'a.value' (property 'a' is a mapped property and requires keyed access)
      at com.espertech.esper.compiler.internal.util.CompilerHelperStatementProvider.compileItem(CompilerHelperStatementProvider.java:294)
      at com.espertech.esper.compiler.internal.util.CompilerHelperModuleProvider.compileToBytes(CompilerHelperModuleProvider.java:112)
      ... 4 more
    Caused by: com.espertech.esper.common.internal.epl.expression.core.ExprValidationException: Failed to validate select-clause expression 'a.value': Failed to resolve property 'a.value' (property 'a' is a mapped property and requires keyed access)
      at com.espertech.esper.common.internal.epl.expression.core.ExprNodeUtilityValidate.makeValidationExWExpression(ExprNodeUtilityValidate.java:184)
      at com.espertech.esper.common.internal.epl.expression.core.ExprNodeUtilityValidate.getValidatedSubtree(ExprNodeUtilityValidate.java:171)
      at com.espertech.esper.common.internal.epl.resultset.core.ResultSetProcessorFactoryFactory.validateSelectAssignColNames(ResultSetProcessorFactoryFactory.java:903)
      at com.espertech.esper.common.internal.epl.resultset.core.ResultSetProcessorFactoryFactory.getProcessorPrototype(ResultSetProcessorFactoryFactory.java:161)
      at com.espertech.esper.common.internal.context.aifactory.select.StmtForgeMethodSelectUtil.make(StmtForgeMethodSelectUtil.java:293)
      at com.espertech.esper.common.internal.context.aifactory.select.StmtForgeMethodSelect.make(StmtForgeMethodSelect.java:28)
      at com.espertech.esper.compiler.internal.util.CompilerHelperStatementProvider.compileItem(CompilerHelperStatementProvider.java:225)
      ... 5 more
    Caused by: com.espertech.esper.common.internal.epl.expression.core.ExprValidationPropertyException: Failed to resolve property 'a.value' (property 'a' is a mapped property and requires keyed access)
      at com.espertech.esper.common.internal.epl.expression.core.ExprIdentNodeUtil.getTypeFromStream(ExprIdentNodeUtil.java:112)
      at com.espertech.esper.common.internal.epl.expression.core.ExprIdentNodeImpl.validate(ExprIdentNodeImpl.java:200)
      at com.espertech.esper.common.internal.epl.expression.core.ExprNodeUtilityValidate.getValidatedSubtreeInternal(ExprNodeUtilityValidate.java:297)
      at com.espertech.esper.common.internal.epl.expression.core.ExprNodeUtilityValidate.getValidatedSubtree(ExprNodeUtilityValidate.java:156)
      ... 10 more

Measures returns a map, here a Map with a column "a" that contains the Map of the event. I.e. it returns the underlying event object when the measures clause specifies the variable. You could probably use @eventbean here too.