You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/07/08 08:04:42 UTC

[GitHub] [calcite] danny0405 commented on issue #1299: [CALCITE-3100] cast(? as DATE) won't work with PreparedStatement

danny0405 commented on issue #1299: [CALCITE-3100] cast(? as DATE) won't work with PreparedStatement
URL: https://github.com/apache/calcite/pull/1299#issuecomment-509122864
 
 
   @jinxing64 
   >SqlValidator infers the "type" of SqlDynamicParam by the "type" of CAST. And during the optimization, such a CAST will be regarded as redundant and get simplified/peeled.
   
   `SqlValidatorImpl` did use the operand0 type of the `SqlDynamicParam` directly, and it's the sql-to-rel conversion that create a `RexDynamicParam` with the correct type (not the optimization phrase).
   
   We can see that the `RexDynamicParam` has the correct data type, but the java type factory has an `int` type for sql `DATE` and `TIMESTAMP` type. [3] 
   
   @yuqi1129 Although cast to `string.class` type first can solve this problem, i still think the intermediate type should depend on what the type the JDBC `DataContext` returns. 
   
   [1] https://github.com/apache/calcite/blob/046f9f4e2e3c779e4e2e61946d67a0dc124f7f72/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java#L107
   [2] https://github.com/apache/calcite/blob/046f9f4e2e3c779e4e2e61946d67a0dc124f7f72/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java#L3006
   [3] https://github.com/apache/calcite/blob/046f9f4e2e3c779e4e2e61946d67a0dc124f7f72/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java#L179
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services