[fix](group commit) Fix group commit debug log and improve performance (#38754) (#38841)

Pick https://github.com/apache/doris/pull/38754
This commit is contained in:
meiyi
2024-08-05 18:34:49 +08:00
committed by GitHub
parent 0f0b0e9b37
commit ce75e6adfe
2 changed files with 15 additions and 11 deletions

View File

@ -1236,8 +1236,9 @@ public class NativeInsertStmt extends InsertStmt {
for (Expr expr : row) {
if (!(expr instanceof LiteralExpr)) {
if (LOG.isDebugEnabled()) {
LOG.debug("group commit is off for table: {}, because not literal expr, "
+ "expr: {}, row: {}", targetTable.getName(), expr, row);
LOG.debug("group commit is off for query_id: {}, table: {}, "
+ "because not literal expr: {}, row: {}",
DebugUtil.printId(ctx.queryId()), targetTable.getName(), expr, row);
}
return;
}
@ -1246,8 +1247,9 @@ public class NativeInsertStmt extends InsertStmt {
// Does not support: insert into tbl values();
if (selectStmt.getValueList().getFirstRow().isEmpty() && CollectionUtils.isEmpty(targetColumnNames)) {
if (LOG.isDebugEnabled()) {
LOG.debug("group commit is off for table: {}, because first row: {}, target columns: {}",
targetTable.getName(), selectStmt.getValueList().getFirstRow(), targetColumnNames);
LOG.debug("group commit is off for query_id: {}, table: {}, because first row: {}, "
+ "target columns: {}", DebugUtil.printId(ctx.queryId()), targetTable.getName(),
selectStmt.getValueList().getFirstRow(), targetColumnNames);
}
return;
}
@ -1259,8 +1261,10 @@ public class NativeInsertStmt extends InsertStmt {
for (SelectListItem item : items) {
if (item.getExpr() != null && !(item.getExpr() instanceof LiteralExpr)) {
if (LOG.isDebugEnabled()) {
LOG.debug("group commit is off for table: {}, because not literal expr, "
+ "expr: {}, row: {}", targetTable.getName(), item.getExpr(), item);
LOG.debug("group commit is off for query_id: {}, table: {}, "
+ "because not literal expr: {}, row: {}",
DebugUtil.printId(ctx.queryId()), targetTable.getName(), item.getExpr(),
item);
}
return;
}
@ -1273,8 +1277,8 @@ public class NativeInsertStmt extends InsertStmt {
if (LOG.isDebugEnabled()) {
for (Pair<BooleanSupplier, Supplier<String>> pair : conditions) {
if (pair.first.getAsBoolean() == false) {
LOG.debug("group commit is off for table: {}, because: {}", targetTable.getName(),
pair.second.get());
LOG.debug("group commit is off for query_id: {}, table: {}, because: {}",
DebugUtil.printId(ctx.queryId()), targetTable.getName(), pair.second.get());
break;
}
}

View File

@ -347,14 +347,14 @@ public class StmtExecutor {
if (expr instanceof NullLiteral) {
row.addColBuilder().setValue(NULL_VALUE_FOR_LOAD);
} else if (expr instanceof ArrayLiteral) {
row.addColBuilder().setValue(String.format("\"%s\"", expr.getStringValueForStreamLoad(options)));
row.addColBuilder().setValue("\"" + expr.getStringValueForStreamLoad(options) + "\"");
} else {
String stringValue = expr.getStringValueForStreamLoad(options);
if (stringValue.equals(NULL_VALUE_FOR_LOAD) || stringValue.startsWith("\"") || stringValue.endsWith(
"\"")) {
row.addColBuilder().setValue(String.format("\"%s\"", stringValue));
row.addColBuilder().setValue("\"" + stringValue + "\"");
} else {
row.addColBuilder().setValue(String.format("%s", stringValue));
row.addColBuilder().setValue(stringValue);
}
}
}