weixiangsun commented on a change in pull request #8029: URL: https://github.com/apache/pinot/pull/8029#discussion_r793124452
########## File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java ########## @@ -130,8 +130,25 @@ public static PinotQuery compileToPinotQuery(String sql) if (!options.isEmpty()) { sql = removeOptionsFromSql(sql); } + + SqlParser sqlParser = SqlParser.create(sql, PARSER_CONFIG); + SqlNode sqlNode; + try { + sqlNode = sqlParser.parseQuery(); + } catch (SqlParseException e) { + throw new SqlCompilationException("Caught exception while parsing query: " + sql, e); + } + // Compile Sql without OPTION statements. - PinotQuery pinotQuery = compileCalciteSqlToPinotQuery(sql); + PinotQuery pinotQuery = compileSqlNodeToPinotQuery(sqlNode); + + SqlSelect sqlSelect = getSelectNode(sqlNode); + if (sqlSelect != null) { + SqlNode fromNode = sqlSelect.getFrom(); + if (fromNode != null && (fromNode instanceof SqlSelect || fromNode instanceof SqlOrderBy)) { + pinotQuery.getDataSource().setSubquery(compileSqlNodeToPinotQuery(fromNode)); + } + } Review comment: I just broke down compileCalciteSqlToPinotQuery into two parts: 1. converting sql statement to SqlNode 2. construct PinotQuery from SqlNode. This breakdown is because we need reuse the second part for constructing the pinotQuery from outer query and inner query. So the change to original code is necessary. -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org