[improvement](group commit) Group commit insert into can be executed on observer fe (#26589)

This commit is contained in:
meiyi
2023-11-08 22:10:06 +08:00
committed by GitHub
parent a6f9df7096
commit e92d2fcb5a
2 changed files with 17 additions and 3 deletions

View File

@ -365,7 +365,7 @@ public class NativeInsertStmt extends InsertStmt {
analyzeTargetTable(analyzer);
db = analyzer.getEnv().getCatalogMgr().getCatalog(tblName.getCtl()).getDbOrAnalysisException(tblName.getDb());
analyzeGroupCommit();
analyzeGroupCommit(analyzer);
if (isGroupCommit()) {
return;
}
@ -1067,14 +1067,24 @@ public class NativeInsertStmt extends InsertStmt {
@Override
public RedirectStatus getRedirectStatus() {
if (isExplain()) {
if (isExplain() || isGroupCommit()) {
return RedirectStatus.NO_FORWARD;
} else {
return RedirectStatus.FORWARD_WITH_SYNC;
}
}
private void analyzeGroupCommit() {
public void analyzeGroupCommit(Analyzer analyzer) {
if (isGroupCommit) {
return;
}
try {
tblName.analyze(analyzer);
initTargetTable(analyzer);
} catch (Throwable e) {
LOG.warn("analyze group commit failed", e);
return;
}
if (ConnectContext.get().getSessionVariable().enableInsertGroupCommit
&& targetTable instanceof OlapTable
&& !ConnectContext.get().isTxnModel()

View File

@ -1109,6 +1109,10 @@ public class StmtExecutor {
analyzeVariablesInStmt();
}
if (context.getSessionVariable().enableInsertGroupCommit && parsedStmt instanceof NativeInsertStmt) {
NativeInsertStmt nativeInsertStmt = (NativeInsertStmt) parsedStmt;
nativeInsertStmt.analyzeGroupCommit(new Analyzer(context.getEnv(), context));
}
redirectStatus = parsedStmt.getRedirectStatus();
}