-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[opt](profile) Disable profile for insert into values and other commands #47296
base: master
Are you sure you want to change the base?
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,18 +142,22 @@ | |
import org.apache.doris.nereids.NereidsPlanner; | ||
import org.apache.doris.nereids.PlanProcess; | ||
import org.apache.doris.nereids.StatementContext; | ||
import org.apache.doris.nereids.analyzer.UnboundTableSink; | ||
import org.apache.doris.nereids.exceptions.MustFallbackException; | ||
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; | ||
import org.apache.doris.nereids.rules.exploration.mv.InitMaterializationContextHook; | ||
import org.apache.doris.nereids.trees.plans.Plan; | ||
import org.apache.doris.nereids.trees.plans.algebra.InlineTable; | ||
import org.apache.doris.nereids.trees.plans.commands.Command; | ||
import org.apache.doris.nereids.trees.plans.commands.CreatePolicyCommand; | ||
import org.apache.doris.nereids.trees.plans.commands.CreateTableCommand; | ||
import org.apache.doris.nereids.trees.plans.commands.DeleteFromCommand; | ||
import org.apache.doris.nereids.trees.plans.commands.DeleteFromUsingCommand; | ||
import org.apache.doris.nereids.trees.plans.commands.Forward; | ||
import org.apache.doris.nereids.trees.plans.commands.LoadCommand; | ||
import org.apache.doris.nereids.trees.plans.commands.PrepareCommand; | ||
import org.apache.doris.nereids.trees.plans.commands.Redirect; | ||
import org.apache.doris.nereids.trees.plans.commands.UnsupportedCommand; | ||
|
@@ -1226,6 +1230,40 @@ private boolean isQuery() { | |
&& !(((LogicalPlanAdapter) parsedStmt).getLogicalPlan() instanceof Command)); | ||
} | ||
|
||
private boolean isProfileSafeStmt() { | ||
// fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java:131 | ||
// Only generate profile for NereidsPlanner. | ||
if (!(parsedStmt instanceof LogicalPlanAdapter)) { | ||
return false; | ||
} | ||
|
||
LogicalPlan plan = ((LogicalPlanAdapter) parsedStmt).getLogicalPlan(); | ||
|
||
if (plan instanceof InsertIntoTableCommand) { | ||
LogicalPlan logicalPlan = ((InsertIntoTableCommand) plan).getLogicalQuery(); | ||
if (logicalPlan instanceof UnboundTableSink) { | ||
if (logicalPlan.children() == null || logicalPlan.children().isEmpty()) { | ||
return false; | ||
} | ||
|
||
for (Plan child : logicalPlan.children()) { | ||
if (child instanceof InlineTable) { | ||
return false; | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add comment to explain what does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
return true; | ||
} | ||
|
||
// Generate profile for CreateTableCommand(mainly for create as select). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment is different with code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
if ((plan instanceof Command) && !(plan instanceof LoadCommand) | ||
&& !(plan instanceof CreateTableCommand) && !(plan instanceof InsertOverwriteTableCommand)) { | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
private void forwardToMaster() throws Exception { | ||
masterOpExecutor = new MasterOpExecutor(originStmt, context, redirectStatus, isQuery()); | ||
if (LOG.isDebugEnabled()) { | ||
|
@@ -1261,7 +1299,7 @@ private void forwardToMaster() throws Exception { | |
} | ||
|
||
public void updateProfile(boolean isFinished) { | ||
if (!context.getSessionVariable().enableProfile()) { | ||
if (!context.getSessionVariable().enableProfile() || !isProfileSafeStmt()) { | ||
return; | ||
} | ||
// If any error happened in update profile, we should ignore this error | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if UnboundJdbcSink or UnboundHiveSink? is it safe for them to generate profile not like olap table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed by adding UnboundBaseExternalTableSink