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

Dawid Wysakowicz commented on CALCITE-2746:
-------------------------------------------

What we would also have to solve for {{PARTITION BY}} is naming the partition 
keys, as they are returned as part of result. So we would need to support 
expressions like: {{PARTITION BY (id + 1) AS derivedId}}.

If you think it makes more sense to support expressions in {{PARTITION BY}} 
feel free to change the scope of this issue.

> 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