jinxing64 commented on issue #1299: [CALCITE-3100] cast(? as DATE) won't work with PreparedStatement URL: https://github.com/apache/calcite/pull/1299#issuecomment-508942240 hmm.. I think this CALCITE-3100 is really a good catch for the shortage when using `SqlDynamicParam` in `CAST`. The core problem is that `SqlValidator` infer 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. But this PR just fixes the casting to type of `DATE/TIME`, what about other common types? e.g. cast(String as Integer) and so on .... In my experiment, below simple query is failing ``` PreparedStatement pstmt = connection.prepareStatement("select \"name\", \"deptno\" from \"emps\" WHERE \"empid\"=cast(? as INTEGER)"); pstmt.setString(1, "100"); pstmt.execute();
---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
