EmmyMiao87 commented on a change in pull request #3150: Support non-correlated subquery in having clause URL: https://github.com/apache/incubator-doris/pull/3150#discussion_r397577244
########## File path: fe/src/main/java/org/apache/doris/analysis/StmtRewriter.java ########## @@ -43,62 +44,260 @@ * Rewrite the statement of an analysis result. The unanalyzed rewritten * statement is returned. */ - public static void rewrite(Analyzer analyzer, StatementBase parsedStmt) + public static StatementBase rewrite(Analyzer analyzer, StatementBase parsedStmt) throws AnalysisException { if (parsedStmt instanceof QueryStmt) { QueryStmt analyzedStmt = (QueryStmt) parsedStmt; Preconditions.checkNotNull(analyzedStmt.analyzer); - rewriteQueryStatement(analyzedStmt, analyzer); + return rewriteQueryStatement(analyzedStmt, analyzer); } else if (parsedStmt instanceof InsertStmt) { final InsertStmt insertStmt = (InsertStmt)parsedStmt; final QueryStmt analyzedStmt = (QueryStmt)insertStmt.getQueryStmt(); Preconditions.checkNotNull(analyzedStmt.analyzer); - rewriteQueryStatement(analyzedStmt, analyzer); + QueryStmt rewrittenQueryStmt = rewriteQueryStatement(analyzedStmt, analyzer); + insertStmt.setQueryStmt(rewrittenQueryStmt); } else { throw new AnalysisException("Unsupported statement containing subqueries: " + parsedStmt.toSql()); } + return parsedStmt; } /** * Calls the appropriate rewrite method based on the specific type of query stmt. See * rewriteSelectStatement() and rewriteUnionStatement() documentation. */ - public static void rewriteQueryStatement(QueryStmt stmt, Analyzer analyzer) + public static QueryStmt rewriteQueryStatement(QueryStmt stmt, Analyzer analyzer) throws AnalysisException { Preconditions.checkNotNull(stmt); if (stmt instanceof SelectStmt) { - rewriteSelectStatement((SelectStmt) stmt, analyzer); + return rewriteSelectStatement((SelectStmt) stmt, analyzer); } else if (stmt instanceof SetOperationStmt) { rewriteUnionStatement((SetOperationStmt) stmt, analyzer); Review comment: The rewriteUnionStatement is a function without return parameters. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org