You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "dang-stripe (via GitHub)" <gi...@apache.org> on 2025/03/04 21:21:50 UTC
Re: [I] `ArrayIndexOutOfBoundsException` error for multi-stage query [pinot]
dang-stripe commented on issue #15121:
URL: https://github.com/apache/pinot/issues/15121#issuecomment-2698949621
@Jackie-Jiang I've narrowed this down to when we're using a window function and sum/case/when or count/filter. It does not happen without the window function. Here's an example query.
```
WITH "windowed_data" AS (
SELECT
"user_id",
"value",
SUM("value") OVER (
PARTITION BY "user_id"
ORDER BY "timestamp"
) AS "running_total",
"date" AS "event_date"
FROM "events_table"
WHERE "account_id" = 'acct_sample123'
LIMIT 500
)
SELECT
"event_date",
SUM(CASE WHEN "value" < 0 AND "running_total" = 0 THEN 1 ELSE 0 END) AS "count_type_a"
FROM "windowed_data"
GROUP BY 1
LIMIT 10
```
The explain plan looks like this:
```
LogicalSort(offset=[0], fetch=[10])
PinotLogicalSortExchange(distribution=[hash], collation=[[]], isSortOnSender=[false], isSortOnReceiver=[false])
LogicalSort(fetch=[10])
PinotLogicalAggregate(group=[{0}], agg#0=[COUNT($1)])
PinotLogicalExchange(distribution=[hash[0]])
PinotLogicalAggregate(group=[{0}], agg#0=[COUNT() FILTER $1])
LogicalProject(event_date=[$2], $f2=[AND(<($0, 0), =($1, 0))])
LogicalSort(offset=[0], fetch=[500])
PinotLogicalSortExchange(distribution=[hash], collation=[[]], isSortOnSender=[false], isSortOnReceiver=[false])
LogicalSort(fetch=[500])
LogicalProject(value=[$3], running_total=[$4], event_date=[$2])
LogicalWindow(window#0=[window(partition {0} order by [1] aggs [SUM($3)])])
PinotLogicalSortExchange(distribution=[hash[0]], collation=[[1]], isSortOnSender=[false], isSortOnReceiver=[true])
LogicalProject(user_id=[$6], timestamp=[$8], date=[$9], value=[$12])
LogicalFilter(condition=[=($3, _UTF-8'acct_sample123')])
LogicalTableScan(table=[[default, events_table]])
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org