[Improve](complex-type)improve array/map/struct creating and function with decimalv3 (#19830)
This commit is contained in:
@ -199,6 +199,9 @@ public abstract class Type {
|
||||
mapSubTypes.add(FLOAT);
|
||||
mapSubTypes.add(DOUBLE);
|
||||
mapSubTypes.add(DECIMALV2);
|
||||
mapSubTypes.add(DECIMAL32); // same DEFAULT_DECIMALV3
|
||||
mapSubTypes.add(DECIMAL64);
|
||||
mapSubTypes.add(DECIMAL128);
|
||||
mapSubTypes.add(DATE);
|
||||
mapSubTypes.add(DATETIME);
|
||||
mapSubTypes.add(DATEV2);
|
||||
@ -214,6 +217,9 @@ public abstract class Type {
|
||||
structSubTypes.add(FLOAT);
|
||||
structSubTypes.add(DOUBLE);
|
||||
structSubTypes.add(DECIMALV2);
|
||||
structSubTypes.add(DECIMAL32); // same DEFAULT_DECIMALV3
|
||||
structSubTypes.add(DECIMAL64);
|
||||
structSubTypes.add(DECIMAL128);
|
||||
structSubTypes.add(DATE);
|
||||
structSubTypes.add(DATETIME);
|
||||
structSubTypes.add(DATEV2);
|
||||
@ -341,6 +347,41 @@ public abstract class Type {
|
||||
return isScalarType(PrimitiveType.DECIMALV2);
|
||||
}
|
||||
|
||||
public boolean typeContainsPrecision() {
|
||||
if (PrimitiveType.typeWithPrecision.contains(this.getPrimitiveType())) {
|
||||
return true;
|
||||
} else if (isStructType()) {
|
||||
for (StructField field : ((StructType) this).getFields()) {
|
||||
if (PrimitiveType.typeWithPrecision.contains(field.getType().getPrimitiveType())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (isMapType()) {
|
||||
return PrimitiveType.typeWithPrecision.contains(((MapType) this).getKeyType().getPrimitiveType())
|
||||
|| PrimitiveType.typeWithPrecision.contains(((MapType) this).getValueType().getPrimitiveType());
|
||||
} else if (isArrayType()) {
|
||||
return PrimitiveType.typeWithPrecision.contains(((ArrayType) this).getItemType().getPrimitiveType());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDecimalV3OrContainsDecimalV3() {
|
||||
if (isDecimalV3()) {
|
||||
return true;
|
||||
} else if (isStructType()) {
|
||||
for (StructField field : ((StructType) this).getFields()) {
|
||||
if (field.getType().isDecimalV3()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (isMapType()) {
|
||||
return ((MapType) this).getKeyType().isDecimalV3() || ((MapType) this).getValueType().isDecimalV3();
|
||||
} else if (isArrayType()) {
|
||||
return ((ArrayType) this).getItemType().isDecimalV3();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDecimalV3() {
|
||||
return isScalarType(PrimitiveType.DECIMAL32) || isScalarType(PrimitiveType.DECIMAL64)
|
||||
|| isScalarType(PrimitiveType.DECIMAL128);
|
||||
|
||||
Reference in New Issue
Block a user