New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Calcite SQL Parser and make another entry point to query Pinot #4387
Conversation
54648fb
to
45c8dea
Compare
Codecov Report
@@ Coverage Diff @@
## master #4387 +/- ##
===========================================
+ Coverage 55.7% 65.5% +9.79%
Complexity 20 20
===========================================
Files 1066 1075 +9
Lines 55403 55835 +432
Branches 7894 7964 +70
===========================================
+ Hits 30865 36573 +5708
+ Misses 22150 16644 -5506
- Partials 2388 2618 +230
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not parse PQL using calcite after removing options.
@@ -83,6 +88,22 @@ public BrokerResponse executeQuery(String brokerAddress, String query) | |||
} | |||
} | |||
|
|||
@Override | |||
public BrokerResponse executeSqlQuery(String brokerAddress, String query) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to add another overloaded parameter to executeQueryAsync to take queryFormat as a param (default can be PQL for now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make Query an object
pinot-broker/src/test/java/org/apache/pinot/broker/request/PqlAndCalciteSqlCompatibleTest.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
public boolean validate(BrokerRequest br1, BrokerRequest br2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should move this to some Validator so that we can invoke it from other places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
Show resolved
Hide resolved
…ql parsing logic seamlessly
pinot-api/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransport.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/PinotQueryParserFactory.java
Show resolved
Hide resolved
@@ -338,6 +337,13 @@ public BrokerResponse handleRequest(JsonNode request, @Nullable RequesterIdentit | |||
return brokerResponse; | |||
} | |||
|
|||
private PinotQueryRequest getPinotQueryRequest(JsonNode request) { | |||
if (request.has(SQL)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to assert that only one of SQL|PQL is specified in the request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since sql support is newly added, I feel it's ok to keep sql parsing as first priority comparing to PQL.
So existing PQL user won't get affected.
...ache/pinot/broker/requesthandler/MultipleOrEqualitiesToInClauseFilterQueryTreeOptimizer.java
Outdated
Show resolved
Hide resolved
...-broker/src/test/java/org/apache/pinot/broker/request/PqlAndCalciteSqlCompatibilityTest.java
Show resolved
Hide resolved
public void testPqlAndSqlCompatible() | ||
throws Exception { | ||
final BufferedReader brPql = new BufferedReader(new InputStreamReader( | ||
PqlAndCalciteSqlCompatibilityTest.class.getClassLoader().getResourceAsStream("pql_queries.list"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the queries.list comprehensive enough to test all the various PQL syntax features?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will cover full syntax features. I've added some more queries into it. We should keep adding more query patterns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we should ensure that we have full coverage before we advertise the SQL option. Let's open a issue to track that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
@@ -96,6 +96,10 @@ | |||
<groupId>org.antlr</groupId> | |||
<artifactId>antlr4-runtime</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.calcite</groupId> | |||
<artifactId>calcite-core</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have a lot more functionality than the complier that we won't need? If so, is there a different artifact to include that just has what we need?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the artifact we need in order to use SqlParser(https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/parser/SqlParser.java
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So are we bringing in a lot more (in calcite-core) than we need? Probably we don't have an option, but in case we do, consider just getting the minimal artifact available that we need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we may exclude the unnecessary dependencies once conflict is found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor comments need responding before pushing the change. LGTM, otherwise.
As part of winedepot#14, this PR implements a Calcite SQL parser to compile SQL to PinotQuery.
Something to be noticed as syntax backward incompatible with PQL.
Currently I removed the single quote from StringLiteral to match PQL parsing behavior.
See:
literal.setStringValue(node.toString().replaceAll("^\'|\'$", ""));