[Cherry-pick](branch-2.1) Pick "[Featrue](default value) Support bitmap_empty default value (#40364)" (#40487)
## Proposed changes Pick #40364 <!--Describe your changes.-->
This commit is contained in:
@ -367,8 +367,10 @@ public class ColumnDef {
|
||||
}
|
||||
|
||||
if (type.getPrimitiveType() == PrimitiveType.BITMAP) {
|
||||
if (defaultValue.isSet && defaultValue != DefaultValue.NULL_DEFAULT_VALUE) {
|
||||
throw new AnalysisException("Bitmap type column can not set default value");
|
||||
if (defaultValue.isSet && defaultValue != DefaultValue.NULL_DEFAULT_VALUE
|
||||
&& !defaultValue.value.equals(DefaultValue.BITMAP_EMPTY_DEFAULT_VALUE.value)) {
|
||||
throw new AnalysisException("Bitmap type column default value only support null or "
|
||||
+ DefaultValue.BITMAP_EMPTY_DEFAULT_VALUE.value);
|
||||
}
|
||||
defaultValue = DefaultValue.BITMAP_EMPTY_DEFAULT_VALUE;
|
||||
}
|
||||
|
||||
@ -2695,6 +2695,8 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
|
||||
}
|
||||
} else if (ctx.CURRENT_DATE() != null) {
|
||||
defaultValue = Optional.of(DefaultValue.CURRENT_DATE_DEFAULT_VALUE);
|
||||
} else if (ctx.BITMAP_EMPTY() != null) {
|
||||
defaultValue = Optional.of(DefaultValue.BITMAP_EMPTY_DEFAULT_VALUE);
|
||||
}
|
||||
}
|
||||
if (ctx.UPDATE() != null) {
|
||||
|
||||
@ -286,13 +286,15 @@ public class ColumnDefinition {
|
||||
}
|
||||
defaultValue = Optional.of(DefaultValue.HLL_EMPTY_DEFAULT_VALUE);
|
||||
} else if (type.isBitmapType()) {
|
||||
if (defaultValue.isPresent() && defaultValue.get() != DefaultValue.NULL_DEFAULT_VALUE) {
|
||||
throw new AnalysisException("Bitmap type column can not set default value");
|
||||
if (defaultValue.isPresent() && isOlap && defaultValue.get() != DefaultValue.NULL_DEFAULT_VALUE
|
||||
&& !defaultValue.get().getValue().equals(DefaultValue.BITMAP_EMPTY_DEFAULT_VALUE.getValue())) {
|
||||
throw new AnalysisException("Bitmap type column default value only support "
|
||||
+ DefaultValue.BITMAP_EMPTY_DEFAULT_VALUE);
|
||||
}
|
||||
defaultValue = Optional.of(DefaultValue.BITMAP_EMPTY_DEFAULT_VALUE);
|
||||
} else if (type.isArrayType() && defaultValue.isPresent() && isOlap
|
||||
&& defaultValue.get() != DefaultValue.NULL_DEFAULT_VALUE && !defaultValue.get()
|
||||
.getValue().equals(DefaultValue.ARRAY_EMPTY_DEFAULT_VALUE.getValue())) {
|
||||
.getValue().equals(DefaultValue.ARRAY_EMPTY_DEFAULT_VALUE.getValue())) {
|
||||
throw new AnalysisException("Array type column default value only support null or "
|
||||
+ DefaultValue.ARRAY_EMPTY_DEFAULT_VALUE);
|
||||
} else if (type.isMapType()) {
|
||||
|
||||
@ -27,6 +27,8 @@ public class DefaultValue {
|
||||
public static String CURRENT_DATE = "CURRENT_DATE";
|
||||
public static String CURRENT_TIMESTAMP = "CURRENT_TIMESTAMP";
|
||||
public static String NOW = "now";
|
||||
public static String HLL_EMPTY = "HLL_EMPTY";
|
||||
public static String BITMAP_EMPTY = "BITMAP_EMPTY";
|
||||
public static DefaultValue CURRENT_DATE_DEFAULT_VALUE = new DefaultValue(CURRENT_DATE, CURRENT_DATE.toLowerCase());
|
||||
public static DefaultValue CURRENT_TIMESTAMP_DEFAULT_VALUE = new DefaultValue(CURRENT_TIMESTAMP, NOW);
|
||||
// default null
|
||||
@ -36,7 +38,7 @@ public class DefaultValue {
|
||||
// default "value", "0" means empty hll
|
||||
public static DefaultValue HLL_EMPTY_DEFAULT_VALUE = new DefaultValue(ZERO);
|
||||
// default "value", "0" means empty bitmap
|
||||
public static DefaultValue BITMAP_EMPTY_DEFAULT_VALUE = new DefaultValue(ZERO);
|
||||
public static DefaultValue BITMAP_EMPTY_DEFAULT_VALUE = new DefaultValue(ZERO, BITMAP_EMPTY);
|
||||
// default "value", "[]" means empty array
|
||||
public static DefaultValue ARRAY_EMPTY_DEFAULT_VALUE = new DefaultValue("[]");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user