You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Maksim Zhuravkov (Jira)" <ji...@apache.org> on 2023/08/04 07:06:00 UTC
[jira] [Created] (IGNITE-20164) Sql. Incorrect propagation of RelCollation trait for Sort-based Map/reduce aggregates.
Maksim Zhuravkov created IGNITE-20164:
-----------------------------------------
Summary: 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
Reporter: Maksim Zhuravkov
RelCollation propagation does not take remapping for group keys between MAP/REDUCE phases, hence brakes 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}
{code:java}
// Some comments here
public String getFoo()
{
return foo;
}
{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)