You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Guoliang Sun (Jira)" <ji...@apache.org> on 2023/05/19 07:00:00 UTC
[jira] [Created] (CALCITE-5713) SqlBasicCall's Deep Copy Logic Raises Rule Optimization Exception
Guoliang Sun created CALCITE-5713:
-------------------------------------
Summary: SqlBasicCall's Deep Copy Logic Raises Rule Optimization Exception
Key: CALCITE-5713
URL: https://issues.apache.org/jira/browse/CALCITE-5713
Project: Calcite
Issue Type: Bug
Components: core
Reporter: Guoliang Sun
h3. Background
In the fix for [CALCITE-4795,|https://issues.apache.org/jira/browse/CALCITE-4795] the operands in the SqlBasicCall class were changed from SqlNode[] to ImmutableNullableList. Also change the variable name to operandList, and add a new set method to modify the elements in the collection.
h3. Exception
Take the following SQL as an example
{code:sql}
SELECT { fn TRUNCATE(
{ fn QUARTER(
{ fn TIMESTAMPADD(
SQL_TSI_HOUR,
1,
{ ts '1900-01-01 00:00:00' }
) }
) },
0
) }
FROM "TDVT"."CALCS" "CALCS"
GROUP BY 1.1000000000000001
{code}
An exception is thrown when the optimization execution reaches the CoreRules.PROJECT_REDUCE_EXPRESSIONS rule: {color:#DE350B}cannot translate call QUARTER($t4){color}
h3. RootCause
The SqlBasicCall#set method uses a deep copy in order to modify immutable collections and returns a new operandList object when modified.
If the SQL contains an operation that requires a rewrite call, such as QUARTER in the above SQL, the deep copy logic will cause the operator and operandList to be different and eventually raise an exception.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)