Skip to content

Commit

Permalink
Fix comment
Browse files Browse the repository at this point in the history
Signed-off-by: wyb <[email protected]>
  • Loading branch information
wyb committed Sep 10, 2024
1 parent 1a2b4fa commit 10874fd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
45 changes: 20 additions & 25 deletions fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ public String toSql() {
public <R, C> R accept(AstVisitor<R, C> visitor, C context) {
return visitor.visitCreateTableAsSelectStatement(this, context);
}

@Override
public int getTimeout() {
return insertStmt.getTimeout();
}
}
7 changes: 4 additions & 3 deletions fe/fe-core/src/main/java/com/starrocks/sql/ast/DmlStmt.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,15 +53,15 @@ public Map<String, String> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -151,4 +152,8 @@ public void setAllQueryScopeHints(List<HintNode> hintNodes) {
public boolean isExistQueryScopeHint() {
return CollectionUtils.isNotEmpty(allQueryScopeHints);
}

public int getTimeout() {
return ConnectContext.get().getSessionVariable().getQueryTimeoutS();
}
}

0 comments on commit 10874fd

Please sign in to comment.