This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 0c71825172c [Fix](Export) Fix BE core when the `columns` attribute of
`export` parquet is specified as an asterisk (#28627)
0c71825172c is described below
commit 0c71825172cb2d2b661efb1d1fefe5f50785662e
Author: Tiewei Fang <[email protected]>
AuthorDate: Fri Dec 22 11:10:47 2023 +0800
[Fix](Export) Fix BE core when the `columns` attribute of `export` parquet
is specified as an asterisk (#28627)
---
.../java/org/apache/doris/analysis/ExportStmt.java | 31 +++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExportStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExportStmt.java
index 38f02c49cc4..6eaa45cdfdd 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExportStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExportStmt.java
@@ -39,6 +39,7 @@ import org.apache.doris.qe.VariableMgr;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
@@ -49,6 +50,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
+import java.util.stream.Collectors;
// EXPORT statement, export data to dirs by broker.
//
@@ -64,7 +66,6 @@ public class ExportStmt extends StatementBase {
private static final String DEFAULT_COLUMN_SEPARATOR = "\t";
private static final String DEFAULT_LINE_DELIMITER = "\n";
- private static final String DEFAULT_COLUMNS = "";
private static final String DEFAULT_PARALLELISM = "1";
private static final Integer DEFAULT_TIMEOUT = 7200;
@@ -121,7 +122,6 @@ public class ExportStmt extends StatementBase {
this.columnSeparator = DEFAULT_COLUMN_SEPARATOR;
this.lineDelimiter = DEFAULT_LINE_DELIMITER;
this.timeout = DEFAULT_TIMEOUT;
- this.columns = DEFAULT_COLUMNS;
// The ExportStmt may be created in replay thread, there is no
ConnectionContext
// in replay thread, so we need to clone session variable from default
session variable.
@@ -352,7 +352,14 @@ public class ExportStmt extends StatementBase {
properties, ExportStmt.DEFAULT_COLUMN_SEPARATOR));
this.lineDelimiter =
Separator.convertSeparator(PropertyAnalyzer.analyzeLineDelimiter(
properties, ExportStmt.DEFAULT_LINE_DELIMITER));
- this.columns = properties.getOrDefault(LoadStmt.KEY_IN_PARAM_COLUMNS,
DEFAULT_COLUMNS);
+
+ // null means not specified
+ // "" means user specified zero columns
+ this.columns = properties.getOrDefault(LoadStmt.KEY_IN_PARAM_COLUMNS,
null);
+ // check columns are exits
+ if (this.columns != null) {
+ checkColumns();
+ }
// format
this.format =
properties.getOrDefault(LoadStmt.KEY_IN_PARAM_FORMAT_TYPE, "csv").toLowerCase();
@@ -384,6 +391,24 @@ public class ExportStmt extends StatementBase {
label = properties.get(LABEL);
}
+ private void checkColumns() throws DdlException {
+ if (this.columns.isEmpty()) {
+ throw new DdlException("columns can not be empty");
+ }
+ Database db =
Env.getCurrentInternalCatalog().getDbOrDdlException(this.tblName.getDb());
+ Table table = db.getTableOrDdlException(this.tblName.getTbl());
+ List<String> tableColumns = table.getBaseSchema().stream().map(column
-> column.getName())
+ .collect(Collectors.toList());
+ Splitter split = Splitter.on(',').trimResults().omitEmptyStrings();
+
+ List<String> columnsSpecified =
split.splitToList(this.columns.toLowerCase());
+ for (String columnName : columnsSpecified) {
+ if (!tableColumns.contains(columnName)) {
+ throw new DdlException("unknown column [" + columnName + "] in
table [" + this.tblName.getTbl() + "]");
+ }
+ }
+ }
+
@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]