From 10874fdc343cfff1c09a76f3f09705ef1725285b Mon Sep 17 00:00:00 2001 From: wyb Date: Tue, 10 Sep 2024 17:00:19 +0800 Subject: [PATCH] Fix comment Signed-off-by: wyb --- .../java/com/starrocks/qe/ConnectContext.java | 3 +- .../java/com/starrocks/qe/StmtExecutor.java | 45 +++++++++---------- .../sql/ast/CreateTableAsSelectStmt.java | 5 +++ .../java/com/starrocks/sql/ast/DmlStmt.java | 7 +-- .../com/starrocks/sql/ast/StatementBase.java | 5 +++ 5 files changed, 35 insertions(+), 30 deletions(-) diff --git a/fe/fe-core/src/main/java/com/starrocks/qe/ConnectContext.java b/fe/fe-core/src/main/java/com/starrocks/qe/ConnectContext.java index b4073b214c5fa4..3f98d8cd9812ee 100644 --- a/fe/fe-core/src/main/java/com/starrocks/qe/ConnectContext.java +++ b/fe/fe-core/src/main/java/com/starrocks/qe/ConnectContext.java @@ -66,7 +66,6 @@ import com.starrocks.sql.analyzer.Authorizer; import com.starrocks.sql.analyzer.SemanticException; import com.starrocks.sql.ast.CleanTemporaryTableStmt; -import com.starrocks.sql.ast.DmlStmt; import com.starrocks.sql.ast.SetListItem; import com.starrocks.sql.ast.SetStmt; import com.starrocks.sql.ast.SetType; @@ -921,7 +920,7 @@ private String getExecType() { } private boolean isExecLoadType() { - return executor != null && executor.getParsedStmt() instanceof DmlStmt; + return executor != null && executor.isExecLoadType(); } public void checkTimeout(long now) { diff --git a/fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java b/fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java index 431c929f89c999..a49b636f048171 100644 --- a/fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java +++ b/fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java @@ -458,6 +458,26 @@ public StatementBase getParsedStmt() { return parsedStmt; } + public int getExecTimeout() { + return parsedStmt.getTimeout(); + } + + public String getExecType() { + if (parsedStmt instanceof InsertStmt || parsedStmt instanceof CreateTableAsSelectStmt) { + return "Insert"; + } else if (parsedStmt instanceof UpdateStmt) { + return "Update"; + } else if (parsedStmt instanceof DeleteStmt) { + return "Delete"; + } else { + return "Query"; + } + } + + public boolean isExecLoadType() { + return parsedStmt instanceof DmlStmt || parsedStmt instanceof CreateTableAsSelectStmt; + } + // Execute one statement. // Exception: // IOException: talk with client failed. @@ -2692,29 +2712,4 @@ public void addFinishedQueryDetail() { QueryDetailQueue.addQueryDetail(queryDetail); } - - public int getExecTimeout() { - if (parsedStmt instanceof DmlStmt) { - int timeout = ((DmlStmt) parsedStmt).getTimeout(); - return timeout != -1 ? timeout : context.getSessionVariable().getInsertTimeoutS(); - } - if (parsedStmt instanceof CreateTableAsSelectStmt) { - InsertStmt insertStmt = ((CreateTableAsSelectStmt) parsedStmt).getInsertStmt(); - int timeout = insertStmt.getTimeout(); - return timeout != -1 ? timeout : context.getSessionVariable().getInsertTimeoutS(); - } - return context.getSessionVariable().getQueryTimeoutS(); - } - - public String getExecType() { - if (parsedStmt instanceof InsertStmt || parsedStmt instanceof CreateTableAsSelectStmt) { - return "Insert"; - } else if (parsedStmt instanceof UpdateStmt) { - return "Update"; - } else if (parsedStmt instanceof DeleteStmt) { - return "Delete"; - } else { - return "Query"; - } - } } diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/ast/CreateTableAsSelectStmt.java b/fe/fe-core/src/main/java/com/starrocks/sql/ast/CreateTableAsSelectStmt.java index 4da1e00f2b2015..855bd80f9a88a4 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/ast/CreateTableAsSelectStmt.java +++ b/fe/fe-core/src/main/java/com/starrocks/sql/ast/CreateTableAsSelectStmt.java @@ -78,4 +78,9 @@ public String toSql() { public R accept(AstVisitor visitor, C context) { return visitor.visitCreateTableAsSelectStatement(this, context); } + + @Override + public int getTimeout() { + return insertStmt.getTimeout(); + } } diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/ast/DmlStmt.java b/fe/fe-core/src/main/java/com/starrocks/sql/ast/DmlStmt.java index 1bf5f2bc68e249..684f1eca8aef5b 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/ast/DmlStmt.java +++ b/fe/fe-core/src/main/java/com/starrocks/sql/ast/DmlStmt.java @@ -17,6 +17,7 @@ import com.google.common.collect.Maps; import com.starrocks.analysis.RedirectStatus; import com.starrocks.analysis.TableName; +import com.starrocks.qe.ConnectContext; import com.starrocks.sql.parser.NodePosition; import java.util.Map; @@ -52,15 +53,15 @@ public Map getProperties() { return properties; } + @Override public int getTimeout() { - int timeout = -1; if (properties.containsKey(LoadStmt.TIMEOUT_PROPERTY)) { try { - timeout = Integer.parseInt(properties.get(LoadStmt.TIMEOUT_PROPERTY)); + return Integer.parseInt(properties.get(LoadStmt.TIMEOUT_PROPERTY)); } catch (NumberFormatException e) { // ignore } } - return timeout; + return ConnectContext.get().getSessionVariable().getInsertTimeoutS(); } } diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/ast/StatementBase.java b/fe/fe-core/src/main/java/com/starrocks/sql/ast/StatementBase.java index c8745193aae6b0..0edc4f1a165cc7 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/ast/StatementBase.java +++ b/fe/fe-core/src/main/java/com/starrocks/sql/ast/StatementBase.java @@ -39,6 +39,7 @@ import com.starrocks.analysis.ParseNode; import com.starrocks.analysis.RedirectStatus; import com.starrocks.common.profile.Tracers; +import com.starrocks.qe.ConnectContext; import com.starrocks.qe.OriginStatement; import com.starrocks.sql.parser.NodePosition; import org.apache.commons.collections4.CollectionUtils; @@ -151,4 +152,8 @@ public void setAllQueryScopeHints(List hintNodes) { public boolean isExistQueryScopeHint() { return CollectionUtils.isNotEmpty(allQueryScopeHints); } + + public int getTimeout() { + return ConnectContext.get().getSessionVariable().getQueryTimeoutS(); + } }