[fix](Nereids) fallback not work when cannot parse after forward (#19790)
This commit is contained in:
@ -32,6 +32,10 @@ public class ParseException extends AnalysisException {
|
||||
private final Origin start;
|
||||
private final Optional<String> command;
|
||||
|
||||
public ParseException(String message) {
|
||||
this(message, new Origin(0, 0), Optional.empty());
|
||||
}
|
||||
|
||||
public ParseException(String message, Origin start, Optional<String> command) {
|
||||
super(message, start.line, start.startPosition, Optional.empty());
|
||||
this.message = message;
|
||||
|
||||
@ -115,6 +115,7 @@ import org.apache.doris.mysql.MysqlSerializer;
|
||||
import org.apache.doris.mysql.privilege.PrivPredicate;
|
||||
import org.apache.doris.nereids.NereidsPlanner;
|
||||
import org.apache.doris.nereids.StatementContext;
|
||||
import org.apache.doris.nereids.exceptions.ParseException;
|
||||
import org.apache.doris.nereids.glue.LogicalPlanAdapter;
|
||||
import org.apache.doris.nereids.minidump.MinidumpUtils;
|
||||
import org.apache.doris.nereids.parser.NereidsParser;
|
||||
@ -406,16 +407,17 @@ public class StmtExecutor {
|
||||
|| (parsedStmt == null && sessionVariable.isEnableNereidsPlanner())) {
|
||||
try {
|
||||
executeByNereids(queryId);
|
||||
} catch (NereidsException e) {
|
||||
} catch (NereidsException | ParseException e) {
|
||||
if (context.getMinidump() != null) {
|
||||
MinidumpUtils.saveMinidumpString(context.getMinidump(), DebugUtil.printId(context.queryId()));
|
||||
}
|
||||
// try to fall back to legacy planner
|
||||
LOG.warn("nereids cannot process statement\n" + originStmt.originStmt
|
||||
+ "\n because of " + e.getMessage(), e);
|
||||
if (!context.getSessionVariable().enableFallbackToOriginalPlanner) {
|
||||
if (e instanceof NereidsException
|
||||
&& !context.getSessionVariable().enableFallbackToOriginalPlanner) {
|
||||
LOG.warn("Analyze failed. {}", context.getQueryIdentifier(), e);
|
||||
throw e.getException();
|
||||
throw ((NereidsException) e).getException();
|
||||
}
|
||||
LOG.info("fall back to legacy planner");
|
||||
parsedStmt = null;
|
||||
@ -536,14 +538,11 @@ public class StmtExecutor {
|
||||
try {
|
||||
statements = new NereidsParser().parseSQL(originStmt.originStmt);
|
||||
} catch (Exception e) {
|
||||
throw new NereidsException(
|
||||
new AnalysisException("Nereids parse failed. " + e.getMessage(), e)
|
||||
);
|
||||
throw new ParseException("Nereids parse failed. " + e.getMessage());
|
||||
}
|
||||
if (statements.size() <= originStmt.idx) {
|
||||
throw new NereidsException(
|
||||
new AnalysisException("Nereids parse failed. Parser get " + statements.size() + " statements,"
|
||||
+ " but we need at least " + originStmt.idx + " statements."));
|
||||
throw new ParseException("Nereids parse failed. Parser get " + statements.size() + " statements,"
|
||||
+ " but we need at least " + originStmt.idx + " statements.");
|
||||
}
|
||||
parsedStmt = statements.get(originStmt.idx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user