walterddr commented on code in PR #10421:
URL: https://github.com/apache/pinot/pull/10421#discussion_r1137845840
##########
pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java:
##########
@@ -492,6 +489,62 @@ public static PinotQuery
compileSqlNodeToPinotQuery(SqlNode sqlNode) {
return pinotQuery;
}
+ private static DataSource compileToDataSource(SqlNode sqlNode) {
+ DataSource dataSource = new DataSource();
+ switch (sqlNode.getKind()) {
+ case IDENTIFIER:
+ dataSource.setTableName(sqlNode.toString());
+ break;
+ case AS:
+ List<SqlNode> operandList = ((SqlBasicCall) sqlNode).getOperandList();
+ dataSource.setSubquery(compileSqlNodeToPinotQuery(operandList.get(0)));
+ dataSource.setTableName(operandList.get(1).toString());
+ break;
+ case SELECT:
+ case ORDER_BY:
+ dataSource.setSubquery(compileSqlNodeToPinotQuery(sqlNode));
+ break;
+ case JOIN:
+ dataSource.setJoin(compileToJoin((SqlJoin) sqlNode));
+ break;
+ default:
+ throw new IllegalStateException("Unsupported SQL node kind as
DataSource: " + sqlNode.getKind());
+ }
+ return dataSource;
+ }
+
+ private static Join compileToJoin(SqlJoin sqlJoin) {
+ Join join = new Join();
+ switch (sqlJoin.getJoinType()) {
+ case INNER:
+ join.setType(JoinType.INNER);
+ break;
+ case LEFT:
+ join.setType(JoinType.LEFT);
+ break;
+ case RIGHT:
+ join.setType(JoinType.RIGHT);
+ break;
+ case FULL:
+ join.setType(JoinType.FULL);
+ break;
+ default:
+ throw new IllegalStateException("Unsupported join type: " +
sqlJoin.getJoinType());
+ }
+ join.setLeft(compileToDataSource(sqlJoin.getLeft()));
+ join.setRight(compileToDataSource(sqlJoin.getRight()));
+ switch (sqlJoin.getConditionType()) {
+ case ON:
+ join.setCondition(toExpression(sqlJoin.getCondition()));
Review Comment:
you mean query rewriter? i think we don't need to deal with these level of
complexity in parser
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]