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

Pavel Pereslegin edited comment on IGNITE-16906 at 4/28/23 12:46 PM:
---------------------------------------------------------------------

Fixed by this 
[change|https://github.com/apache/ignite-3/pull/941/files#diff-263b5cf209a8dbda237fce379f0b49e29fda4595cc8e4895a06532b023443372R778].


was (Author: xtern):
This has been fixed by this 
[change|https://github.com/apache/ignite-3/pull/941/files#diff-263b5cf209a8dbda237fce379f0b49e29fda4595cc8e4895a06532b023443372R778].

> SQL Calcite. ClassCastException when deserialising TIMESTAMP literal
> --------------------------------------------------------------------
>
>                 Key: IGNITE-16906
>                 URL: https://issues.apache.org/jira/browse/IGNITE-16906
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>    Affects Versions: 2.13
>            Reporter: Konstantin Orlov
>            Assignee: Pavel Pereslegin
>            Priority: Major
>              Labels: calcite
>
> The problem appears to be caused by an inconsistency of RelReader and 
> RexBuilder: RelReader diserializes every integer value as a value of type 
> Integer, but the RexBuilder assumes that for TIMESTAMP literal a value of 
> type Long will be passed, and make the explicit cast:
> {code:java}
> // RexBuilder#clean(Object, RelDataType)
> case TIMESTAMP:
>   if (o instanceof TimestampString) {
>     return o;
>   } else if (o instanceof Calendar) {
>     if (!((Calendar) o).getTimeZone().equals(DateTimeUtils.UTC_ZONE)) {
>       throw new AssertionError();
>     }
>     return TimestampString.fromCalendarFields((Calendar) o);
>   } else {
>     return TimestampString.fromMillisSinceEpoch((Long) o);
>   } {code}
> Here is a stack trace:
> {noformat}
> java.lang.ClassCastException: java.lang.Integer cannot be cast to 
> java.lang.Long
>       at org.apache.calcite.rex.RexBuilder.clean(RexBuilder.java:1780)
>       at org.apache.calcite.rex.RexBuilder.makeLiteral(RexBuilder.java:1558)
>       at org.apache.calcite.rex.RexBuilder.makeLiteral(RexBuilder.java:1520)
>       at 
> org.apache.ignite.internal.processors.query.calcite.externalize.RelJson.toRex(RelJson.java:529)
>       at 
> org.apache.ignite.internal.processors.query.calcite.externalize.RelJsonReader$RelInputImpl.getExpressionList(RelJsonReader.java:248)
>       at 
> org.apache.ignite.internal.processors.query.calcite.trait.TraitUtils$1.getExpressionList(TraitUtils.java:323)
>       at 
> org.apache.ignite.internal.processors.query.calcite.rel.ProjectableFilterableTableScan.<init>(ProjectableFilterableTableScan.java:87)
>       at 
> org.apache.ignite.internal.processors.query.calcite.rel.IgniteTableScan.<init>(IgniteTableScan.java:46)
> {noformat}
> The problem could be reproduced by a simple test:
> {code}
>     // ProjectFilterScanMergePlannerTest.java
>     @Test
>     public void test() throws Exception {
>         assertPlan("SELECT 0::TIMESTAMP FROM tbl WHERE c = 0", publicSchema, 
> isInstanceOf(IgniteTableScan.class)
>             .and(scan -> scan.projects() != null)
>             .and(scan -> scan.condition() != null)
>             .and(scan -> "=($t2, 0)".equals(scan.condition().toString()))
>             .and(scan -> ImmutableBitSet.of(2).equals(scan.requiredColumns()))
>         );
>     }
> {code}



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

Reply via email to