You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2019/03/08 18:23:00 UTC

[jira] [Resolved] (CALCITE-2674) SqlIdentifier same name with built-in function but with escape character should be still resolved as an identifier

     [ https://issues.apache.org/jira/browse/CALCITE-2674?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Hyde resolved CALCITE-2674.
----------------------------------
    Resolution: Fixed

Fixed in https://github.com/apache/calcite/commit/870d5f48de16d44e44a09891018ba2c138980f68. Thanks for the PR, [~danny0405], and sorry I took so long to review!

> SqlIdentifier same name with built-in function but with escape character should be still resolved as an identifier
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2674
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2674
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.18.0
>            Reporter: Danny Chan
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.19.0
>
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> Now If user defines table as schema below:
> {code:java}
> create table tt(
> `current_time` int,
> b int);
> {code}
> Then start a query: 
> {code:java}
> select `current_time` from tt;
> {code}
> Calcite parser will parse the *current_time* as a normal *SqlIdentifier*, then the SqlValidator will recognize it as a builtin function with below code snippet:
> {code:java}
> public static SqlCall makeCall(
>     SqlOperatorTable opTab,
>     SqlIdentifier id) {
>   if (id.names.size() == 1) {
>     final List<SqlOperator> list = new ArrayList<>();
>     opTab.lookupOperatorOverloads(id, null, SqlSyntax.FUNCTION, list);
>     for (SqlOperator operator : list) {
>       if (operator.getSyntax() == SqlSyntax.FUNCTION_ID) {
>         // Even though this looks like an identifier, it is a
>         // actually a call to a function. Construct a fake
>         // call to this function, so we can use the regular
>         // operator validation.
>         return new SqlBasicCall(
>             operator,
>             SqlNode.EMPTY_ARRAY,
>             id.getParserPosition(),
>             true,
>             null);
>       }
>     }
>   }
>   return null;
> }{code}
> While i tried MYSQL and such query can work properly, so is this a bug ?
> Cause if the matched function's return type is same with the column, then the query will output wrong results.
>  



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