[ 
https://issues.apache.org/jira/browse/CALCITE-4555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17723290#comment-17723290
 ] 

Sergey Nuyanzin commented on CALCITE-4555:
------------------------------------------

yeah, I also noticed that query

However further analysis shows that 
{{org.apache.calcite.rex.RexBuilder#makeZeroLiteral}} is called only from 
1. {{org.apache.calcite.rex.RexBuilder#makeCastExactToBoolean}}
2. {{org.apache.calcite.rex.RexBuilder#makeCastBooleanToExact}}
both called from {{org.apache.calcite.rex.RexBuilder#makeCas}} in case of 
boolean casting to exact number or exact number casting to boolean. This is 
what happens in the mentioned BigQuery's SQL.

3. {{org.apache.calcite.sql2rel.RelFieldTrimmer#trimChildRestore}} which is 
called from +unused+ public method 
{{org.apache.calcite.sql2rel.RelFieldTrimmer#trimFields}}

Thus there is no way to invoke this method for any query related to {{TIMESTAMP 
WITH LOCAL TIME ZONE}} since for that case 
{{org.apache.calcite.rex.RexBuilder#makeAbstractCast}} is called

> Invalid zero literal value is used for TIMESTAMP WITH LOCAL TIME ZONE type in 
> RexBuilder
> ----------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4555
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4555
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Leonard Xu
>            Priority: Major
>
>  The zero literal value for TIMESTAMP WITH LOCAL TIME ZONE type is used in 
> `org.apache.calcite.rex.RexBuilder`
> {code:java}
>     case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
>       return new TimestampString(0, 0, 0, 0, 0, 0);
>    //TimestampString(int year, int month, int day, int h, int m, int s)
> {code}
> the month and day should never be zero, I think the zero value should be 
> '1970-01-01 00:00:00'(epoch 0 second).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to