Date and time formats in the standard operator table
Hi, We are seeing that in many dialects, there is support for formatting dates, times and timestamps (please see THIS <https://docs.google.com/spreadsheets/d/19x0hK3LcHxhdcx-Q7j1i8jZOoxRoUJjUTp3VxeWt4Ak/edit?usp=sharing> link for information about SqlServer, MySql, Oracle, Teradata). In the current standard operator table, we don't see any operator that does such a thing. We were thinking that we should add a new standard operator which follows the formatting standard followed by SimpleDateFormat.java Can you please share your inputs regarding this? Should we go ahead and do so or do you have other thoughts regarding this? *Regards,* *Soma Mondal*
[jira] [Created] (CALCITE-3318) Preserving CAST of STRING operands in comparison operator
Soma Mondal created CALCITE-3318: Summary: Preserving CAST of STRING operands in comparison operator Key: CALCITE-3318 URL: https://issues.apache.org/jira/browse/CALCITE-3318 Project: Calcite Issue Type: Bug Components: core Affects Versions: 1.20.0 Reporter: Soma Mondal We have a REL which has this information select * from employee where employee_id = cast('12' as float); but Calcite removes the CAST from the STRING literal('12' in our case). select * from employee where employee_id = '12'; There are dialects which needs explicit casting in the above case and we need to maintain the CAST in our dialect. Calcite removes the cast in SqlImplementor's stripCastFromString() method. I'm thinking of having the dialect intercept this and decide whether or not to remove the cast. -- This message was sent by Atlassian Jira (v8.3.2#803003)
Re: Preserving CAST of STRING operands in comparison operator
Hi Julian, After some further analysis, it seems that the mandatory cast is only required in SOME cases for BigQuery. Please see attached my analysis for Hive, MySQL, Netezza and Oracle. https://drive.google.com/open?id=1GJ_VuDY7GQS-aPbWf4EKj73dYCqaRaEqPTjmXLkPW_g I'm thinking of having the dialect intercept this and check the specific conditions (specified in the sheet above) and decide whether or not to remove the cast. Regards, Soma On Mon, 26 Aug 2019 at 22:29, Julian Hyde wrote: > I might be mistaken, but disabling stripCastFromString() for some dialects > and not others doesn’t sound like it’s solving the root cause of the > problem. > > Julian > > > > On Aug 26, 2019, at 7:49 AM, Soma Mondal > wrote: > > > > Hi Julian, > > > > 2 tests failed when I made the stripCastFromString() no-op. > > > > 1. > > > > testDb2DialectSelectQueryWithGroup > > 2. > > > > testSelectQueryWithGroup > > > > Above tests pretty much do the same thing and basically strip the cast > from > > String literal something like this: > > > > Expected: > > > > SELECT COUNT(*), SUM(employee_id) > > > > FROM foodmart.reserve_employee > > > > WHERE hire_date > '2015-01-01' AND (position_title = 'SDE' OR > > position_title = 'SDM') > > > > GROUP BY store_id, position_title > > > > But with no-op we get this: > > > > SELECT COUNT(*), SUM(employee_id) > > > > FROM foodmart.reserve_employee > > > > WHERE hire_date > CAST('2015-01-01' AS TIMESTAMP(0)) AND (position_title > = > > 'SDE' OR position_title = 'SDM') > > > > GROUP BY store_id, position_title > > > > Can I go ahead and make changes where calls to stripCastFromString() will > > be skipped for specific dialects? > > > > Regards, > > > > Soma > > > > > > On Fri, 23 Aug 2019 at 16:02, Soma Mondal > > wrote: > > > >> Hello, > >> > >> We have a REL which has this information > >> select * from employee where employee_id = cast('12' as float); > >> > >> but Calcite removes the CAST from the STRING literal('12' in our case). > >> select * from employee where employee_id = '12'; > >> > >> There are dialects which needs explicit casting in the above case and we > >> need to maintain the CAST in our dialect. > >> Calcite removes the cast in SqlImplementor's stripCastFromString() > >> method. I would like to understand why Calcite removes the CAST and > shall > >> we go ahead and make the changes in Calcite to maintain the CAST. > >> > >> Thanks & Regards, > >> Soma Mondal > >> > >
Re: Preserving CAST of STRING operands in comparison operator
Hi Julian, 2 tests failed when I made the stripCastFromString() no-op. 1. testDb2DialectSelectQueryWithGroup 2. testSelectQueryWithGroup Above tests pretty much do the same thing and basically strip the cast from String literal something like this: Expected: SELECT COUNT(*), SUM(employee_id) FROM foodmart.reserve_employee WHERE hire_date > '2015-01-01' AND (position_title = 'SDE' OR position_title = 'SDM') GROUP BY store_id, position_title But with no-op we get this: SELECT COUNT(*), SUM(employee_id) FROM foodmart.reserve_employee WHERE hire_date > CAST('2015-01-01' AS TIMESTAMP(0)) AND (position_title = 'SDE' OR position_title = 'SDM') GROUP BY store_id, position_title Can I go ahead and make changes where calls to stripCastFromString() will be skipped for specific dialects? Regards, Soma On Fri, 23 Aug 2019 at 16:02, Soma Mondal wrote: > Hello, > > We have a REL which has this information > select * from employee where employee_id = cast('12' as float); > > but Calcite removes the CAST from the STRING literal('12' in our case). > select * from employee where employee_id = '12'; > > There are dialects which needs explicit casting in the above case and we > need to maintain the CAST in our dialect. > Calcite removes the cast in SqlImplementor's stripCastFromString() > method. I would like to understand why Calcite removes the CAST and shall > we go ahead and make the changes in Calcite to maintain the CAST. > > Thanks & Regards, > Soma Mondal >
Preserving CAST of STRING operands in comparison operator
Hello, We have a REL which has this information select * from employee where employee_id = cast('12' as float); but Calcite removes the CAST from the STRING literal('12' in our case). select * from employee where employee_id = '12'; There are dialects which needs explicit casting in the above case and we need to maintain the CAST in our dialect. Calcite removes the cast in SqlImplementor's stripCastFromString() method. I would like to understand why Calcite removes the CAST and shall we go ahead and make the changes in Calcite to maintain the CAST. Thanks & Regards, Soma Mondal