Skip to content

Commit

Permalink
fix failed case
Browse files Browse the repository at this point in the history
  • Loading branch information
starocean999 committed Nov 18, 2024
1 parent cfe08f3 commit 09cf7f2
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.doris.nereids.types.coercion.CharacterType;
import org.apache.doris.qe.SessionVariable;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;

import java.util.ArrayList;
Expand Down Expand Up @@ -251,21 +252,20 @@ private void checkKeyColumnType(boolean isOlap) {
} else if (type.isArrayType()) {
throw new AnalysisException("Array can only be used in the non-key column of"
+ " the duplicate table at present.");
} else if (type.isBitmapType() || type.isHllType() || type.isQuantileStateType()) {
throw new AnalysisException("Key column can not set complex type:" + name);
} else if (type.isJsonType()) {
throw new AnalysisException("JsonType type should not be used in key column[" + getName() + "].");
} else if (type.isVariantType()) {
throw new AnalysisException("Variant type should not be used in key column[" + getName() + "].");
} else if (type.isMapType()) {
throw new AnalysisException("Map can only be used in the non-key column of"
+ " the duplicate table at present.");
} else if (type.isStructType()) {
throw new AnalysisException("Struct can only be used in the non-key column of"
+ " the duplicate table at present.");
}
}
if (type.isBitmapType() || type.isHllType() || type.isQuantileStateType()) {
throw new AnalysisException("Key column can not set complex type:" + name);
} else if (type.isJsonType()) {
throw new AnalysisException("JsonType type should not be used in key column[" + getName() + "].");
} else if (type.isVariantType()) {
throw new AnalysisException("Variant type should not be used in key column[" + getName() + "].");
} else if (type.isMapType()) {
throw new AnalysisException("Map can only be used in the non-key column of"
+ " the duplicate table at present.");
} else if (type.isStructType()) {
throw new AnalysisException("Struct can only be used in the non-key column of"
+ " the duplicate table at present.");
}
}

/**
Expand Down Expand Up @@ -300,7 +300,13 @@ public void validate(boolean isOlap, Set<String> keysSet, Set<String> clusterKey
throw new AnalysisException("complex type have to use aggregate function: " + name);
}
}
isNullable = false;
if (isNullable) {
throw new AnalysisException("complex type column must be not nullable, column:" + name);
}
}

if (keysSet.contains(name)) {
isKey = true;
}

// check keys type
Expand All @@ -324,6 +330,17 @@ public void validate(boolean isOlap, Set<String> keysSet, Set<String> clusterKey
throw new AnalysisException("agg state not enable, need set enable_agg_state=true");
}
}
} else if (isOlap && !isKey) {
Preconditions.checkState(keysType != null, "keysType is null");
if (keysType.equals(KeysType.DUP_KEYS)) {
aggType = AggregateType.NONE;
} else if (keysType.equals(KeysType.UNIQUE_KEYS) && isEnableMergeOnWrite) {
aggType = AggregateType.NONE;
} else if (!keysType.equals(KeysType.AGG_KEYS)) {
aggType = AggregateType.REPLACE;
} else {
throw new AnalysisException("should set aggregation type to non-key column when in aggregate key");
}
}

if (isOlap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import org.apache.doris.analysis.DefaultValueExprDef;
import org.apache.doris.catalog.ScalarType;
import org.apache.doris.common.util.TimeUtils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
* default value of a column.
Expand Down Expand Up @@ -112,6 +116,29 @@ public String getRawValue() {
* get string value of a default value expression.
*/
public String getValue() {
if (isCurrentTimeStamp()) {
return LocalDateTime.now(TimeUtils.getTimeZone().toZoneId()).toString().replace('T', ' ');
} else if (isCurrentTimeStampWithPrecision()) {
long precision = getCurrentTimeStampPrecision();
String format = "yyyy-MM-dd HH:mm:ss";
if (precision == 0) {
return LocalDateTime.now(TimeUtils.getTimeZone().toZoneId()).toString().replace('T', ' ');
} else if (precision == 1) {
format = "yyyy-MM-dd HH:mm:ss.S";
} else if (precision == 2) {
format = "yyyy-MM-dd HH:mm:ss.SS";
} else if (precision == 3) {
format = "yyyy-MM-dd HH:mm:ss.SSS";
} else if (precision == 4) {
format = "yyyy-MM-dd HH:mm:ss.SSSS";
} else if (precision == 5) {
format = "yyyy-MM-dd HH:mm:ss.SSSSS";
} else if (precision == 6) {
format = "yyyy-MM-dd HH:mm:ss.SSSSSS";
}
return LocalDateTime.now(TimeUtils.getTimeZone().toZoneId())
.format(DateTimeFormatter.ofPattern(format));
}
return value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ public void validate(ConnectContext ctx) throws UserException {
this.opType = AlterOpType.MODIFY_TABLE_PROPERTY_SYNC;
} else if (properties.containsKey(PropertyAnalyzer.ENABLE_UNIQUE_KEY_SKIP_BITMAP_COLUMN)) {
// do nothing, will be analyzed when creating alter job
} else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_STORAGE_PAGE_SIZE)) {
throw new AnalysisException("You can not modify storage_page_size");
} else {
throw new AnalysisException("Unknown table property: " + properties.keySet());
}
Expand Down

0 comments on commit 09cf7f2

Please sign in to comment.