[
https://issues.apache.org/jira/browse/IGNITE-20164?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Maksim Zhuravkov updated IGNITE-20164:
--------------------------------------
Description:
RelCollation propagation does not take remapping for group keys between
MAP/REDUCE phases into account, hence causes errors in queries that are
expected to use sort-based MAP/REDUCE. Example:
{code:java}
String[] rules = {
"MapReduceHashAggregateConverterRule",
"ColocatedHashAggregateConverterRule",
"ColocatedSortAggregateConverterRule"
};
sql("CREATE TABLE testMe40 (a INTEGER, b INTEGER);");
sql("INSERT INTO testMe40 VALUES (11, 2), (12, 2), (12, 3)");
assertQuery("SELECT COUNT(a), COUNT(DISTINCT(b)) FROM testMe40")
.disableRules(rules)
.returns(3L, 2L)
.check();
{code}
Plan:
{code:java}
IgniteProject(EXPR$0=[CAST($0):BIGINT NOT NULL], EXPR$1=[$1]), id = 210
IgniteReduceSortAggregate(group=[{}], EXPR$0=[$SUM0($1)], EXPR$1=[COUNT($0)],
collation=[[]]), id = 209
IgniteMapSortAggregate(group=[{}], EXPR$0=[$SUM0($1)], EXPR$1=[COUNT($0)],
collation=[[]]), id = 208
IgniteReduceSortAggregate(group=[{1}], EXPR$0=[COUNT($0)],
collation=[[1]]), id = 207
IgniteExchange(distribution=[single]), id = 206
IgniteMapSortAggregate(group=[{1}], EXPR$0=[COUNT($0)],
collation=[[1]]), id = 205
IgniteSort(sort0=[$1], dir0=[ASC]), id = 204
IgniteTableScan(table=[[PUBLIC, TESTME40]], requiredColumns=[{1,
2}]), id = 194
{code}
Error:
{code:java}
Caused by: java.lang.ClassCastException: class java.util.ArrayList cannot be
cast to class java.lang.Comparable (java.util.ArrayList and
java.lang.Comparable are in module java.base of loader 'bootstrap')
at
org.apache.ignite.internal.sql.engine.exec.exp.ExpressionFactoryImpl.compare(ExpressionFactoryImpl.java:247)
at
org.apache.ignite.internal.sql.engine.exec.exp.ExpressionFactoryImpl.lambda$comparator$0(ExpressionFactoryImpl.java:178)
at
java.base/java.util.Map$Entry.lambda$comparingByKey$6d558cbf$1(Map.java:539)
at
java.base/java.util.PriorityQueue.siftUpUsingComparator(PriorityQueue.java:675)
at java.base/java.util.PriorityQueue.siftUp(PriorityQueue.java:652)
at java.base/java.util.PriorityQueue.offer(PriorityQueue.java:345)
at
org.apache.ignite.internal.sql.engine.exec.rel.Inbox.pushOrdered(Inbox.java:235)
at
org.apache.ignite.internal.sql.engine.exec.rel.Inbox.push(Inbox.java:188)
at
org.apache.ignite.internal.sql.engine.exec.rel.Inbox.onBatchReceived(Inbox.java:168)
at
org.apache.ignite.internal.sql.engine.exec.ExchangeServiceImpl.onMessage(ExchangeServiceImpl.java:184)
... 7 more
{code}
The query below works because position of column b does not change after MAP
phase.
{code:java}
String[] rules = {
"MapReduceHashAggregateConverterRule",
"ColocatedHashAggregateConverterRule",
"ColocatedSortAggregateConverterRule"
};
sql("CREATE TABLE testMe40 (a INTEGER, b INTEGER);");
sql("INSERT INTO testMe40 VALUES (11, 2), (12, 2), (12, 3)");
assertQuery("SELECT COUNT(a), COUNT(DISTINCT(b)) FROM testMe40")
.disableRules(rules)
.returns(3L, 2L)
.check();
{code}
Plan:
{code:java}
IgniteProject(EXPR$0=[$0], EXPR$1=[CAST($1):BIGINT NOT NULL]), id = 350
IgniteReduceSortAggregate(group=[{}], EXPR$0=[COUNT($0)], EXPR$1=[$SUM0($1)],
collation=[[]]), id = 349
IgniteMapSortAggregate(group=[{}], EXPR$0=[COUNT($0)], EXPR$1=[$SUM0($1)],
collation=[[]]), id = 348
IgniteReduceSortAggregate(group=[{0}], EXPR$1=[COUNT($1)],
collation=[[0]]), id = 347
IgniteExchange(distribution=[single]), id = 346
IgniteMapSortAggregate(group=[{0}], EXPR$1=[COUNT($1)],
collation=[[0]]), id = 345
IgniteSort(sort0=[$0], dir0=[ASC]), id = 344
IgniteTableScan(table=[[PUBLIC, TESTME40]], projects=[[$t1,
$t0]], requiredColumns=[{1, 2}]), id = 334
{code}
was:
RelCollation propagation does not take remapping for group keys between
MAP/REDUCE phases into account, hence causes errors in queries that are
expected to use sort-based MAP/REDUCE. Example:
{code:java}
String[] rules = {
"MapReduceHashAggregateConverterRule",
"ColocatedHashAggregateConverterRule",
"ColocatedSortAggregateConverterRule"
};
sql("CREATE TABLE testMe40 (a INTEGER, b INTEGER);");
sql("INSERT INTO testMe40 VALUES (11, 2), (12, 2), (12, 3)");
assertQuery("SELECT COUNT(a), COUNT(DISTINCT(b)) FROM testMe40")
.disableRules(rules)
.returns(3L, 2L)
.check();
{code}
Plan:
{code:java}
IgniteProject(EXPR$0=[CAST($0):BIGINT NOT NULL], EXPR$1=[$1]), id = 210
IgniteReduceSortAggregate(group=[{}], EXPR$0=[$SUM0($1)], EXPR$1=[COUNT($0)],
collation=[[]]), id = 209
IgniteMapSortAggregate(group=[{}], EXPR$0=[$SUM0($1)], EXPR$1=[COUNT($0)],
collation=[[]]), id = 208
IgniteReduceSortAggregate(group=[{1}], EXPR$0=[COUNT($0)],
collation=[[1]]), id = 207
IgniteExchange(distribution=[single]), id = 206
IgniteMapSortAggregate(group=[{1}], EXPR$0=[COUNT($0)],
collation=[[1]]), id = 205
IgniteSort(sort0=[$1], dir0=[ASC]), id = 204
IgniteTableScan(table=[[PUBLIC, TESTME40]], requiredColumns=[{1,
2}]), id = 194
{code}
Error:
{code:java}
Caused by: java.lang.ClassCastException: class java.util.ArrayList cannot be
cast to class java.lang.Comparable (java.util.ArrayList and
java.lang.Comparable are in module java.base of loader 'bootstrap')
at
org.apache.ignite.internal.sql.engine.exec.exp.ExpressionFactoryImpl.compare(ExpressionFactoryImpl.java:247)
at
org.apache.ignite.internal.sql.engine.exec.exp.ExpressionFactoryImpl.lambda$comparator$0(ExpressionFactoryImpl.java:178)
at
java.base/java.util.Map$Entry.lambda$comparingByKey$6d558cbf$1(Map.java:539)
at
java.base/java.util.PriorityQueue.siftUpUsingComparator(PriorityQueue.java:675)
at java.base/java.util.PriorityQueue.siftUp(PriorityQueue.java:652)
at java.base/java.util.PriorityQueue.offer(PriorityQueue.java:345)
at
org.apache.ignite.internal.sql.engine.exec.rel.Inbox.pushOrdered(Inbox.java:235)
at
org.apache.ignite.internal.sql.engine.exec.rel.Inbox.push(Inbox.java:188)
at
org.apache.ignite.internal.sql.engine.exec.rel.Inbox.onBatchReceived(Inbox.java:168)
at
org.apache.ignite.internal.sql.engine.exec.ExchangeServiceImpl.onMessage(ExchangeServiceImpl.java:184)
... 7 more
{code}
The query below works because position of column b does not change after MAP
phase.
{code:java}
String[] rules = {
"MapReduceHashAggregateConverterRule",
"ColocatedHashAggregateConverterRule",
"ColocatedSortAggregateConverterRule"
};
sql("CREATE TABLE testMe40 (a INTEGER, b INTEGER);");
sql("INSERT INTO testMe40 VALUES (11, 2), (12, 2), (12, 3)");
assertQuery("SELECT COUNT(a), COUNT(DISTINCT(b)) FROM testMe40")
.disableRules(rules)
.returns(3L, 2L)
.check();
{code}
Plan:
{code:java}
IgniteProject(EXPR$0=[$0], EXPR$1=[CAST($1):BIGINT NOT NULL]), id = 350
IgniteReduceSortAggregate(group=[{}], EXPR$0=[COUNT($0)], EXPR$1=[$SUM0($1)],
collation=[[]]), id = 349
IgniteMapSortAggregate(group=[{}], EXPR$0=[COUNT($0)], EXPR$1=[$SUM0($1)],
collation=[[]]), id = 348
IgniteReduceSortAggregate(group=[{0}], EXPR$1=[COUNT($1)],
collation=[[0]]), id = 347
IgniteExchange(distribution=[single]), id = 346
IgniteMapSortAggregate(group=[{0}], EXPR$1=[COUNT($1)],
collation=[[0]]), id = 345
IgniteSort(sort0=[$0], dir0=[ASC]), id = 344
IgniteTableScan(table=[[PUBLIC, TESTME40]], projects=[[$t1,
$t0]], requiredColumns=[{1, 2}]), id = 334
{code}
> Sql. Incorrect propagation of RelCollation trait for Sort-based Map/reduce
> aggregates.
> --------------------------------------------------------------------------------------
>
> Key: IGNITE-20164
> URL: https://issues.apache.org/jira/browse/IGNITE-20164
> Project: Ignite
> Issue Type: Bug
> Components: sql
> Affects Versions: 3.0.0-beta1
> Reporter: Maksim Zhuravkov
> Priority: Major
> Labels: ignite-3
>
> RelCollation propagation does not take remapping for group keys between
> MAP/REDUCE phases into account, hence causes errors in queries that are
> expected to use sort-based MAP/REDUCE. Example:
> {code:java}
> String[] rules = {
> "MapReduceHashAggregateConverterRule",
> "ColocatedHashAggregateConverterRule",
> "ColocatedSortAggregateConverterRule"
> };
> sql("CREATE TABLE testMe40 (a INTEGER, b INTEGER);");
> sql("INSERT INTO testMe40 VALUES (11, 2), (12, 2), (12, 3)");
> assertQuery("SELECT COUNT(a), COUNT(DISTINCT(b)) FROM testMe40")
> .disableRules(rules)
> .returns(3L, 2L)
> .check();
> {code}
> Plan:
> {code:java}
> IgniteProject(EXPR$0=[CAST($0):BIGINT NOT NULL], EXPR$1=[$1]), id = 210
> IgniteReduceSortAggregate(group=[{}], EXPR$0=[$SUM0($1)],
> EXPR$1=[COUNT($0)], collation=[[]]), id = 209
> IgniteMapSortAggregate(group=[{}], EXPR$0=[$SUM0($1)],
> EXPR$1=[COUNT($0)], collation=[[]]), id = 208
> IgniteReduceSortAggregate(group=[{1}], EXPR$0=[COUNT($0)],
> collation=[[1]]), id = 207
> IgniteExchange(distribution=[single]), id = 206
> IgniteMapSortAggregate(group=[{1}], EXPR$0=[COUNT($0)],
> collation=[[1]]), id = 205
> IgniteSort(sort0=[$1], dir0=[ASC]), id = 204
> IgniteTableScan(table=[[PUBLIC, TESTME40]],
> requiredColumns=[{1, 2}]), id = 194
> {code}
> Error:
> {code:java}
> Caused by: java.lang.ClassCastException: class java.util.ArrayList cannot be
> cast to class java.lang.Comparable (java.util.ArrayList and
> java.lang.Comparable are in module java.base of loader 'bootstrap')
> at
> org.apache.ignite.internal.sql.engine.exec.exp.ExpressionFactoryImpl.compare(ExpressionFactoryImpl.java:247)
> at
> org.apache.ignite.internal.sql.engine.exec.exp.ExpressionFactoryImpl.lambda$comparator$0(ExpressionFactoryImpl.java:178)
> at
> java.base/java.util.Map$Entry.lambda$comparingByKey$6d558cbf$1(Map.java:539)
> at
> java.base/java.util.PriorityQueue.siftUpUsingComparator(PriorityQueue.java:675)
> at java.base/java.util.PriorityQueue.siftUp(PriorityQueue.java:652)
> at java.base/java.util.PriorityQueue.offer(PriorityQueue.java:345)
> at
> org.apache.ignite.internal.sql.engine.exec.rel.Inbox.pushOrdered(Inbox.java:235)
> at
> org.apache.ignite.internal.sql.engine.exec.rel.Inbox.push(Inbox.java:188)
> at
> org.apache.ignite.internal.sql.engine.exec.rel.Inbox.onBatchReceived(Inbox.java:168)
> at
> org.apache.ignite.internal.sql.engine.exec.ExchangeServiceImpl.onMessage(ExchangeServiceImpl.java:184)
> ... 7 more
> {code}
> The query below works because position of column b does not change after MAP
> phase.
> {code:java}
> String[] rules = {
> "MapReduceHashAggregateConverterRule",
> "ColocatedHashAggregateConverterRule",
> "ColocatedSortAggregateConverterRule"
> };
> sql("CREATE TABLE testMe40 (a INTEGER, b INTEGER);");
> sql("INSERT INTO testMe40 VALUES (11, 2), (12, 2), (12, 3)");
> assertQuery("SELECT COUNT(a), COUNT(DISTINCT(b)) FROM testMe40")
> .disableRules(rules)
> .returns(3L, 2L)
> .check();
> {code}
> Plan:
> {code:java}
> IgniteProject(EXPR$0=[$0], EXPR$1=[CAST($1):BIGINT NOT NULL]), id = 350
> IgniteReduceSortAggregate(group=[{}], EXPR$0=[COUNT($0)],
> EXPR$1=[$SUM0($1)], collation=[[]]), id = 349
> IgniteMapSortAggregate(group=[{}], EXPR$0=[COUNT($0)],
> EXPR$1=[$SUM0($1)], collation=[[]]), id = 348
> IgniteReduceSortAggregate(group=[{0}], EXPR$1=[COUNT($1)],
> collation=[[0]]), id = 347
> IgniteExchange(distribution=[single]), id = 346
> IgniteMapSortAggregate(group=[{0}], EXPR$1=[COUNT($1)],
> collation=[[0]]), id = 345
> IgniteSort(sort0=[$0], dir0=[ASC]), id = 344
> IgniteTableScan(table=[[PUBLIC, TESTME40]], projects=[[$t1,
> $t0]], requiredColumns=[{1, 2}]), id = 334
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)