[
https://issues.apache.org/jira/browse/CALCITE-886?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14791213#comment-14791213
]
Jinfeng Ni commented on CALCITE-886:
------------------------------------
The fix is to call validateExpr() for SqlIdentifier, since SqlIdentifier could
represent a regular SqlIdentifier, or a system function.
Add two unit testcases to cover this case.
> Calcite hits SqlValidatorException when group by clause has system functions
> ----------------------------------------------------------------------------
>
> Key: CALCITE-886
> URL: https://issues.apache.org/jira/browse/CALCITE-886
> Project: Calcite
> Issue Type: Bug
> Reporter: Jinfeng Ni
> Assignee: Jinfeng Ni
>
> The system functions are the ones that do not have parentheses, like
> CURRENT_DATE, CURRENT_TIME, CURRENT_USER, etc.
> When such functions appear in the group by clause, Calcite will hit
> SqlValidatorException, complaining the column with the function name could
> not be found in any table.
> For instance,
> {code}
> select CURRENT_USER from SCOTT.EMP GROUP BY CURRENT_USER;
> org.apache.calcite.sql.validate.SqlValidatorException <init>
> SEVERE: org.apache.calcite.sql.validate.SqlValidatorException: Column
> 'CURRENT_USER' not found in any table
> {code}
> This query runs perfectly fine.
> {code}
> select CURRENT_USER from SCOTT.EMP limit 1;
> {code}
> Looks like the sql validation logic for group by clause could not recognize
> SqlIdentifier which may represent a function w/o parentheses.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)