This is an automated email from the ASF dual-hosted git repository.
lichaoyong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 2a2cec9 Adding a column with SUM aggregation to table should restrict
the default value (#5315)
2a2cec9 is described below
commit 2a2cec91f9c98db1e6ee4663ca08cfa4a92e61be
Author: lichaoyong <[email protected]>
AuthorDate: Fri Feb 5 18:50:04 2021 +0800
Adding a column with SUM aggregation to table should restrict the default
value (#5315)
One Tablet have three replicas, the compaction progress is different.
Considering the following scenario, replica A have 3 versions(1, 2, 3);
replica B have 2 versions(1-2, 3);
replica C have 1 versions(1-3).
Now a column named city been added with default zero 1.
Replica A will be resulted as 3, replica B results as 2,
replica C results as 1.
So there is a necessity to restrict the default value to zero for SUM
aggregation column.
---
.../src/main/java/org/apache/doris/alter/SchemaChangeHandler.java | 3 +++
1 file changed, 3 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
index 2428c58..ee9ae4b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
@@ -753,6 +753,9 @@ public class SchemaChangeHandler extends AlterHandler {
throw new DdlException("Can not assign aggregation method on
key column: " + newColName);
} else if (null == newColumn.getAggregationType()) {
newColumn.setIsKey(true);
+ } else if (newColumn.getAggregationType() == AggregateType.SUM
+ && newColumn.getDefaultValue() != null &&
!newColumn.getDefaultValue().equals("0")) {
+ throw new DdlException("The default value of '" + newColName +
"' with SUM aggregation function must be zero");
}
} else if (KeysType.UNIQUE_KEYS == olapTable.getKeysType()) {
if (newColumn.getAggregationType() != null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]