You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Muhammad Gelbana (JIRA)" <ji...@apache.org> on 2017/08/04 12:20:00 UTC

[jira] [Created] (CALCITE-1926) Function names are unparsed quoted while PostgreSQL can only handle unquoted function names

Muhammad Gelbana created CALCITE-1926:
-----------------------------------------

             Summary: Function names are unparsed quoted while PostgreSQL can only handle unquoted function names
                 Key: CALCITE-1926
                 URL: https://issues.apache.org/jira/browse/CALCITE-1926
             Project: Calcite
          Issue Type: Bug
          Components: jdbc-adapter
    Affects Versions: 1.13.0
            Reporter: Muhammad Gelbana
            Assignee: Julian Hyde


While working on a Drill plugin, Calcite unparsed a *JdbcRel* node and produced the following PostgreSQL query
{code:sql}
SELECT "TEMP( Test)( 535799381)( 0)"
FROM (SELECT "STRPOS"("str1", 'BI') = 1 AS "TEMP( Test)( 535799381)( 0)"
FROM "TestV1"."Calcs") AS "t"
GROUP BY "TEMP( Test)( 535799381)( 0)"
{code}
The query fails due to a parsing exception, the reason is that the *STRPOS* function name is quoted using double quotes. I tried the query manually without quoting the function name and it executed successfully.

I debugged through Calcite and found that the [this method|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/SqlUtil.java#L262] unparses the function name as a plain identifier which leads to the [quoting of the function name|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java?deDup474625=1#L287] if the dialect supports it.

Drill uses Calcite v1.4 but as I compared it with the master branch, I found them identical.

I haven't tried that with custom functions yet.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)