apache / apache/pinot

EXPLAIN PLAN FOR <query> breaks on simple aggregation + filters

Open
#8,008 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
6.1k
Forks
1.5k
Avg merge
1d 21h
Merged PRs (30d)
189

Description

When I run the following query (replacing $number with a numerical value):
```sql
explain plan for select count(*) from t where col1=true and col2 >= $number limit 10
```

I get results that don't show much:
```json
"rows": [
[
"BROKER_REDUCE(limit:10)",
0,
-1
],
[
0
]
]
```

The query itself produces a count successfully, however the explain plan doesn't work at all.

If I try
```sql
explain plan for select * from t where col1=true and col2 >= $number limit 10
```
it crashes and I get the exception:
```
ProcessingException(errorCode:450, message:InternalError:
java.io.IOException: Failed : HTTP error code : 500
at org.apache.pinot.controller.api.resources.PinotQueryResource.sendPostRaw(PinotQueryResource.java:305)
at org.apache.pinot.controller.api.resources.PinotQueryResource.sendRequestRaw(PinotQueryResource.java:343)
at org.apache.pinot.controller.api.resources.PinotQueryResource.getQueryResponse(PinotQueryResource.java:225)
at org.apache.pinot.controller.api.resources.PinotQueryResource.handlePostSql(PinotQueryResource.java:137))
```

cc @amrishlal since it looks like you built most of that functionality.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing both EXPLAIN PLAN queries in the issue, then inspect PinotQueryResource.java at sendPostRaw, sendRequestRaw, getQueryResponse, and handlePostSql from the stack trace. Done means the aggregation query returns a useful plan and the SELECT * variant no longer fails with an HTTP 500.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.