diff --git a/be/src/runtime/group_commit_mgr.cpp b/be/src/runtime/group_commit_mgr.cpp index 692f7c6846..3931306cd6 100644 --- a/be/src/runtime/group_commit_mgr.cpp +++ b/be/src/runtime/group_commit_mgr.cpp @@ -226,7 +226,8 @@ Status GroupCommitTable::get_first_block_load_queue( } } } - return Status::InternalError("can not get a block queue"); + return Status::InternalError("can not get a block queue for table_id: " + + std::to_string(_table_id)); } Status GroupCommitTable::_create_group_commit_load( diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ArrayLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ArrayLiteral.java index 540a0747b4..5b4b5a9109 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ArrayLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ArrayLiteral.java @@ -148,6 +148,22 @@ public class ArrayLiteral extends LiteralExpr { return "[" + StringUtils.join(list, ", ") + "]"; } + @Override + public String getStringValueForStreamLoad() { + List list = new ArrayList<>(children.size()); + children.forEach(v -> { + String stringLiteral; + if (v instanceof NullLiteral) { + stringLiteral = "null"; + } else { + stringLiteral = getStringLiteralForStreamLoad(v); + } + // we should use type to decide we output array is suitable for json format + list.add(stringLiteral); + }); + return "[" + StringUtils.join(list, ", ") + "]"; + } + @Override protected void toThrift(TExprNode msg) { msg.node_type = TExprNodeType.ARRAY_LITERAL; diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java index 869ace0ef1..adb7621a34 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java @@ -2243,6 +2243,10 @@ public abstract class Expr extends TreeNode implements ParseNode, Cloneabl return getStringValue(); } + public String getStringValueForStreamLoad() { + return getStringValue(); + } + // A special method only for array literal, all primitive type in array // will be wrapped by double quote. eg: // ["1", "2", "3"] diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExpr.java index c222070e28..ce89b2fc3c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExpr.java @@ -123,6 +123,18 @@ public abstract class LiteralExpr extends Expr implements Comparable list = new ArrayList<>(children.size()); + children.forEach(v -> list.add(getStringLiteralForComplexType(v))); + return "{" + StringUtils.join(list, ", ") + "}"; + } + @Override protected void toThrift(TExprNode msg) { msg.node_type = TExprNodeType.STRUCT_LITERAL; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertIntoTableCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertIntoTableCommand.java index c1ec90fff7..d5101aabcd 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertIntoTableCommand.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertIntoTableCommand.java @@ -25,6 +25,7 @@ import org.apache.doris.catalog.Table; import org.apache.doris.catalog.TableIf; import org.apache.doris.common.ErrorCode; import org.apache.doris.common.ErrorReport; +import org.apache.doris.common.FeConstants; import org.apache.doris.common.UserException; import org.apache.doris.common.util.ProfileManager.ProfileType; import org.apache.doris.load.loadv2.LoadStatistic; @@ -251,10 +252,12 @@ public class InsertIntoTableCommand extends Command implements ForwardWithSync, || ctx.getSessionVariable().isEnableUniqueKeyPartialUpdate()) { return false; } + OlapTable targetTable = physicalOlapTableSink.getTargetTable(); return ctx.getSessionVariable().getSqlMode() != SqlModeHelper.MODE_NO_BACKSLASH_ESCAPES - && physicalOlapTableSink.getTargetTable() instanceof OlapTable && !ctx.isTxnModel() - && sink.getFragment().getPlanRoot() instanceof UnionNode && physicalOlapTableSink.getPartitionIds() - .isEmpty() && physicalOlapTableSink.getTargetTable().getTableProperty().getUseSchemaLightChange(); + && !ctx.isTxnModel() && sink.getFragment().getPlanRoot() instanceof UnionNode + && physicalOlapTableSink.getPartitionIds().isEmpty() && targetTable.getTableProperty() + .getUseSchemaLightChange() && !targetTable.getQualifiedDbName() + .equalsIgnoreCase(FeConstants.INTERNAL_DB_NAME); } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java index d97bf54c50..9c23469886 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java @@ -295,9 +295,9 @@ 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.getStringValueInFe())); + row.addColBuilder().setValue(String.format("\"%s\"", expr.getStringValueForStreamLoad())); } else { - String stringValue = expr.getStringValueInFe(); + String stringValue = expr.getStringValueForStreamLoad(); if (stringValue.equals(NULL_VALUE_FOR_LOAD) || stringValue.startsWith("\"") || stringValue.endsWith( "\"")) { row.addColBuilder().setValue(String.format("\"%s\"", stringValue)); @@ -1944,6 +1944,8 @@ public class StmtExecutor { } else if (insertStmt instanceof NativeInsertStmt && ((NativeInsertStmt) insertStmt).isGroupCommit()) { isGroupCommit = true; NativeInsertStmt nativeInsertStmt = (NativeInsertStmt) insertStmt; + long dbId = nativeInsertStmt.getTargetTable().getDatabase().getId(); + long tableId = nativeInsertStmt.getTargetTable().getId(); int maxRetry = 3; for (int i = 0; i < maxRetry; i++) { GroupCommitPlanner groupCommitPlanner = nativeInsertStmt.planForGroupCommit(context.queryId); @@ -1954,10 +1956,11 @@ public class StmtExecutor { ProtocolStringList errorMsgsList = response.getStatus().getErrorMsgsList(); if (code == TStatusCode.DATA_QUALITY_ERROR && !errorMsgsList.isEmpty() && errorMsgsList.get(0) .contains("schema version not match")) { - LOG.info("group commit insert failed. stmt: {}, backend id: {}, status: {}, " - + "schema version: {}, retry: {}", insertStmt.getOrigStmt().originStmt, - groupCommitPlanner.getBackend().getId(), - response.getStatus(), nativeInsertStmt.getBaseSchemaVersion(), i); + LOG.info("group commit insert failed. stmt: {}, query_id: {}, db_id: {}, table_id: {}" + + ", schema version: {}, backend_id: {}, status: {}, retry: {}", + insertStmt.getOrigStmt().originStmt, DebugUtil.printId(context.queryId()), dbId, tableId, + nativeInsertStmt.getBaseSchemaVersion(), groupCommitPlanner.getBackend().getId(), + response.getStatus(), i); if (i < maxRetry) { List tables = Lists.newArrayList(insertStmt.getTargetTable()); MetaLockUtils.readLockTables(tables); @@ -1970,12 +1973,14 @@ public class StmtExecutor { } continue; } else { - errMsg = "group commit insert failed. backend id: " + errMsg = "group commit insert failed. db_id: " + dbId + ", table_id: " + tableId + + ", query_id: " + DebugUtil.printId(context.queryId()) + ", backend_id: " + groupCommitPlanner.getBackend().getId() + ", status: " + response.getStatus(); } } else if (code != TStatusCode.OK) { - errMsg = "group commit insert failed. backend id: " + groupCommitPlanner.getBackend().getId() - + ", status: " + response.getStatus(); + errMsg = "group commit insert failed. db_id: " + dbId + ", table_id: " + tableId + ", query_id: " + + DebugUtil.printId(context.queryId()) + ", backend_id: " + groupCommitPlanner.getBackend() + .getId() + ", status: " + response.getStatus(); ErrorReport.reportDdlException(errMsg, ErrorCode.ERR_FAILED_WHEN_INSERT); } label = response.getLabel();