[ 
https://issues.apache.org/jira/browse/CALCITE-2746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16724315#comment-16724315
 ] 

Julian Hyde commented on CALCITE-2746:
--------------------------------------

That's not a user error, so the real problem is that we haven't implemented 
PARTITION BY based on expressions. We should; it's not difficult; we just need 
to generate an extra column (using a Project) when we do SQL-to-RelNode 
conversion.

Can you please check whether expressions work in all of the other sub-clauses 
of MATCH_RECOGNIZE (e.g. ORDER BY), and add test cases to match.iq? It would 
make sense to do them all at the same time.

> Cryptic exception when expression used in PARTITION BY clause in 
> MATCH_RECOGNIZE
> --------------------------------------------------------------------------------
>
>                 Key: CALCITE-2746
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2746
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Dawid Wysakowicz
>            Assignee: Julian Hyde
>            Priority: Major
>              Labels: match
>
> Query:
> {code}
> SELECT *
> FROM MyTable
> MATCH_RECOGNIZE (
>   PARTITION BY (id + 2)
>   ORDER BY proctime
>   MEASURES
>     A.id AS id
>   PATTERN (A)
>   DEFINE
>     A AS name = 'a'
> ) AS T
> {code}
> results in exception:
> {code}
> Caused by: java.lang.ClassCastException: org.apache.calcite.sql.SqlBasicCall 
> cannot be cast to org.apache.calcite.sql.SqlIdentifier
>       at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateMatchRecognize(SqlValidatorImpl.java:4885)
>       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:972)
>       at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:948)
> {code}
> I suggest improving it to give a proper hint that only input reference is 
> supported.



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

Reply via email to