[
https://issues.apache.org/jira/browse/IGNITE-22785?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Maksim Zhuravkov updated IGNITE-22785:
--------------------------------------
Summary: Sql. Partition pruning. Insert. ArrayOutOfBoundsError when value
of key column overflows (was: Sql. Partition pruning. Insert.
ArrayOutOfBoundsError when value of key column overflows.)
> Sql. Partition pruning. Insert. ArrayOutOfBoundsError when value of key
> column overflows
> ----------------------------------------------------------------------------------------
>
> Key: IGNITE-22785
> URL: https://issues.apache.org/jira/browse/IGNITE-22785
> Project: Ignite
> Issue Type: Improvement
> Components: sql
> Reporter: Maksim Zhuravkov
> 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}
> *no* further _formatting_ is done here
> {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}
> Possible culprit:
> {noformat}
> ref = (RexLocalRef) projections.get(mapping.getSourceOpt(key)); <<<--- this
> line
> {noformat}
> If a primary key column is wrapped into a cast, then
> `mapping.getSourceOpt(key)` returns -1;
> *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)