calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Soma Mondal <mail.mondal.s...@gmail.com>
Subject Re: Preserving CAST of STRING operands in comparison operator
Date Mon, 26 Aug 2019 14:49:05 GMT
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 <mail.mondal.soma@gmail.com>
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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message