yiguolei commented on code in PR #25049:
URL: https://github.com/apache/doris/pull/25049#discussion_r1351620362
##########
fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java:
##########
@@ -2735,6 +2737,81 @@ private List<ResultRow>
convertResultBatchToResultRows(TResultBatch batch) {
return resultRows;
}
+ public void generateStreamLoadNereidsPlan(TUniqueId queryId) throws
Exception {
+ LOG.info("TUniqueId: {} generate stream load plan", queryId);
+ context.setQueryId(queryId);
+ context.setStartTime();
+ profile.getSummaryProfile().setQueryBeginTime();
+ context.setStmtId(STMT_ID_GENERATOR.incrementAndGet());
+
+ parseByNereids();
+ Preconditions.checkState(parsedStmt instanceof LogicalPlanAdapter,
+ "Nereids only process LogicalPlanAdapter, but parsedStmt is "
+ parsedStmt.getClass().getName());
+ context.getState().setNereids(true);
+ InsertIntoTableCommand insert = (InsertIntoTableCommand)
((LogicalPlanAdapter) parsedStmt).getLogicalPlan();
+ try {
+ insert.initPlan(context, this);
+ if (context.getTxnEntry() == null) {
+ TransactionEntry transactionEntry =
+ new TransactionEntry(new
TTxnParams().setTxnId(insert.getTxn().getTxnId()),
+ insert.getTxn().getDatabase(),
insert.getTxn().getTable());
+ transactionEntry.setLabel(insert.getTxn().getLabelName());
+ context.setTxnEntry(transactionEntry);
+ }
+ // Determine if it can be converted to TVFScanNode
+ PlanNode planRoot = planner.getFragments().get(0).getPlanRoot();
+ Preconditions.checkState(planRoot instanceof TVFScanNode,
+ "Nereids' planNode cannot be converted to " +
planRoot.getClass().getName());
+ } catch (QueryStateException e) {
+ LOG.debug("Command(" + originStmt.originStmt + ") process
failed.", e);
+ context.setState(e.getQueryState());
+ throw new NereidsException("Command(" + originStmt.originStmt + ")
process failed",
+ new AnalysisException(e.getMessage(), e));
+ } catch (UserException e) {
+ // Return message to info client what happened.
+ LOG.debug("Command(" + originStmt.originStmt + ") process
failed.", e);
+ context.getState().setError(e.getMysqlErrorCode(), e.getMessage());
+ throw new NereidsException("Command (" + originStmt.originStmt +
") process failed",
+ new AnalysisException(e.getMessage(), e));
+ } catch (Exception e) {
+ // Maybe our bug
+ LOG.debug("Command (" + originStmt.originStmt + ") process
failed.", e);
+ context.getState().setError(ErrorCode.ERR_UNKNOWN_ERROR,
e.getMessage());
+ throw new NereidsException("Command (" + originStmt.originStmt +
") process failed.",
+ new AnalysisException(e.getMessage(), e));
+ }
+ }
+
+ public void getStreamLoadPlan(TUniqueId queryId) throws Exception {
+ try {
+ generateStreamLoadNereidsPlan(queryId);
+ } catch (NereidsException | ParseException e) {
+ if (context.getMinidump() != null) {
+ MinidumpUtils.saveMinidumpString(context.getMinidump(),
DebugUtil.printId(context.queryId()));
+ }
+ // try to fall back to legacy planner
+ LOG.debug("nereids cannot process statement\n" +
originStmt.originStmt
+ + "\n because of " + e.getMessage(), e);
+ if (e instanceof NereidsException &&
!context.getSessionVariable().enableFallbackToOriginalPlanner) {
+ LOG.warn("Analyze failed. {}", context.getQueryIdentifier(),
e);
+ throw ((NereidsException) e).getException();
+ }
+ LOG.debug("fall back to legacy planner on statement:\n{}",
originStmt.originStmt);
+ // Due to executing Nereids, it needs to be reset
+ parsedStmt = null;
+ planner = null;
+ context.getState().setNereids(false);
+ context.setTxnEntry(null);
+ context.setQueryId(queryId);
+ context.setStartTime();
+ profile.getSummaryProfile().setQueryBeginTime();
Review Comment:
context.setStartTime();
profile.getSummaryProfile().setQueryBeginTime();
useless
--
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]