This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 7ea1c33736d [fix](nereids) Fix load failed where not set database in
session (#41951) (#42081)
7ea1c33736d is described below
commit 7ea1c33736dca2d15ab7493dbbeb63ee8ded1587
Author: zxealous <[email protected]>
AuthorDate: Wed Oct 23 11:08:12 2024 +0800
[fix](nereids) Fix load failed where not set database in session (#41951)
(#42081)
cherry-pick from master #41951
load failed where not set database in session, should use label's
database if not set database in session
LOAD LABEL test_db.label_111111 ( DATA
INFILE("hdfs://hdfs01:9000/user/") INTO TABLE `test_load_tb`) WITH
BROKER "broker" ( "username" = "user", "password" = "");
ERROR 1105 (HY000): errCode = 2, detailMessage = Current database is not
set.
---
.../antlr4/org/apache/doris/nereids/DorisParser.g4 | 6 ++---
.../doris/nereids/parser/LogicalPlanBuilder.java | 26 +++++++++++++++++++---
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
index 0d39145c268..cdae7d27b7a 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
@@ -906,7 +906,7 @@ identityOrFunction
dataDesc
: ((WITH)? mergeType)? DATA INFILE LEFT_PAREN filePaths+=STRING_LITERAL
(COMMA filePath+=STRING_LITERAL)* RIGHT_PAREN
- INTO TABLE tableName=multipartIdentifier
+ INTO TABLE targetTableName=identifier
(PARTITION partition=identifierList)?
(COLUMNS TERMINATED BY comma=STRING_LITERAL)?
(LINES TERMINATED BY separator=STRING_LITERAL)?
@@ -920,8 +920,8 @@ dataDesc
(deleteOn=deleteOnClause)?
(sequenceColumn=sequenceColClause)?
(propertyClause)?
- | ((WITH)? mergeType)? DATA FROM TABLE tableName=multipartIdentifier
- INTO TABLE tableName=multipartIdentifier
+ | ((WITH)? mergeType)? DATA FROM TABLE sourceTableName=identifier
+ INTO TABLE targetTableName=identifier
(PARTITION partition=identifierList)?
(columnMapping=colMappingList)?
(where=whereClause)?
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 82045b8dac2..0fc3e27e071 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -1144,9 +1144,30 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
}
}
ImmutableList.Builder<BulkLoadDataDesc> dataDescriptions = new
ImmutableList.Builder<>();
+ List<String> labelParts = visitMultipartIdentifier(ctx.lableName);
+ String labelName = null;
+ String labelDbName = null;
+ if (ConnectContext.get().getDatabase().isEmpty() && labelParts.size()
== 1) {
+ throw new AnalysisException("Current database is not set.");
+ } else if (labelParts.size() == 1) {
+ labelName = labelParts.get(0);
+ } else if (labelParts.size() == 2) {
+ labelDbName = labelParts.get(0);
+ labelName = labelParts.get(1);
+ } else if (labelParts.size() == 3) {
+ labelDbName = labelParts.get(1);
+ labelName = labelParts.get(2);
+ } else {
+ throw new AnalysisException("labelParts in load should be
[ctl.][db.]label");
+ }
+
for (DorisParser.DataDescContext ddc : ctx.dataDescs) {
- List<String> tableName =
RelationUtil.getQualifierName(ConnectContext.get(),
- visitMultipartIdentifier(ddc.tableName));
+ List<String> nameParts = Lists.newArrayList();
+ if (labelDbName != null) {
+ nameParts.add(labelDbName);
+ }
+ nameParts.add(ddc.targetTableName.getText());
+ List<String> tableName =
RelationUtil.getQualifierName(ConnectContext.get(), nameParts);
List<String> colNames = (ddc.columns == null ? ImmutableList.of()
: visitIdentifierList(ddc.columns));
List<String> columnsFromPath = (ddc.columnsFromPath == null ?
ImmutableList.of()
:
visitIdentifierList(ddc.columnsFromPath.identifierList()));
@@ -1194,7 +1215,6 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
ddc.sequenceColumn == null ? Optional.empty()
:
Optional.of(ddc.sequenceColumn.identifier().getText()), dataProperties));
}
- String labelName = ctx.lableName.getText();
Map<String, String> properties = Collections.emptyMap();
if (ctx.propertyClause() != null) {
properties =
visitPropertyItemList(ctx.propertyClause().propertyItemList());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]