You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2020/09/14 07:51:14 UTC
[incubator-doris] branch branch-0.13 updated (bbefdad -> 9d86f66)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a change to branch branch-0.13
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git.
from bbefdad [Spark Load][Bug] Keep the column splitting in spark load consistent with broker load / mini load (#4532)
new 782b54a [Variable] Add a new global variable "performance_schema" to support Mysql JDBC 8.0.16 or later.#4537# (#4542)
new 4ff6e84 [BUG] Fix stale path delete checking logic when current main path is missing. (#4549)
new 3b4564b [Bug] Fix null pointer when replay RollupJob (#4572)
new 87e8c22 [Bug] catch plugin init error for Reinstall plugin (#4561)
new 557b3d4 [Bug] fix get_parsed_paths() subscript out of range (#4585)
new 33b6206 [SparkDpp] Support complete types (#4524)
new f4ba580 [Bug]Fix bug that tablet info with wrong capacity may cause fe oom (#4567)
new 53f0577 [SQL][Planner] Fix the the parallesim of fragment which has 3 or more childern #4569 (#4570)
new 3f4110e [BUG] ReAgg when adding agg mv on dup base table (#4587)
new 9d86f66 [compaction][config] Change default config policy to size_based
The 10 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
be/src/common/config.h | 2 +-
be/src/exprs/json_functions.cpp | 3 +
be/src/olap/push_handler.cpp | 2 +-
be/src/olap/schema_change.cpp | 27 +++-
be/src/olap/tablet.cpp | 73 +++++++--
docs/en/administrator-guide/variables.md | 4 +
docs/zh-CN/administrator-guide/variables.md | 4 +
.../java/org/apache/doris/alter/RollupJob.java | 4 +
.../apache/doris/plugin/DynamicPluginLoader.java | 7 +-
.../main/java/org/apache/doris/qe/Coordinator.java | 19 ++-
.../java/org/apache/doris/qe/GlobalVariable.java | 5 +
.../java/org/apache/doris/qe/ShowExecutor.java | 22 +--
.../apache/doris/load/loadv2/dpp/ColumnParser.java | 89 +++++++++--
.../org/apache/doris/load/loadv2/dpp/SparkDpp.java | 170 ++++++++++++++++++---
.../doris/load/loadv2/dpp/SparkRDDAggregator.java | 53 +++++--
.../doris/load/loadv2/dpp/ColumnParserTest.java | 135 ++++++++++++++++
.../apache/doris/load/loadv2/dpp/SparkDppTest.java | 67 ++++++++
17 files changed, 604 insertions(+), 82 deletions(-)
create mode 100644 fe/spark-dpp/src/test/java/org/apache/doris/load/loadv2/dpp/ColumnParserTest.java
create mode 100644 fe/spark-dpp/src/test/java/org/apache/doris/load/loadv2/dpp/SparkDppTest.java
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[incubator-doris] 03/10: [Bug] Fix null pointer when replay
RollupJob (#4572)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-0.13
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 3b4564b52e0d5929404d1ba8e8c0ce391bb6428c
Author: EmmyMiao87 <52...@qq.com>
AuthorDate: Thu Sep 10 11:55:14 2020 +0800
[Bug] Fix null pointer when replay RollupJob (#4572)
When fe replay rollup job(v1) with deleted table, it will throw null pointer exception and exit.
This commit ignore this error and print a warning log to avoid fe exit.
Fixed #4571
Change-Id: I302b554a94d42aee645db6b224cd989e00cd3ca6
---
fe/fe-core/src/main/java/org/apache/doris/alter/RollupJob.java | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJob.java b/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJob.java
index 5cd474b..15d07f7 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJob.java
@@ -903,6 +903,10 @@ public class RollupJob extends AlterJob {
db.writeLock();
try {
OlapTable olapTable = (OlapTable) db.getTable(tableId);
+ if (olapTable == null) {
+ LOG.warn("table {} could not be found when replay rollup job", tableId);
+ return;
+ }
olapTable.setState(OlapTableState.NORMAL);
} finally {
db.writeUnlock();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[incubator-doris] 06/10: [SparkDpp] Support complete types (#4524)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-0.13
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 33b6206f699b30eb5b55f4bb28f3991a19c2862a
Author: wangbo <50...@qq.com>
AuthorDate: Sun Sep 13 11:57:33 2020 +0800
[SparkDpp] Support complete types (#4524)
For[Spark Load]
1 support decimal andl largeint
2 add validate logic for char/varchar/decimal
3 check data load from hive with strict mode
4 support decimal/date/datetime aggregator
---
be/src/olap/push_handler.cpp | 2 +-
.../apache/doris/load/loadv2/dpp/ColumnParser.java | 89 +++++++++--
.../org/apache/doris/load/loadv2/dpp/SparkDpp.java | 170 ++++++++++++++++++---
.../doris/load/loadv2/dpp/SparkRDDAggregator.java | 53 +++++--
.../doris/load/loadv2/dpp/ColumnParserTest.java | 135 ++++++++++++++++
.../apache/doris/load/loadv2/dpp/SparkDppTest.java | 67 ++++++++
6 files changed, 467 insertions(+), 49 deletions(-)
diff --git a/be/src/olap/push_handler.cpp b/be/src/olap/push_handler.cpp
index 2a06329..cfd221d 100644
--- a/be/src/olap/push_handler.cpp
+++ b/be/src/olap/push_handler.cpp
@@ -1026,7 +1026,7 @@ OLAPStatus PushBrokerReader::next(ContiguousRow* row) {
const void* value = _tuple->get_slot(slot->tuple_offset());
// try execute init method defined in aggregateInfo
// by default it only copies data into cell
- _schema->column(i)->consume(&cell, (const char*)value, is_null,
+ _schema->column(i)->consume(&cell, (const char*)value, is_null,
_mem_pool.get(), _runtime_state->obj_pool());
// if column(i) is a value column, try execute finalize method defined in aggregateInfo
// to convert data into final format
diff --git a/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/ColumnParser.java b/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/ColumnParser.java
index d5e0cee..c9d6a42 100644
--- a/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/ColumnParser.java
+++ b/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/ColumnParser.java
@@ -19,13 +19,20 @@ package org.apache.doris.load.loadv2.dpp;
import org.apache.doris.common.SparkDppException;
import org.apache.doris.load.loadv2.etl.EtlJobConfig;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
import org.joda.time.DateTime;
import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
import java.util.Date;
// Parser to validate value for different type
public abstract class ColumnParser implements Serializable {
+
+ protected static final Logger LOG = LogManager.getLogger(ColumnParser.class);
+
public static ColumnParser create(EtlJobConfig.EtlColumn etlColumn) throws SparkDppException {
String columnType = etlColumn.columnType;
if (columnType.equalsIgnoreCase("TINYINT")) {
@@ -51,6 +58,10 @@ public abstract class ColumnParser implements Serializable {
|| columnType.equalsIgnoreCase("BITMAP")
|| columnType.equalsIgnoreCase("HLL")) {
return new StringParser(etlColumn);
+ } else if (columnType.equalsIgnoreCase("DECIMALV2")) {
+ return new DecimalParser(etlColumn);
+ } else if (columnType.equalsIgnoreCase("LARGEINT")) {
+ return new LargeIntParser();
} else {
throw new SparkDppException("unsupported type:" + columnType);
}
@@ -63,10 +74,7 @@ class TinyIntParser extends ColumnParser {
@Override
public boolean parse(String value) {
try {
- Short parsed = Short.parseShort(value);
- if (parsed > 127 || parsed < -128) {
- return false;
- }
+ Byte.parseByte(value);
} catch (NumberFormatException e) {
return false;
}
@@ -102,7 +110,7 @@ class BigIntParser extends ColumnParser {
@Override
public boolean parse(String value) {
try {
- Integer.parseInt(value);
+ Long.parseLong(value);
} catch (NumberFormatException e) {
return false;
}
@@ -114,11 +122,11 @@ class FloatParser extends ColumnParser {
@Override
public boolean parse(String value) {
try {
- Float.parseFloat(value);
+ Float ret = Float.parseFloat(value);
+ return !ret.isNaN() && !ret.isInfinite();
} catch (NumberFormatException e) {
return false;
}
- return true;
}
}
@@ -126,11 +134,11 @@ class DoubleParser extends ColumnParser {
@Override
public boolean parse(String value) {
try {
- Double.parseDouble(value);
+ Double ret = Double.parseDouble(value);
+ return !ret.isInfinite() && !ret.isNaN();
} catch (NumberFormatException e) {
return false;
}
- return true;
}
}
@@ -186,4 +194,67 @@ class StringParser extends ColumnParser {
throw new RuntimeException("string check failed ", e);
}
}
+}
+
+class DecimalParser extends ColumnParser {
+
+ public static int PRECISION = 27;
+ public static int SCALE = 9;
+
+ private BigDecimal maxValue;
+ private BigDecimal minValue;
+
+ public DecimalParser(EtlJobConfig.EtlColumn etlColumn) {
+ StringBuilder precisionStr = new StringBuilder();
+ for (int i = 0; i < etlColumn.precision - etlColumn.scale; i++) {
+ precisionStr.append("9");
+ }
+ StringBuilder scaleStr = new StringBuilder();
+ for (int i = 0; i < etlColumn.scale; i++) {
+ scaleStr.append("9");
+ }
+ maxValue = new BigDecimal(precisionStr.toString() + "." + scaleStr.toString());
+ minValue = new BigDecimal("-" + precisionStr.toString() + "." + scaleStr.toString());
+ }
+
+ @Override
+ public boolean parse(String value) {
+ try {
+ BigDecimal bigDecimal = new BigDecimal(value);
+ return bigDecimal.precision() - bigDecimal.scale() <= PRECISION - SCALE && bigDecimal.scale() <= SCALE;
+ } catch (NumberFormatException e) {
+ return false;
+ } catch (Exception e) {
+ throw new RuntimeException("decimal parse failed ", e);
+ }
+ }
+
+ public BigDecimal getMaxValue() {
+ return maxValue;
+ }
+
+ public BigDecimal getMinValue() {
+ return minValue;
+ }
+}
+
+class LargeIntParser extends ColumnParser {
+
+ private BigInteger maxValue = new BigInteger("170141183460469231731687303715884105727");
+ private BigInteger minValue = new BigInteger("-170141183460469231731687303715884105728");
+
+ @Override
+ public boolean parse(String value) {
+ try {
+ BigInteger inputValue = new BigInteger(value);
+ return inputValue.compareTo(maxValue) < 0 && inputValue.compareTo(minValue) > 0;
+ } catch (NumberFormatException e) {
+ return false;
+ } catch (ArithmeticException e) {
+ LOG.warn("int value is too big even for java BigInteger,value={}" + value);
+ return false;
+ } catch (Exception e) {
+ throw new RuntimeException("large int parse failed:" + value, e);
+ }
+ }
}
\ No newline at end of file
diff --git a/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/SparkDpp.java b/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/SparkDpp.java
index fd71add..e4c3a23 100644
--- a/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/SparkDpp.java
+++ b/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/SparkDpp.java
@@ -40,6 +40,7 @@ import org.apache.spark.Partitioner;
import org.apache.spark.TaskContext;
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaRDD;
+import org.apache.spark.api.java.function.FlatMapFunction;
import org.apache.spark.api.java.function.PairFlatMapFunction;
import org.apache.spark.api.java.function.VoidFunction;
import org.apache.spark.sql.Dataset;
@@ -59,6 +60,8 @@ import org.apache.spark.util.LongAccumulator;
import org.apache.spark.util.SerializableConfiguration;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
import java.net.URISyntaxException;
@@ -107,6 +110,8 @@ public final class SparkDpp implements java.io.Serializable {
private SerializableConfiguration serializableHadoopConf;
private DppResult dppResult = new DppResult();
+ // just for ut
+ public SparkDpp() {}
public SparkDpp(SparkSession spark, EtlJobConfig etlJobConfig) {
this.spark = spark;
@@ -180,6 +185,8 @@ public final class SparkDpp implements java.io.Serializable {
long tableId,
EtlJobConfig.EtlIndex indexMeta,
SparkRDDAggregator[] sparkRDDAggregators) throws SparkDppException {
+ // TODO(wb) should deal largint as BigInteger instead of string when using biginteger as key,
+ // data type may affect sorting logic
StructType dstSchema = DppUtils.createDstTableSchema(indexMeta.columns, false, true);
ExpressionEncoder encoder = RowEncoder.apply(dstSchema);
@@ -359,12 +366,49 @@ public final class SparkDpp implements java.io.Serializable {
return Pair.of(keyMap.toArray(new Integer[keyMap.size()]), valueMap.toArray(new Integer[valueMap.size()]));
}
- // repartition dataframe by partitionid_bucketid
- // so data in the same bucket will be consecutive.
- private JavaPairRDD<List<Object>, Object[]> fillTupleWithPartitionColumn(SparkSession spark, Dataset<Row> dataframe,
+ /**
+ * check decimal,char/varchar
+ */
+ public boolean validateData(Object srcValue, EtlJobConfig.EtlColumn etlColumn, ColumnParser columnParser, Row row) {
+
+ switch (etlColumn.columnType.toUpperCase()) {
+ case "DECIMALV2":
+ // TODO(wb): support decimal round; see be DecimalV2Value::round
+ DecimalParser decimalParser = (DecimalParser) columnParser;
+ BigDecimal srcBigDecimal = (BigDecimal) srcValue;
+ if (srcValue != null && (decimalParser.getMaxValue().compareTo(srcBigDecimal) < 0 || decimalParser.getMinValue().compareTo(srcBigDecimal) > 0)) {
+ LOG.warn(String.format("decimal value is not valid for defination, column=%s, value=%s,precision=%s,scale=%s",
+ etlColumn.columnName, srcValue.toString(), srcBigDecimal.precision(), srcBigDecimal.scale()));
+ return false;
+ }
+ break;
+ case "CHAR":
+ case "VARCHAR":
+ // TODO(wb) padding char type
+ try {
+ int strSize = 0;
+ if (srcValue != null && (strSize = srcValue.toString().getBytes("UTF-8").length) > etlColumn.stringLength) {
+ LOG.warn(String.format("the length of input is too long than schema. column_name:%s,input_str[%s],schema length:%s,actual length:%s",
+ etlColumn.columnName, row.toString(), etlColumn.stringLength, strSize));
+ return false;
+ }
+ } catch (UnsupportedEncodingException e) {
+ LOG.warn("input string value can not encode with utf-8,value=" + srcValue.toString());
+ return false;
+ }
+ break;
+ }
+ return true;
+ }
+
+ /**
+ * 1 project column and reorder column
+ * 2 validate data
+ * 3 fill tuple with partition column
+ */
+ private JavaPairRDD<List<Object>, Object[]> fillTupleWithPartitionColumn(Dataset<Row> dataframe,
EtlJobConfig.EtlPartitionInfo partitionInfo,
List<Integer> partitionKeyIndex,
- List<Class> partitionKeySchema,
List<DorisRangePartitioner.PartitionRangeKey> partitionRangeKeys,
List<String> keyColumnNames,
List<String> valueColumnNames,
@@ -385,25 +429,42 @@ public final class SparkDpp implements java.io.Serializable {
}
}
}
+
+ List<ColumnParser> parsers = new ArrayList<>();
+ for (EtlJobConfig.EtlColumn column : baseIndex.columns) {
+ parsers.add(ColumnParser.create(column));
+ }
+
// use PairFlatMapFunction instead of PairMapFunction because the there will be
// 0 or 1 output row for 1 input row
JavaPairRDD<List<Object>, Object[]> resultPairRDD = dataframe.toJavaRDD().flatMapToPair(new PairFlatMapFunction<Row, List<Object>, Object[]>() {
@Override
public Iterator<Tuple2<List<Object>, Object[]>> call(Row row) throws Exception {
+ List<Tuple2<List<Object>, Object[]>> result = new ArrayList<>();
List<Object> keyColumns = new ArrayList<>();
- Object[] valueColumns = new Object[valueColumnNames.size()];
- for (String columnName : keyColumnNames) {
+ List<Object> valueColumns = new ArrayList<>(valueColumnNames.size());
+ for (int i = 0; i < keyColumnNames.size(); i++) {
+ String columnName = keyColumnNames.get(i);
Object columnObject = row.get(row.fieldIndex(columnName));
+ if(!validateData(columnObject, baseIndex.getColumn(columnName), parsers.get(i), row)) {
+ abnormalRowAcc.add(1);
+ return result.iterator();
+ };
keyColumns.add(columnObject);
}
for (int i = 0; i < valueColumnNames.size(); i++) {
- valueColumns[i] = row.get(row.fieldIndex(valueColumnNames.get(i)));
+ String columnName = valueColumnNames.get(i);
+ Object columnObject = row.get(row.fieldIndex(columnName));
+ if(!validateData(columnObject, baseIndex.getColumn(columnName), parsers.get(i + keyColumnNames.size()),row)) {
+ abnormalRowAcc.add(1);
+ return result.iterator();
+ };
+ valueColumns.add(columnObject);
}
DppColumns key = new DppColumns(keyColumns);
int pid = partitioner.getPartition(key);
- List<Tuple2<List<Object>, Object[]>> result = new ArrayList<>();
if (!validPartitionIndex.contains(pid)) {
LOG.warn("invalid partition for row:" + row + ", pid:" + pid);
abnormalRowAcc.add(1);
@@ -414,6 +475,7 @@ public final class SparkDpp implements java.io.Serializable {
LOG.info("invalid rows contents:" + invalidRows.value());
}
} else {
+ // TODO(wb) support lagreint for hash
long hashValue = DppUtils.getHashValue(row, distributeColumns, dstTableSchema);
int bucketId = (int) ((hashValue & 0xffffffff) % partitionInfo.partitions.get(pid).bucketNum);
long partitionId = partitionInfo.partitions.get(pid).partitionId;
@@ -423,7 +485,7 @@ public final class SparkDpp implements java.io.Serializable {
List<Object> tuple = new ArrayList<>();
tuple.add(bucketKey);
tuple.addAll(keyColumns);
- result.add(new Tuple2<>(tuple, valueColumns));
+ result.add(new Tuple2<>(tuple, valueColumns.toArray()));
}
return result.iterator();
}
@@ -508,17 +570,6 @@ public final class SparkDpp implements java.io.Serializable {
dataframe = dataframe.withColumn(mappingColumn,
functions.expr(mappingDescription).cast(dstTableSchema.apply(mappingColumn).dataType()));
}
- // projection and reorder the columns
- dataframe.createOrReplaceTempView("src_table");
- StringBuilder selectSqlBuilder = new StringBuilder();
- selectSqlBuilder.append("select ");
- for (String name : dstColumnNames) {
- selectSqlBuilder.append(name + ",");
- }
- selectSqlBuilder.deleteCharAt(selectSqlBuilder.length() - 1);
- selectSqlBuilder.append(" from src_table");
- String selectSql = selectSqlBuilder.toString();
- dataframe = spark.sql(selectSql);
return dataframe;
}
@@ -588,7 +639,8 @@ public final class SparkDpp implements java.io.Serializable {
int index = dstColumnNameToIndex.get(srcColumnName);
String type = columns.get(index).columnType;
if (type.equalsIgnoreCase("CHAR")
- || type.equalsIgnoreCase("VARCHAR")) {
+ || type.equalsIgnoreCase("VARCHAR")
+ || fileGroup.columnMappings.containsKey(field.name())) {
continue;
}
ColumnParser parser = parsers.get(index);
@@ -675,6 +727,9 @@ public final class SparkDpp implements java.io.Serializable {
} else if (dstClass.equals(Long.class)) {
return ((Double) srcValue).longValue();
} else if (dstClass.equals(BigInteger.class)) {
+ // TODO(wb) gson will cast origin value to double by default
+ // when the partition column is largeint, this will cause error data
+ // need fix it thoroughly
return new BigInteger(((Double) srcValue).toString());
} else if (dstClass.equals(java.sql.Date.class) || dstClass.equals(java.util.Date.class)) {
double srcValueDouble = (double)srcValue;
@@ -800,10 +855,78 @@ public final class SparkDpp implements java.io.Serializable {
});
sql.deleteCharAt(sql.length() - 1).append(" from ").append(hiveDbTableName);
Dataset<Row> dataframe = spark.sql(sql.toString());
+ dataframe = checkDataFromHiveWithStrictMode(dataframe, baseIndex, fileGroup.columnMappings.keySet(), etlJobConfig.properties.strictMode,
+ dstTableSchema);
dataframe = convertSrcDataframeToDstDataframe(baseIndex, dataframe, dstTableSchema, fileGroup);
return dataframe;
}
+ private Dataset<Row> checkDataFromHiveWithStrictMode(
+ Dataset<Row> dataframe, EtlJobConfig.EtlIndex baseIndex, Set<String> mappingColKeys, boolean isStrictMode, StructType dstTableSchema) throws SparkDppException {
+ List<EtlJobConfig.EtlColumn> columnNameNeedCheckArrayList = new ArrayList<>();
+ List<ColumnParser> columnParserArrayList = new ArrayList<>();
+ for (EtlJobConfig.EtlColumn column : baseIndex.columns) {
+ if (!StringUtils.equalsIgnoreCase(column.columnType, "varchar") &&
+ !StringUtils.equalsIgnoreCase(column.columnType, "char") &&
+ !mappingColKeys.contains(column.columnName)) {
+ columnNameNeedCheckArrayList.add(column);
+ columnParserArrayList.add(ColumnParser.create(column));
+ }
+ }
+
+ ColumnParser[] columnParserArray = columnParserArrayList.toArray(new ColumnParser[columnParserArrayList.size()]);
+ EtlJobConfig.EtlColumn[] columnNameArray = columnNameNeedCheckArrayList.toArray(new EtlJobConfig.EtlColumn[columnNameNeedCheckArrayList.size()]);
+
+ JavaRDD<Row> result = dataframe.toJavaRDD().flatMap(new FlatMapFunction<Row, Row>() {
+ @Override
+ public Iterator<Row> call(Row row) throws Exception {
+ List<Row> result = new ArrayList<>();
+ Set<Integer> columnIndexNeedToRepalceNull = new HashSet<Integer>();
+ boolean validRow = true;
+ for (int i = 0; i < columnNameArray.length; i++) {
+ EtlJobConfig.EtlColumn column = columnNameArray[i];
+ int fieldIndex = row.fieldIndex(column.columnName);
+ Object value = row.get(fieldIndex);
+ if (value == null && !column.isAllowNull) {
+ validRow = false;
+ LOG.warn("column:" + i + " can not be null. row:" + row.toString());
+ break;
+ }
+ if (value != null && !columnParserArray[i].parse(value.toString())) {
+ if (isStrictMode) {
+ validRow = false;
+ LOG.warn(String.format("row parsed failed in strict mode, column name %s, src row %s", column.columnName, row.toString()));
+ } else {
+ columnIndexNeedToRepalceNull.add(fieldIndex);
+ }
+ }
+ }
+ if (!validRow) {
+ abnormalRowAcc.add(1);
+ // at most add 5 rows to invalidRows
+ if (abnormalRowAcc.value() <= 5) {
+ invalidRows.add(row.toString());
+ }
+ } if (columnIndexNeedToRepalceNull.size() != 0) {
+ Object[] newRow = new Object[row.size()];
+ for (int i = 0; i < row.size(); i++) {
+ if (columnIndexNeedToRepalceNull.contains(i)) {
+ newRow[i] = null;
+ } else {
+ newRow[i] = row.get(i);
+ }
+ }
+ result.add(RowFactory.create(newRow));
+ } else {
+ result.add(row);
+ }
+ return result.iterator();
+ }
+ });
+
+ return spark.createDataFrame(result, dstTableSchema);
+ }
+
private void process() throws Exception {
try {
for (Map.Entry<Long, EtlJobConfig.EtlTable> entry : etlJobConfig.tables.entrySet()) {
@@ -872,9 +995,10 @@ public final class SparkDpp implements java.io.Serializable {
unselectedRowAcc.add(currentSize - originalSize);
}
- JavaPairRDD<List<Object>, Object[]> ret = fillTupleWithPartitionColumn(spark, fileGroupDataframe,
+ JavaPairRDD<List<Object>, Object[]> ret = fillTupleWithPartitionColumn(
+ fileGroupDataframe,
partitionInfo, partitionKeyIndex,
- partitionKeySchema, partitionRangeKeys,
+ partitionRangeKeys,
keyColumnNames, valueColumnNames,
dstTableSchema, baseIndex, fileGroup.partitions);
if (tablePairRDD == null) {
diff --git a/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/SparkRDDAggregator.java b/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/SparkRDDAggregator.java
index 4682fdc..7f1d030 100644
--- a/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/SparkRDDAggregator.java
+++ b/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/SparkRDDAggregator.java
@@ -32,6 +32,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.Serializable;
+import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Comparator;
@@ -52,7 +53,6 @@ public abstract class SparkRDDAggregator<T> implements Serializable {
return value;
};
- // TODO(wb) support more datatype:decimal,date,datetime
public static SparkRDDAggregator buildAggregator(EtlJobConfig.EtlColumn column) throws SparkDppException {
String aggType = StringUtils.lowerCase(column.aggregationType);
String columnType = StringUtils.lowerCase(column.columnType);
@@ -69,6 +69,9 @@ public abstract class SparkRDDAggregator<T> implements Serializable {
case "bigint":
case "float":
case "double":
+ case "decimalv2":
+ case "date":
+ case "datetime":
return new NumberMaxAggregator();
case "char":
case "varchar":
@@ -86,6 +89,9 @@ public abstract class SparkRDDAggregator<T> implements Serializable {
case "bigint":
case "float":
case "double":
+ case "decimalv2":
+ case "date":
+ case "datetime":
return new NumberMinAggregator();
case "char":
case "varchar":
@@ -111,6 +117,8 @@ public abstract class SparkRDDAggregator<T> implements Serializable {
return new DoubleSumAggregator();
case "largeint":
return new LargeIntSumAggregator();
+ case "decimalv2":
+ return new BigDecimalSumAggregator();
default:
throw new SparkDppException(String.format("unsupported sum aggregator for column type:%s", columnType));
}
@@ -324,6 +332,12 @@ class LargeIntMaxAggregator extends SparkRDDAggregator<BigInteger> {
}
return dst.compareTo(src) > 0 ? dst : src;
}
+
+ @Override
+ String finalize(Object value) {
+ BigInteger bigInteger = (BigInteger) value;
+ return bigInteger.toString();
+ }
}
class LargeIntMinAggregator extends LargeIntMaxAggregator {
@@ -394,7 +408,6 @@ class LongSumAggregator extends SparkRDDAggregator<Long> {
if (dst == null) {
return src;
}
- // TODO(wb) check overflow of long type
return dst + src;
}
}
@@ -409,11 +422,9 @@ class ShortSumAggregator extends SparkRDDAggregator<Short> {
if (dst == null) {
return src;
}
- Integer ret = dst + src;
- if (ret > Short.MAX_VALUE || ret < Short.MIN_VALUE) {
- throw new RuntimeException("short column sum size exceeds Short.MAX_VALUE or Short.MIN_VALUE");
- }
- return Short.valueOf(ret.toString());
+ int ret = dst + src;
+ // here may overflow, just keep the same logic with be
+ return (short)ret;
}
}
@@ -428,9 +439,7 @@ class IntSumAggregator extends SparkRDDAggregator<Integer> {
return src;
}
long ret = Long.sum(dst, src);
- if (ret > Integer.MAX_VALUE || ret < Integer.MIN_VALUE) {
- throw new RuntimeException("int column sum size exceeds Integer.MAX_VALUE or Integer.MIN_VALUE");
- }
+ // here may overflow, just keep the same logic with be
return (int) ret;
}
}
@@ -445,11 +454,9 @@ class ByteSumAggregator extends SparkRDDAggregator<Byte> {
if (dst == null) {
return src;
}
- Integer ret = dst + src;
- if (ret > Byte.MAX_VALUE || ret < Byte.MIN_VALUE) {
- throw new RuntimeException("byte column sum size exceeds Byte.MAX_VALUE or Byte.MIN_VALUE");
- }
- return Byte.valueOf(ret.toString());
+ int ret = dst + src;
+ // here may overflow, just keep the same logic with be
+ return (byte)ret;
}
}
@@ -467,7 +474,6 @@ class DoubleSumAggregator extends SparkRDDAggregator<Double> {
}
}
-// TODO(wb) add bound check for float/double
class FloatSumAggregator extends SparkRDDAggregator<Float> {
@Override
@@ -510,6 +516,21 @@ class StringMinAggregator extends SparkRDDAggregator<String> {
}
}
+class BigDecimalSumAggregator extends SparkRDDAggregator<BigDecimal> {
+
+
+ @Override
+ BigDecimal update(BigDecimal src, BigDecimal dst) {
+ if (src == null) {
+ return dst;
+ }
+ if (dst == null) {
+ return src;
+ }
+ return src.add(dst);
+ }
+}
+
class BucketComparator implements Comparator<List<Object>>, Serializable {
diff --git a/fe/spark-dpp/src/test/java/org/apache/doris/load/loadv2/dpp/ColumnParserTest.java b/fe/spark-dpp/src/test/java/org/apache/doris/load/loadv2/dpp/ColumnParserTest.java
new file mode 100644
index 0000000..cfb4122
--- /dev/null
+++ b/fe/spark-dpp/src/test/java/org/apache/doris/load/loadv2/dpp/ColumnParserTest.java
@@ -0,0 +1,135 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+package org.apache.doris.load.loadv2.dpp;
+
+import org.apache.doris.load.loadv2.etl.EtlJobConfig;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ColumnParserTest {
+
+ // TODO(wb) try to keep ut consistent with be's ut
+ @Test
+ public void testBoundCheck() {
+ // tinyint
+ TinyIntParser tinyIntParser = new TinyIntParser();
+ // 1 normal
+ String tinyint = "100";
+ Assert.assertTrue(tinyIntParser.parse(tinyint));
+ // 2 upper
+ String tinyintUpper = "128";
+ Assert.assertFalse(tinyIntParser.parse(tinyintUpper));
+ // 3 lower
+ String tinyintLower = "-129";
+ Assert.assertFalse(tinyIntParser.parse(tinyintLower));
+
+ // smallint
+ SmallIntParser smallIntParser = new SmallIntParser();
+ // 1 normal
+ String smallint = "100";
+ Assert.assertTrue(smallIntParser.parse(smallint));
+ // 2 upper
+ String smallintUpper = "32768";
+ Assert.assertFalse(smallIntParser.parse(smallintUpper));
+ // 3 lower
+ String smallintLower = "-32769";
+ Assert.assertFalse(smallIntParser.parse(smallintLower));
+
+ // int
+ IntParser intParser = new IntParser();
+ // 1 normal
+ String intValue = "100";
+ Assert.assertTrue(intParser.parse(intValue));
+ // 2 upper
+ String intUpper = "2147483648";
+ Assert.assertFalse(intParser.parse(intUpper));
+ // 3 lower
+ String intLower = "-2147483649";
+ Assert.assertFalse(intParser.parse(intLower));
+
+ // bigint
+ BigIntParser bigIntParser = new BigIntParser();
+ // 1 normal
+ String bigint = "100";
+ Assert.assertTrue(bigIntParser.parse(bigint));
+ // 2 upper
+ String bigintUpper = "9223372036854775808";
+ Assert.assertFalse(bigIntParser.parse(bigintUpper));
+ // 3 lower
+ String bigintLower = "-9223372036854775809";
+ Assert.assertFalse(bigIntParser.parse(bigintLower));
+
+ // largeint
+ LargeIntParser largeIntParser = new LargeIntParser();
+ // 1 normal
+ String largeint = "100";
+ Assert.assertTrue(largeIntParser.parse(largeint));
+ // 2 upper
+ String largeintUpper = "170141183460469231731687303715884105728";
+ Assert.assertFalse(largeIntParser.parse(largeintUpper));
+ // 3 lower
+ String largeintLower = "-170141183460469231731687303715884105729";
+ Assert.assertFalse(largeIntParser.parse(largeintLower));
+
+ // float
+ FloatParser floatParser = new FloatParser();
+ // normal
+ String floatValue = "1.1";
+ Assert.assertTrue(floatParser.parse(floatValue));
+ // inf
+ String inf = "Infinity";
+ Assert.assertFalse(floatParser.parse(inf));
+ // nan
+ String nan = "NaN";
+ // failed
+ Assert.assertFalse(floatParser.parse(nan));
+
+ // double
+ DoubleParser doubleParser = new DoubleParser();
+ // normal
+ Assert.assertTrue(doubleParser.parse(floatValue));
+ // inf
+ Assert.assertFalse(doubleParser.parse(inf));
+ // nan
+ Assert.assertFalse(doubleParser.parse(nan));
+
+ // decimal
+ EtlJobConfig.EtlColumn etlColumn = new EtlJobConfig.EtlColumn();
+ etlColumn.precision = 5;
+ etlColumn.scale = 3;
+ DecimalParser decimalParser = new DecimalParser(etlColumn);
+ // normal
+ String decimalValue = "10.333";
+ Assert.assertTrue(decimalParser.parse(decimalValue));
+ // overflow
+ String decimalOverflow = "1000.3333333333";
+ Assert.assertFalse(decimalParser.parse(decimalOverflow));
+
+ // string
+ EtlJobConfig.EtlColumn stringColumn = new EtlJobConfig.EtlColumn();
+ stringColumn.stringLength = 3;
+ StringParser stringParser = new StringParser(stringColumn);
+ // normal
+ String stringnormal = "a";
+ Assert.assertTrue(stringParser.parse(stringnormal));
+ // overflow
+ String stringoverflow = "中文";
+ Assert.assertFalse(stringParser.parse(stringoverflow));
+ }
+
+}
diff --git a/fe/spark-dpp/src/test/java/org/apache/doris/load/loadv2/dpp/SparkDppTest.java b/fe/spark-dpp/src/test/java/org/apache/doris/load/loadv2/dpp/SparkDppTest.java
new file mode 100644
index 0000000..9cec220
--- /dev/null
+++ b/fe/spark-dpp/src/test/java/org/apache/doris/load/loadv2/dpp/SparkDppTest.java
@@ -0,0 +1,67 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+package org.apache.doris.load.loadv2.dpp;
+
+import org.apache.doris.load.loadv2.etl.EtlJobConfig;
+import org.apache.spark.sql.Row;
+import org.apache.spark.sql.RowFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.math.BigDecimal;
+
+public class SparkDppTest {
+
+ @Test
+ public void testValidateData() {
+ SparkDpp sparkDpp = new SparkDpp();
+
+ // decimal
+ EtlJobConfig.EtlColumn etlColumn = new EtlJobConfig.EtlColumn();
+ etlColumn.columnType = "DECIMALV2";
+ etlColumn.precision = 3;
+ etlColumn.scale = 2;
+
+ DecimalParser decimalParser = new DecimalParser(etlColumn);
+ // test max/min
+ Assert.assertTrue(decimalParser.getMaxValue().toString().equals("9.99"));
+ Assert.assertTrue(decimalParser.getMinValue().toString().equals("-9.99"));
+ // normal
+ BigDecimal bigDecimal = new BigDecimal("1.21");
+ Assert.assertTrue(sparkDpp.validateData(bigDecimal, etlColumn, decimalParser, RowFactory.create(bigDecimal)));
+ // failed
+ BigDecimal bigDecimalFailed = new BigDecimal("10");
+ Assert.assertFalse(sparkDpp.validateData(bigDecimalFailed, etlColumn, decimalParser, RowFactory.create(bigDecimalFailed)));
+
+ // string
+ EtlJobConfig.EtlColumn stringColumn = new EtlJobConfig.EtlColumn();
+ stringColumn.stringLength = 3;
+ stringColumn.columnType = "VARCHAR";
+ StringParser stringParser = new StringParser(stringColumn);
+ // normal
+ String normalString = "a1";
+ Assert.assertTrue(sparkDpp.validateData(normalString, stringColumn, stringParser, RowFactory.create(normalString)));
+ // cn normal
+ String normalStringCN = "中";
+ Assert.assertTrue(sparkDpp.validateData(normalStringCN, stringColumn, stringParser, RowFactory.create(normalStringCN)));
+ // cn failed
+ String failedStringCN = "中a";
+ Assert.assertFalse(sparkDpp.validateData(failedStringCN, stringColumn, stringParser, RowFactory.create(failedStringCN)));
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[incubator-doris] 10/10: [compaction][config] Change default config
policy to size_based
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-0.13
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 9d86f66378e349ccd7846c58b0e96d2ecd399e02
Author: chenmingyu <ch...@baidu.com>
AuthorDate: Mon Sep 14 15:50:13 2020 +0800
[compaction][config] Change default config policy to size_based
Change-Id: Id6a1023cb9b4b23bb0714572aeca5d8a0c9ce865
---
be/src/common/config.h | 2 +-
be/src/olap/tablet.cpp | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/be/src/common/config.h b/be/src/common/config.h
index 08151ad..cd16488 100644
--- a/be/src/common/config.h
+++ b/be/src/common/config.h
@@ -273,7 +273,7 @@ namespace config {
// num_based policy, the original version of cumulative compaction, cumulative version compaction once.
// size_based policy, a optimization version of cumulative compaction, targeting the use cases requiring
// lower write amplification, trading off read amplification and space amplification.
- CONF_String(cumulative_compaction_policy, "num_based");
+ CONF_String(cumulative_compaction_policy, "size_based");
// In size_based policy, output rowset of cumulative compaction total disk size exceed this config size,
// this rowset will be given to base compaction, unit is m byte.
diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp
index ea84164..d580611 100644
--- a/be/src/olap/tablet.cpp
+++ b/be/src/olap/tablet.cpp
@@ -445,6 +445,13 @@ void Tablet::delete_expired_stale_rowset() {
std::vector<Version> missed_versions;
calc_missed_versions_unlocked(lastest_delta->end_version(), &missed_versions);
+ if (!missed_versions.empty()) {
+ LOG(WARNING) << "tablet:" << full_name() << ", missed version for version:"
+ << lastest_delta->end_version();
+ _print_missed_versions(missed_versions);
+ return;
+ }
+
// do check consistent operation
auto path_id_iter = path_id_vec.begin();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[incubator-doris] 02/10: [BUG] Fix stale path delete checking logic
when current main path is missing. (#4549)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-0.13
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 4ff6e84cd7586f2929ab61fc23eec526840ff594
Author: ZhangYu0123 <67...@users.noreply.github.com>
AuthorDate: Tue Sep 8 18:52:53 2020 +0800
[BUG] Fix stale path delete checking logic when current main path is missing. (#4549)
Fix stale path delete checking logic.
When current main path is version missing, then delete checking logic is always core dumped. So we fix the checking logic to tolerate current main version missing.
---
be/src/olap/tablet.cpp | 66 +++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 54 insertions(+), 12 deletions(-)
diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp
index e020767..ea84164 100644
--- a/be/src/olap/tablet.cpp
+++ b/be/src/olap/tablet.cpp
@@ -440,6 +440,11 @@ void Tablet::delete_expired_stale_rowset() {
LOG(WARNING) << "lastest_delta is null " << tablet_id();
return;
}
+
+ // fetch missing version before delete
+ std::vector<Version> missed_versions;
+ calc_missed_versions_unlocked(lastest_delta->end_version(), &missed_versions);
+
// do check consistent operation
auto path_id_iter = path_id_vec.begin();
@@ -452,21 +457,58 @@ void Tablet::delete_expired_stale_rowset() {
stale_version_path_map[*path_id_iter] = version_path;
OLAPStatus status = capture_consistent_versions(test_version, nullptr);
- // When there is no consistent versions, we must reconstruct the tracker.
+ // 1. When there is no consistent versions, we must reconstruct the tracker.
if (status != OLAP_SUCCESS) {
- LOG(WARNING) << "The consistent version check fails, there are bugs. "
- << "Reconstruct the tracker to recover versions in tablet=" << tablet_id();
-
- _timestamped_version_tracker.recover_versioned_tracker(stale_version_path_map);
+
+ // 2. fetch missing version after delete
+ std::vector<Version> after_missed_versions;
+ calc_missed_versions_unlocked(lastest_delta->end_version(), &after_missed_versions);
+
+ // 2.1 check whether missed_versions and after_missed_versions are the same.
+ // when they are the same, it means we can delete the path securely.
+ bool is_missng = missed_versions.size() != after_missed_versions.size();
+
+ if (!is_missng) {
+ for (int ver_index = 0; ver_index < missed_versions.size(); ver_index++) {
+ if(missed_versions[ver_index] != after_missed_versions[ver_index]) {
+ is_missng = true;
+ break;
+ }
+ }
+ }
- // double check the consistent versions
- status = capture_consistent_versions(test_version, nullptr);
+ if (is_missng) {
+ LOG(WARNING) << "The consistent version check fails, there are bugs. "
+ << "Reconstruct the tracker to recover versions in tablet=" << tablet_id();
+
+ // 3. try to recover
+ _timestamped_version_tracker.recover_versioned_tracker(stale_version_path_map);
+
+ // 4. double check the consistent versions
+ // fetch missing version after recover
+ std::vector<Version> recover_missed_versions;
+ calc_missed_versions_unlocked(lastest_delta->end_version(), &recover_missed_versions);
+
+ // 4.1 check whether missed_versions and recover_missed_versions are the same.
+ // when they are the same, it means we recover successlly.
+ bool is_recover_missng = missed_versions.size() != recover_missed_versions.size();
+
+ if (!is_recover_missng) {
+ for (int ver_index = 0; ver_index < missed_versions.size(); ver_index++) {
+ if(missed_versions[ver_index] != recover_missed_versions[ver_index]) {
+ is_recover_missng = true;
+ break;
+ }
+ }
+ }
- if (status != OLAP_SUCCESS) {
- if (!config::ignore_rowset_stale_unconsistent_delete) {
- LOG(FATAL) << "rowset stale unconsistent delete. tablet= " << tablet_id();
- } else {
- LOG(WARNING) << "rowset stale unconsistent delete. tablet= " << tablet_id();
+ // 5. check recover fail, version is mission
+ if (is_recover_missng) {
+ if (!config::ignore_rowset_stale_unconsistent_delete) {
+ LOG(FATAL) << "rowset stale unconsistent delete. tablet= " << tablet_id();
+ } else {
+ LOG(WARNING) << "rowset stale unconsistent delete. tablet= " << tablet_id();
+ }
}
}
return;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[incubator-doris] 09/10: [BUG] ReAgg when adding agg mv on dup base
table (#4587)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-0.13
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 3f4110e71b46a57e15fc6792b110d7392270ecb7
Author: EmmyMiao87 <52...@qq.com>
AuthorDate: Sun Sep 13 19:17:35 2020 +0800
[BUG] ReAgg when adding agg mv on dup base table (#4587)
When the keystype of mv and base table is difference, Doris should execute
sorting schema change instead of linked schema change.
If doesn't, the data size of mv actually is same as base table.
This will cause mv to have no pre-aggregation effect at all.
The query will not choose mv.
This commit fixed this problem. Fixed #4586
---
be/src/olap/schema_change.cpp | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/be/src/olap/schema_change.cpp b/be/src/olap/schema_change.cpp
index 3522b1b..81ace25 100644
--- a/be/src/olap/schema_change.cpp
+++ b/be/src/olap/schema_change.cpp
@@ -2090,14 +2090,37 @@ OLAPStatus SchemaChangeHandler::_parse_request(TabletSharedPtr base_tablet,
}
}
+ const TabletSchema& ref_tablet_schema = base_tablet->tablet_schema();
+ const TabletSchema& new_tablet_schema = new_tablet->tablet_schema();
+ if (ref_tablet_schema.keys_type() != new_tablet_schema.keys_type()) {
+ // only when base table is dup and mv is agg
+ // the rollup job must be reagg.
+ *sc_sorting = true;
+ return OLAP_SUCCESS;
+ }
+
+ // If the sort of key has not been changed but the new keys num is less then base's,
+ // the new table should be re agg.
+ // So we also need to set sc_sorting = true.
+ // A, B, C are keys(sort keys), D is value
+ // followings need resort:
+ // old keys: A B C D
+ // new keys: A B
+ if (new_tablet_schema.keys_type() != KeysType::DUP_KEYS
+ && new_tablet->num_key_columns() < base_tablet->num_key_columns()) {
+ // this is a table with aggregate key type, and num of key columns in new schema
+ // is less, which means the data in new tablet should be more aggregated.
+ // so we use sorting schema change to sort and merge the data.
+ *sc_sorting = true;
+ return OLAP_SUCCESS;
+ }
+
if (base_tablet->num_short_key_columns() != new_tablet->num_short_key_columns()) {
// the number of short_keys changed, can't do linked schema change
*sc_directly = true;
return OLAP_SUCCESS;
}
- const TabletSchema& ref_tablet_schema = base_tablet->tablet_schema();
- const TabletSchema& new_tablet_schema = new_tablet->tablet_schema();
for (size_t i = 0; i < new_tablet->num_columns(); ++i) {
ColumnMapping* column_mapping = rb_changer->get_mutable_column_mapping(i);
if (column_mapping->ref_column < 0) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[incubator-doris] 05/10: [Bug] fix get_parsed_paths() subscript out
of range (#4585)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-0.13
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 557b3d4ca67ea20033de60b72f5a3b797ec927f9
Author: HuangWei <hu...@apache.org>
AuthorDate: Sat Sep 12 16:04:21 2020 +0800
[Bug] fix get_parsed_paths() subscript out of range (#4585)
---
be/src/exprs/json_functions.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/be/src/exprs/json_functions.cpp b/be/src/exprs/json_functions.cpp
index 2d9985a..86d1f12 100644
--- a/be/src/exprs/json_functions.cpp
+++ b/be/src/exprs/json_functions.cpp
@@ -371,6 +371,9 @@ void JsonFunctions::parse_json_paths(
void JsonFunctions::get_parsed_paths(
const std::vector<std::string>& path_exprs,
std::vector<JsonPath>* parsed_paths) {
+ if(path_exprs.empty()){
+ return;
+ }
if (path_exprs[0] != "$") {
parsed_paths->emplace_back("", -1, false);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[incubator-doris] 08/10: [SQL][Planner] Fix the the parallesim of
fragment which has 3 or more childern #4569 (#4570)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-0.13
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 53f057797aea5353cdfa6e5c94585b01de383394
Author: wutiangan <wu...@gmail.com>
AuthorDate: Sun Sep 13 19:14:00 2020 +0800
[SQL][Planner] Fix the the parallesim of fragment which has 3 or more childern #4569 (#4570)
fix the the parallelism of fragment which has 3 or more childern
---
.../main/java/org/apache/doris/qe/Coordinator.java | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java b/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
index 60707a0..55c63c6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
@@ -17,7 +17,6 @@
package org.apache.doris.qe;
-import org.apache.commons.collections.map.HashedMap;
import org.apache.doris.analysis.Analyzer;
import org.apache.doris.analysis.DescriptorTable;
import org.apache.doris.catalog.Catalog;
@@ -89,6 +88,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
+import org.apache.commons.collections.map.HashedMap;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.thrift.TException;
@@ -916,7 +916,9 @@ public class Coordinator {
continue;
}
- PlanNode leftMostNode = findLeftmostNode(fragment.getPlanRoot());
+ Pair<PlanNode, PlanNode> pairNodes = findLeftmostNode(fragment.getPlanRoot());
+ PlanNode fatherNode = pairNodes.first;
+ PlanNode leftMostNode = pairNodes.second;
/*
* Case A:
@@ -933,7 +935,11 @@ public class Coordinator {
int inputFragmentIndex = 0;
int maxParallelism = 0;
- for (int j = 0; j < fragment.getChildren().size(); j++) {
+ // If the fragment has three children, then the first child and the second child are the child(both exchange node) of shuffle HashJoinNode,
+ // and the third child is the right child(ExchangeNode) of broadcast HashJoinNode.
+ // We only need to pay attention to the maximum parallelism among the two ExchangeNodes of shuffle HashJoinNode.
+ int childrenCount = (fatherNode != null) ? fatherNode.getChildren().size() : 1;
+ for (int j = 0; j < childrenCount; j++) {
int currentChildFragmentParallelism = fragmentExecParamsMap.get(fragment.getChild(j).getFragmentId()).instanceExecParams.size();
if (currentChildFragmentParallelism > maxParallelism) {
maxParallelism = currentChildFragmentParallelism;
@@ -1071,12 +1077,14 @@ public class Coordinator {
// Returns the id of the leftmost node of any of the gives types in 'plan_root',
// or INVALID_PLAN_NODE_ID if no such node present.
- private PlanNode findLeftmostNode(PlanNode plan) {
+ private Pair<PlanNode, PlanNode> findLeftmostNode(PlanNode plan) {
PlanNode newPlan = plan;
+ PlanNode fatherPlan = null;
while (newPlan.getChildren().size() != 0 && !(newPlan instanceof ExchangeNode)) {
+ fatherPlan = newPlan;
newPlan = newPlan.getChild(0);
}
- return newPlan;
+ return new Pair<PlanNode, PlanNode>(fatherPlan, newPlan);
}
private <K, V> V findOrInsert(HashMap<K, V> m, final K key, final V defaultVal) {
@@ -1701,3 +1709,4 @@ public class Coordinator {
}
}
}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[incubator-doris] 07/10: [Bug]Fix bug that tablet info with wrong
capacity may cause fe oom (#4567)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-0.13
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit f4ba580e21403f2f0fab4a41bb0ad93f34983ca9
Author: caiconghui <55...@users.noreply.github.com>
AuthorDate: Sun Sep 13 19:13:28 2020 +0800
[Bug]Fix bug that tablet info with wrong capacity may cause fe oom (#4567)
* [Bug]Fix bug that tablet info with wrong capacity may cause fe oom
* remove unused code
* fix
* remove empty line
Co-authored-by: caiconghui [蔡聪辉] <ca...@xiaomi.com>
---
.../java/org/apache/doris/qe/ShowExecutor.java | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
index 752b37e..8347b33 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
@@ -1240,7 +1240,7 @@ public class ShowExecutor {
} else {
partitions = olapTable.getPartitions();
}
- List<List<Comparable>> tableInfos = new ArrayList<List<Comparable>>();
+ List<List<Comparable>> tabletInfos = new ArrayList<>();
String indexName = showStmt.getIndexName();
long indexId = -1;
if (indexName != null) {
@@ -1260,18 +1260,18 @@ public class ShowExecutor {
continue;
}
TabletsProcDir procDir = new TabletsProcDir(db, index);
- tableInfos.addAll(procDir.fetchComparableResult(
+ tabletInfos.addAll(procDir.fetchComparableResult(
showStmt.getVersion(), showStmt.getBackendId(), showStmt.getReplicaState()));
- if (sizeLimit > -1 && tableInfos.size() >= sizeLimit) {
+ if (sizeLimit > -1 && tabletInfos.size() >= sizeLimit) {
stop = true;
break;
}
}
}
- if (sizeLimit > -1 && tableInfos.size() < sizeLimit) {
- tableInfos.clear();
+ if (sizeLimit > -1 && tabletInfos.size() < sizeLimit) {
+ tabletInfos.clear();
} else if (sizeLimit > -1) {
- tableInfos = tableInfos.subList((int)showStmt.getOffset(), (int)sizeLimit);
+ tabletInfos = tabletInfos.subList((int)showStmt.getOffset(), (int)sizeLimit);
}
// order by
@@ -1279,15 +1279,15 @@ public class ShowExecutor {
ListComparator<List<Comparable>> comparator = null;
if (orderByPairs != null) {
OrderByPair[] orderByPairArr = new OrderByPair[orderByPairs.size()];
- comparator = new ListComparator<List<Comparable>>(orderByPairs.toArray(orderByPairArr));
+ comparator = new ListComparator<>(orderByPairs.toArray(orderByPairArr));
} else {
// order by tabletId, replicaId
- comparator = new ListComparator<List<Comparable>>(0, 1);
+ comparator = new ListComparator<>(0, 1);
}
- Collections.sort(tableInfos, comparator);
+ Collections.sort(tabletInfos, comparator);
- for (List<Comparable> tabletInfo : tableInfos) {
- List<String> oneTablet = new ArrayList<String>(tableInfos.size());
+ for (List<Comparable> tabletInfo : tabletInfos) {
+ List<String> oneTablet = new ArrayList<String>(tabletInfo.size());
for (Comparable column : tabletInfo) {
oneTablet.add(column.toString());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[incubator-doris] 01/10: [Variable] Add a new global variable
"performance_schema" to support Mysql JDBC 8.0.16 or later.#4537# (#4542)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-0.13
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 782b54a2f3f6dd974d4f7a470409eb01b2fd743e
Author: zhaojintaozhao <49...@users.noreply.github.com>
AuthorDate: Tue Sep 8 09:25:20 2020 +0800
[Variable] Add a new global variable "performance_schema" to support Mysql JDBC 8.0.16 or later.#4537# (#4542)
---
docs/en/administrator-guide/variables.md | 4 ++++
docs/zh-CN/administrator-guide/variables.md | 4 ++++
fe/fe-core/src/main/java/org/apache/doris/qe/GlobalVariable.java | 5 +++++
3 files changed, 13 insertions(+)
diff --git a/docs/en/administrator-guide/variables.md b/docs/en/administrator-guide/variables.md
index 5914df9..1531525 100644
--- a/docs/en/administrator-guide/variables.md
+++ b/docs/en/administrator-guide/variables.md
@@ -318,6 +318,10 @@ SET forward_to_master = concat('tr', 'u', 'e');
* `version`
Used for compatibility with MySQL clients. No practical effect.
+
+* `performance_schema`
+
+ Used for compatibility with MySQL JDBC 8.0.16 or later version. No practical effect.
* `version_comment`
diff --git a/docs/zh-CN/administrator-guide/variables.md b/docs/zh-CN/administrator-guide/variables.md
index 5e780f9..1207334 100644
--- a/docs/zh-CN/administrator-guide/variables.md
+++ b/docs/zh-CN/administrator-guide/variables.md
@@ -317,6 +317,10 @@ SET forward_to_master = concat('tr', 'u', 'e');
* `version`
用于兼容 MySQL 客户端。无实际作用。
+
+* `performance_schema`
+
+ 用于兼容 8.0.16及以上版本的MySQL JDBC。无实际作用。
* `version_comment`
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/GlobalVariable.java b/fe/fe-core/src/main/java/org/apache/doris/qe/GlobalVariable.java
index d122663..0739d98 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/GlobalVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/GlobalVariable.java
@@ -40,6 +40,7 @@ public final class GlobalVariable {
public static final String SYSTEM_TIME_ZONE = "system_time_zone";
public static final String QUERY_CACHE_SIZE = "query_cache_size";
public static final String DEFAULT_ROWSET_TYPE = "default_rowset_type";
+ public static final String PERFORMANCE_SCHEMA = "performance_schema";
@VariableMgr.VarAttr(name = VERSION_COMMENT, flag = VariableMgr.READ_ONLY)
public static String versionComment = "Doris version " + Version.DORIS_BUILD_VERSION;
@@ -74,6 +75,10 @@ public final class GlobalVariable {
@VariableMgr.VarAttr(name = DEFAULT_ROWSET_TYPE, flag = VariableMgr.GLOBAL)
public volatile static String defaultRowsetType = "alpha";
+ // add performance schema to support MYSQL JDBC 8.0.16 or later versions.
+ @VariableMgr.VarAttr(name = PERFORMANCE_SCHEMA, flag = VariableMgr.READ_ONLY)
+ public static String performanceSchema = "OFF";
+
// Don't allow create instance.
private GlobalVariable() {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[incubator-doris] 04/10: [Bug] catch plugin init error for
Reinstall plugin (#4561)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-0.13
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 87e8c22ace9f2d9f60715353a05903b811f65bac
Author: xinghuayu007 <14...@qq.com>
AuthorDate: Sat Sep 12 11:17:46 2020 +0800
[Bug] catch plugin init error for Reinstall plugin (#4561)
---
.../src/main/java/org/apache/doris/plugin/DynamicPluginLoader.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/plugin/DynamicPluginLoader.java b/fe/fe-core/src/main/java/org/apache/doris/plugin/DynamicPluginLoader.java
index 481f363..cfb2c25 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/plugin/DynamicPluginLoader.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/plugin/DynamicPluginLoader.java
@@ -116,8 +116,11 @@ public class DynamicPluginLoader extends PluginLoader {
pluginInstallValid();
pluginContext.setPluginPath(installPath.toString());
-
- plugin.init(pluginInfo, pluginContext);
+ try {
+ plugin.init(pluginInfo, pluginContext);
+ } catch (Error e) {
+ throw new UserException(e.getMessage());
+ }
}
private boolean hasInstalled() {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org