You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Pavel Pereslegin (Jira)" <ji...@apache.org> on 2023/04/28 12:48:00 UTC
[jira] [Resolved] (IGNITE-16906) SQL Calcite. ClassCastException when deserialising TIMESTAMP literal
[ https://issues.apache.org/jira/browse/IGNITE-16906?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pavel Pereslegin resolved IGNITE-16906.
---------------------------------------
Resolution: Cannot Reproduce
> 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)