[
https://issues.apache.org/jira/browse/IGNITE-19401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17728591#comment-17728591
]
Evgeny Stanilovsky commented on IGNITE-19401:
---------------------------------------------
I spend a bit time here, PR with my decisions is attached.
1. Native calcite environment correctly process such a queries.
2. count(distinct) case is processed through "GROUPING" aggregate passed from
AGGREGATE_EXPAND_DISTINCT_AGGREGATES rule.
3. as i can observe there are 2 difference between calcite and ignite
processing of such a queries: different Aggregate#groupSet, groupSets and
trouble in correctly "GROUPING" implementation (check PR, there are link for
calcite description and runtime implementation, but they not clear).
seems need additional investigation here.
> Sql. ArrayIndexOutOfBoundsException for ANY/ALL with subselect
> --------------------------------------------------------------
>
> Key: IGNITE-19401
> URL: https://issues.apache.org/jira/browse/IGNITE-19401
> Project: Ignite
> Issue Type: Improvement
> Components: sql
> Affects Versions: 3.0.0-beta1
> Reporter: Yury Gerzhedovich
> Priority: Major
> Labels: calcite2-required, calcite3-required, ignite-3
> Time Spent: 10m
> Remaining Estimate: 0h
>
> For SqlLogicTest sql/subquery/any_all/test_correlated_any_all.test the
> following query fails with ArrayIndexOutOfBoundsException:
> {code:java}
> SELECT i=ALL(SELECT i FROM integers WHERE i<>i1.i) FROM integers i1 ORDER BY
> i;
> SELECT i FROM integers i1 WHERE i<>ANY(SELECT i FROM integers WHERE i=i1.i)
> ORDER BY i;
> SELECT i=ALL(SELECT i FROM integers WHERE i=i1.i) FROM integers i1 ORDER BY i;
> SELECT i<>ANY(SELECT i FROM integers WHERE i=i1.i) FROM integers i1 ORDER BY
> i;
> SELECT i=ALL(SELECT i FROM integers WHERE i<>i1.i) FROM integers i1 ORDER BY
> i;
> SELECT i=ALL(SELECT i FROM integers WHERE i=i1.i OR i IS NULL) FROM integers
> i1 ORDER BY i;
> {code}
>
> {noformat}
> Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds
> for length 0
> at
> org.apache.ignite.internal.sql.engine.exec.exp.agg.Accumulators$DistinctAccumulator.add(Accumulators.java:885)
> at
> org.apache.ignite.internal.sql.engine.exec.exp.agg.AccumulatorsFactory$AccumulatorWrapperImpl.add(AccumulatorsFactory.java:302)
> at
> org.apache.ignite.internal.sql.engine.exec.rel.HashAggregateNode$Grouping.addOnMapper(HashAggregateNode.java:294)
> at
> org.apache.ignite.internal.sql.engine.exec.rel.HashAggregateNode$Grouping.add(HashAggregateNode.java:261)
> at
> org.apache.ignite.internal.sql.engine.exec.rel.HashAggregateNode.push(HashAggregateNode.java:127)
> at
> org.apache.ignite.internal.sql.engine.exec.rel.Inbox.pushUnordered(Inbox.java:302)
> at
> org.apache.ignite.internal.sql.engine.exec.rel.Inbox.push(Inbox.java:190)
> 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:148){noformat}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)