weixiangsun commented on a change in pull request #8029: URL: https://github.com/apache/pinot/pull/8029#discussion_r814081650
########## File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java ########## @@ -129,8 +129,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: Good catch! Fixed -- 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