While working on a Drill plugin, Calcite unparsed a JdbcRel node and
produced the following PostgreSQL query
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)"
The query fails due to a parsing exception, the reason is that the *STRPOS*
function name is quoted using double quotes as shown in bold. I tried the
method 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.
So is this a bug ? Has it possible been affecting Calcite through all these
releases or did I miss anything ?
Thanks,
Gelbana