[ https://issues.apache.org/jira/browse/IGNITE-22785?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Evgeny Stanilovsky reassigned IGNITE-22785: ------------------------------------------- Assignee: Evgeny Stanilovsky > Sql. Partition pruning. Insert. ArrayIndexOutOfBoundsException when key > column literal overflows > ------------------------------------------------------------------------------------------------ > > Key: IGNITE-22785 > URL: https://issues.apache.org/jira/browse/IGNITE-22785 > Project: Ignite > Issue Type: Improvement > Components: sql > Reporter: Maksim Zhuravkov > Assignee: Evgeny Stanilovsky > Priority: Major > Labels: ignite-3 > > Reproducer: > 1. Disable KeyValueModifyPlan. > 2. Run the following test case: > {noformat} > @Test > public void dmlOps() { > sql("CREATE TABLE test (id INT PRIMARY KEY, val INT);"); > sql(String.format("INSERT INTO test VALUES(%d, 1)", Long.MAX_VALUE)); > } > {noformat} > *Expected error*: SMALLINT out of range > *Actual error*: > {noformat} > Caused by: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds > for length 2 > at > com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:77) > at > org.apache.ignite.internal.sql.engine.prepare.pruning.PartitionPruningMetadataExtractor.extractFromValues(PartitionPruningMetadataExtractor.java:298) > at > org.apache.ignite.internal.sql.engine.prepare.pruning.PartitionPruningMetadataExtractor.visit(PartitionPruningMetadataExtractor.java:250) > at > org.apache.ignite.internal.sql.engine.prepare.pruning.PartitionPruningMetadataExtractor.visit(PartitionPruningMetadataExtractor.java:104) > at > org.apache.ignite.internal.sql.engine.rel.IgniteTableModify.accept(IgniteTableModify.java:145) > at > org.apache.ignite.internal.sql.engine.prepare.IgniteRelShuttle.visit(IgniteRelShuttle.java:250) > at > org.apache.ignite.internal.sql.engine.prepare.IgniteRelShuttle.visitChild(IgniteRelShuttle.java:270) > at > org.apache.ignite.internal.sql.engine.prepare.IgniteRelShuttle.processNode(IgniteRelShuttle.java:260) > at > org.apache.ignite.internal.sql.engine.prepare.IgniteRelShuttle.visit(IgniteRelShuttle.java:64) > at > org.apache.ignite.internal.sql.engine.prepare.IgniteRelShuttle.visit(IgniteRelShuttle.java:60) > at > org.apache.ignite.internal.sql.engine.rel.IgniteSender.accept(IgniteSender.java:108) > at > org.apache.ignite.internal.sql.engine.prepare.pruning.PartitionPruningMetadataExtractor.go(PartitionPruningMetadataExtractor.java:119) > at > org.apache.ignite.internal.sql.engine.prepare.pruning.PartitionPrunerImpl.apply(PartitionPrunerImpl.java:67) > at > org.apache.ignite.internal.sql.engine.exec.mapping.MappingServiceImpl.applyPartitionPruning(MappingServiceImpl.java:284) > at > org.apache.ignite.internal.sql.engine.exec.mapping.MappingServiceImpl.lambda$map0$3(MappingServiceImpl.java:161) > at > java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:680) > at > java.base/java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:658) > at > java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2094) > at > org.apache.ignite.internal.sql.engine.exec.mapping.MappingServiceImpl.map0(MappingServiceImpl.java:161) > at > org.apache.ignite.internal.sql.engine.exec.mapping.MappingServiceImpl.map(MappingServiceImpl.java:108) > at > org.apache.ignite.internal.sql.engine.exec.ExecutionServiceImpl$DistributedQueryManager.execute(ExecutionServiceImpl.java:990) > at > org.apache.ignite.internal.sql.engine.exec.ExecutionServiceImpl.executeQuery(ExecutionServiceImpl.java:323) > at > org.apache.ignite.internal.sql.engine.exec.ExecutionServiceImpl.executePlan(ExecutionServiceImpl.java:382) > at > org.apache.ignite.internal.sql.engine.SqlQueryProcessor.executePlan(SqlQueryProcessor.java:640) > {noformat} > *Plan*: > {noformat} > Project(ROWCOUNT=[CAST($0):BIGINT NOT NULL]): rowcount = 1.0, cumulative cost > = IgniteCost [rowCount=8.0, cpu=11.0, memory=7.0, io=2.0, network=6.0], id = > 60 > ColocatedHashAggregate(group=[{}], agg#0=[$SUM0($0)]): rowcount = 1.0, > cumulative cost = IgniteCost [rowCount=6.0, cpu=9.0, memory=6.0, io=1.0, > network=5.0], id = 59 > Exchange(distribution=[single]): rowcount = 1.0, cumulative cost = > IgniteCost [rowCount=5.0, cpu=8.0, memory=1.0, io=1.0, network=5.0], id = 58 > TableModify(table=[[PUBLIC, TEST]], operation=[INSERT], > flattened=[false], tableId=[9]): rowcount = 1.0, cumulative cost = IgniteCost > [rowCount=4.0, cpu=7.0, memory=1.0, io=1.0, network=1.0], id = 57 > TrimExchange(distribution=[affinity[tableId=9, zoneId=9][0]]): > rowcount = 1.0, cumulative cost = IgniteCost [rowCount=3.0, cpu=6.0, > memory=0.0, io=0.0, network=0.0], id = 56 > Project(ID=[CAST(9223372036854775807:BIGINT):INTEGER NOT NULL], > VAL=[1]): rowcount = 1.0, cumulative cost = IgniteCost [rowCount=2.0, > cpu=2.0, memory=0.0, io=0.0, network=0.0], id = 55 > Values(tuples=[[{ 0 }]]): rowcount = 1.0, cumulative cost = > IgniteCost [rowCount=1.0, cpu=1.0, memory=0.0, io=0.0, network=0.0], id = 47 > {noformat} > Replacing: > {noformat} > ref = (RexLocalRef) projections.get(mapping.getSourceOpt(key)); > {noformat} > with > {noformat} > int sourceOpt = mapping.getSourceOpt(key); > if (sourceOpt == -1) { > return; > } > ref = (RexLocalRef) projections.get(sourceOpt); > {noformat} > fixes the problem. > *Additional context*: > This query does not produce an error: > {noformat} > sql("INSERT INTO test VALUES('11111'::INT, 1)"); > {noformat} > *Plan*: > {noformat} > Project(ROWCOUNT=[CAST($0):BIGINT NOT NULL]): rowcount = 1.0, cumulative cost > = IgniteCost [rowCount=7.0, cpu=10.0, memory=7.0, io=2.0, network=6.0], id = > 38 > ColocatedHashAggregate(group=[{}], agg#0=[$SUM0($0)]): rowcount = 1.0, > cumulative cost = IgniteCost [rowCount=5.0, cpu=8.0, memory=6.0, io=1.0, > network=5.0], id = 37 > Exchange(distribution=[single]): rowcount = 1.0, cumulative cost = > IgniteCost [rowCount=4.0, cpu=7.0, memory=1.0, io=1.0, network=5.0], id = 36 > TableModify(table=[[PUBLIC, TEST]], operation=[INSERT], > flattened=[false], tableId=[9]): rowcount = 1.0, cumulative cost = IgniteCost > [rowCount=3.0, cpu=6.0, memory=1.0, io=1.0, network=1.0], id = 35 > TrimExchange(distribution=[affinity[tableId=9, zoneId=9][0]]): > rowcount = 1.0, cumulative cost = IgniteCost [rowCount=2.0, cpu=5.0, > memory=0.0, io=0.0, network=0.0], id = 34 > Values(tuples=[[{ 11111, 1 }]]): rowcount = 1.0, cumulative cost = > IgniteCost [rowCount=1.0, cpu=1.0, memory=0.0, io=0.0, network=0.0], id = 29 > {noformat} -- This message was sent by Atlassian Jira (v8.20.10#820010)