apache / apache/pinot

Query 500 on `select col, count(*) from table` missing `group by` (query mistake)

Open
#7,868 3 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
Java
Stars
6.1k
Forks
1.5k
Avg merge
1d 21h
Merged PRs (30d)
189

Description

While writing some adhoc queries, I found the controller query console was throwing a 500 and I was scratching my head about the error until I realized the query was incorrect. I'm not sure if Pinot often 500s on invalid queries, or this is a corner case, but certainly making sure a helpful error is returned is better that informs the user their query is invalid.

For example, I was trying
```sql
select $segmentName, count(*)
from table
where $segmentName = 'bar'
```
Mind, the same error happened when I used actual columns rather than the virtual column.

And it was raising the following 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))
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the aggregate query without GROUP BY through the controller query console and trace the request at PinotQueryResource.java, especially the paths named in the stack trace. Determine where the invalid query becomes an HTTP 500, then verify that the same query returns a helpful invalid-query error rather than an internal failure.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.