Adding Pinot SQL endpoint support#14704
Conversation
130a8e7 to
5671504
Compare
|
Awesome improvement ! Can you please add some more details about the design/approach in the PR description. It would help with reviewing since the PR is rather large. Thanks. |
agrawaldevesh
left a comment
There was a problem hiding this comment.
haven't looked at the tests
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSourceV2.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSourceBase.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSourceBase.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSourceBase.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSourceBase.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSourceV2.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSourceV2.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGenerator.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
c183758 to
bc33a1a
Compare
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/test/java/com/facebook/presto/pinot/TestPinotBrokerPageSourceSql.java
Outdated
Show resolved
Hide resolved
agrawaldevesh
left a comment
There was a problem hiding this comment.
I think some of the comments are still yet to be addressed ? Also, it would be great to call out in the PR description what the general approach was and what parts are like semantically new vs just code movement.
Thanks ! (Getting really really close !)
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotSessionProperties.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGenerator.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/test/java/com/facebook/presto/pinot/TestPinotBrokerPageSourceSql.java
Outdated
Show resolved
Hide resolved
e86d1b2 to
a1ce7cf
Compare
agrawaldevesh
left a comment
There was a problem hiding this comment.
Some more comments on beefing up the test coverage to cover the salient differences b/w the SQL and the PQL end points.
presto-pinot-toolkit/src/test/java/com/facebook/presto/pinot/TestPinotBrokerPageSourceSql.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/test/java/com/facebook/presto/pinot/TestPinotBrokerPageSourceSql.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/test/java/com/facebook/presto/pinot/query/TestPinotQueryGeneratorSql.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/test/java/com/facebook/presto/pinot/query/TestPinotQueryGeneratorSql.java
Outdated
Show resolved
Hide resolved
agrawaldevesh
left a comment
There was a problem hiding this comment.
some questions on your responses please :-)
Also, I think we should update the PR description to add more motivation on why we are interested in moving to the SQL end point. Perhaps you can say that the PQL end point is going to be deprecated or something to that effect ?
Thanks !
presto-pinot-toolkit/src/test/java/com/facebook/presto/pinot/TestPinotBrokerPageSourceSql.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/test/java/com/facebook/presto/pinot/TestPinotBrokerPageSourceSql.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/test/java/com/facebook/presto/pinot/query/TestPinotQueryGeneratorSql.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSourceSql.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/test/java/com/facebook/presto/pinot/query/TestPinotQueryGeneratorSql.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/test/java/com/facebook/presto/pinot/query/TestPinotQueryGeneratorSql.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/test/java/com/facebook/presto/pinot/query/TestPinotQueryGeneratorSql.java
Outdated
Show resolved
Hide resolved
c0c4aa5 to
58fccab
Compare
agrawaldevesh
left a comment
There was a problem hiding this comment.
Much much better testing !
A few nits on comments on stuff.
But my biggest remaining question is around my lack of understanding of the new outputs field in the PinotQueryGeneratorContext: Why it can't be used for PQL and the special handling needed for it in visitProject. Please see the comments inline.
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSourceSql.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGenerator.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/test/java/com/facebook/presto/pinot/query/TestPinotQueryGenerator.java
Outdated
Show resolved
Hide resolved
58fccab to
433db34
Compare
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGenerator.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Just like line 319 above, should this also be Map<> newSelections = new HashMap<> ? (instead of new LinkedHashMap)
There was a problem hiding this comment.
Here the reason is that in our PQL generation test, we create AggregationPlanNode by setting the Aggregations directly, if we use HashMap then generatedPql cannot guarantee the ordering of aggregation functions. Otherwise we need to set a ProjectNode always outside an AggregationPlanNode
There was a problem hiding this comment.
Lets please fix the tests instead of complicating the production code like this. Even if it means more changes.
There was a problem hiding this comment.
The issue is that in visitAggregation method, I didn't explicitly generate outputs, and infer it when calling context.withAggregation by using outputs.addAll(newSelection.keySet()). This is fine when selection is an ordered map.
So the change I made is to generate outputs in visitAggregation method.
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGenerator.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
433db34 to
c2c5eda
Compare
agrawaldevesh
left a comment
There was a problem hiding this comment.
Starting to look really good. Can you also please mark the resolved comments as such. Its getting hard to review the incremental changes esp because Github doesn't deal with force pushes that nicely :-)
I think my only remaining comment here is about not having to use a LinkedHashMap for the selections just to make the test code pass. I would rather we change the test code.
c2c5eda to
4698ab7
Compare
The issue is that in The best of it is NO test code changes! |
932461e to
374a419
Compare
agrawaldevesh
left a comment
There was a problem hiding this comment.
Just last few nits. LGTM otherwise !
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
...-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGenerator.java
Outdated
Show resolved
Hide resolved
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGenerator.java
Outdated
Show resolved
Hide resolved
e5ebdb2 to
b752cd9
Compare
Many many thanks!!! |
agrawaldevesh
left a comment
There was a problem hiding this comment.
@highker, @sachdevs please help review this PR.
@fx19880617 and I have done several passes over this and I am pretty satisfied with the end result: The necessary refactoring needed to support both PQL and SQL is clean, in that it tries to share maximal code and the new abstractions introduced also make more sense. There is great test coverage to boot.
Thanks.
|
@zhenxiao, could you help to take a look at the PR also? |
|
@fx19880617, can we squash all commits into one? |
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSourceBase.java
Outdated
Show resolved
Hide resolved
zhenxiao
left a comment
There was a problem hiding this comment.
nice work @fx19880617
looks good to me
a few small things
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSourceBase.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
is it possible we make counter a private data member, and return counter here?
There was a problem hiding this comment.
So the problem is that the Broker page source is one shot: It does not have a notion of partial or a cursor: Either the number of completed positions is zero or it is the entire number of rows being returned.
The current usage of completed positions (if you search for the callers of this function), is to basically show a progress indicator while the query is running. That does not fit the broker page source semantics: Because the counter will only change basically when the query is finished (ie when the counter is numRows, then the page source is already done and the query is being torn down)
There was a problem hiding this comment.
I think counter is completed positions?
There was a problem hiding this comment.
could outputs be Set? LinkedHashSet is an implementation
There was a problem hiding this comment.
I would very much like to keep it as a LinkedHashSet ... I can't tell you the number of times this has bit me: If order is needed then it should be statically checked.
b752cd9 to
e9b1cee
Compare
|
@fx19880617, could you squash the commits and push? I will merge afterwards. |
- Enable this feature by setting `pinot.use-pinot-sql-for-broker-queries=true` - Support aggregation/group by/oder by pushdown to query Pinot broker
e9b1cee to
5948ba3
Compare
Done! Many Thanks!!! |
The motivation of this PR to add Pinot SQL endpoint support is that Pinot Community is moving to SQL syntax/endpoint on query side to support more features and also plan to deprecate PQL queries.
This PR:
pinot.use-pinot-sql-for-broker-queries=true.