atharvrastogi1411 opened a new pull request, #5402:
URL: https://github.com/apache/calcite/pull/5402

   ## Summary
   
   Fixes [CALCITE-7927](https://issues.apache.org/jira/browse/CALCITE-7927).
   
   Extend the dynamic-parameter protection introduced by CALCITE-6346 to both 
nested-cast elimination paths in `RexSimplify.simplifyCast`: removing both 
casts and removing only the inner cast. Neither shortcut should discard a cast 
based solely on a dynamic parameter's declared type.
   
   For example, the JDBC adapter currently simplifies:
   
   ```sql
   CAST(CAST(? AS VARCHAR(1)) AS CHAR(1))
   ```
   
   to:
   
   ```sql
   CAST(? AS CHAR(1))
   ```
   
   With `"longer-value"` bound using `setString`, the original expression 
returns `"l"` in HSQLDB, but the simplified JDBC query returns 
`"longer-value"`. Preserving the nested casts restores the correct result. 
CALCITE-7118's Java executor parameter conversion does not protect JDBC 
pushdown.
   
   ## Tests
   
   - Add a Rex simplification regression covering both nested-cast elimination 
paths.
   - Add an HSQLDB JDBC adapter regression checking the actual truncated result 
and the pushed-down SQL.
   - Confirm both new tests fail before the production fix.
   - Update the existing `testDynamicParameterDoubleCast` golden to retain its 
inner `INTEGER` cast.
   
   Validation passed: 1,050 tests discovered, 0 failures, 4 skipped; both core 
Checkstyle tasks passed.
   
   ```sh
   ./gradlew --no-daemon :core:test \
     --tests org.apache.calcite.rex.RexProgramTest \
     --tests org.apache.calcite.rex.RexLosslessCastTest \
     --tests org.apache.calcite.rex.RexExecutorTest \
     --tests org.apache.calcite.test.JdbcAdapterTest \
     --tests org.apache.calcite.test.SqlToRelConverterTest \
     :core:checkstyleMain :core:checkstyleTest
   ```
   
   The full multi-module build was not run.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [PR] [CALCITE-7927] Preserve ne... atharvrastogi1411 (via GitHub) via commits

Reply via email to