[ https://issues.apache.org/jira/browse/IGNITE-16906 ]
Pavel Pereslegin deleted comment on IGNITE-16906: ------------------------------------------- was (Author: xtern): Was 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)