Hi, It appears that we can only add those fields i...
# troubleshooting
k
Hi, It appears that we can only add those fields in order by which are part of the select statement. Any leads here? Query: SELECT appName FROM requests WHERE request_ts >= '1628380800000' AND request_ts <= '1628726400000' AND testRequest = 'false' GROUP BY appName ORDER BY requestDate ASC Error: [ { "errorCode": 700, "message": "QueryValidationError\njava.lang.UnsupportedOperationException ORDER By should be only on some/all of the columns passed as arguments to DISTINCT\n\tat org.apache.pinot.broker.requesthandler.BaseBrokerRequestHandler.validateRequest(BaseBrokerRequestHandler.java:1249)\n\tat org.apache.pinot.broker.requesthandler.BaseBrokerRequestHandler.handleRequest(BaseBrokerRequestHandler.java:303)\n\tat org.apache.pinot.broker.api.resources.PinotClientRequest.processSqlQueryPost(PinotClientRequest.java:175)\n\tat sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)\n\tat org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)\n\tat org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)\n\tat org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:159)\n\tat org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)\n\tat org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:469)\n\tat org.glassfish.jersey.server.model.ResourceMethodInvoker.lambda$apply$0(ResourceMethodInvoker.java:381)\n\tat org.glassfish.jersey.server.ServerRuntime$AsyncResponder$2$1.run(ServerRuntime.java:819)" } ]
m
Try adding requestDate in select?
k
It still did not work. It needs to be added in group by.
Similar command works in postgres
m
Since this is a group by on select column (not aggregate), it is treated as distinct query. for that this is expected currently
k
Any work around to support such queries?
m
You can’t add group by requestDate also?
k
No as this field is not required in the final data
m
I mean you can just ignore that data from the result?
k
No, the end user expects data to be aggregated
k
@khush what is the purpose of this query?
looks like its trying to get distinct appNames?
k
This is to generate user reports. Yes the intent is to get data aggregated with distinct app names
k
why not use distinct
k
We need to aggregate the measures as well
How will distinct help here?
k
the query you have is not aggregating
Copy code
SELECT appName FROM requests  WHERE request_ts >= '1628380800000' AND request_ts <= '1628726400000' AND testRequest = 'false' GROUP BY appName ORDER BY requestDate ASC
k
Yes, I had removed the aggregation to debug. But it will have aggregate sum on some measures.
k
whats the exact query
k
Copy code
SELECT appName, sum(adRequests) FROM requests  WHERE request_ts >= '1628380800000' AND request_ts <= '1628726400000' AND testRequest = 'false' GROUP BY appName ORDER BY requestDate ASC
x
I tried sth like this on my side, and Pinot returns unique IDs. As this is aggregate query, so either order by fields in GroupBy or aggregates on some metrics column (not necessarily appearing in Select clause).
Copy code
SELECT VendorID FROM taxi_trips GROUP BY VendorID ORDER BY min(RatecodeID) LIMIT 5
So I assume you may try sth like below on your side. If requestDate is String, you may transform it to epoch (doc) and then do a numeric aggregate on it
Copy code
SELECT appName FROM requests ... ORDER BY min(requestDate) ASC
👍 1