[ https://issues.apache.org/jira/browse/CALCITE-5713?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ASF GitHub Bot updated CALCITE-5713: ------------------------------------ Labels: pull-request-available (was: ) > 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 > Priority: Major > Labels: pull-request-available > > 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)