[fix](fe-ut) fix npe of fe ut (#25904)
This commit is contained in:
@ -304,9 +304,14 @@ public class TypeDef implements ParseNode {
|
||||
break;
|
||||
}
|
||||
case DECIMAL256: {
|
||||
SessionVariable sessionVariable = ConnectContext.get().getSessionVariable();
|
||||
boolean enableDecimal256 = sessionVariable.enableDecimal256();
|
||||
boolean enableNereidsPlanner = sessionVariable.isEnableNereidsPlanner();
|
||||
boolean enableNereidsPlanner = false;
|
||||
boolean enableDecimal256 = false;
|
||||
ConnectContext connectContext = ConnectContext.get();
|
||||
if (connectContext != null) {
|
||||
SessionVariable sessionVariable = connectContext.getSessionVariable();
|
||||
enableDecimal256 = sessionVariable.enableDecimal256();
|
||||
enableNereidsPlanner = sessionVariable.isEnableNereidsPlanner();
|
||||
}
|
||||
if (enableNereidsPlanner && enableDecimal256) {
|
||||
int precision = scalarType.decimalPrecision();
|
||||
int scale = scalarType.decimalScale();
|
||||
|
||||
@ -53,7 +53,11 @@ public class Multiply extends BinaryArithmetic implements CheckOverflowNullable
|
||||
int retPercision = t1.getPrecision() + t2.getPrecision();
|
||||
int retScale = t1.getScale() + t2.getScale();
|
||||
if (retPercision > DecimalV3Type.MAX_DECIMAL128_PRECISION) {
|
||||
boolean enableDecimal256 = ConnectContext.get().getSessionVariable().enableDecimal256();
|
||||
boolean enableDecimal256 = false;
|
||||
ConnectContext connectContext = ConnectContext.get();
|
||||
if (connectContext != null) {
|
||||
enableDecimal256 = connectContext.getSessionVariable().enableDecimal256();
|
||||
}
|
||||
if (enableDecimal256) {
|
||||
if (retPercision > DecimalV3Type.MAX_DECIMAL256_PRECISION) {
|
||||
retPercision = DecimalV3Type.MAX_DECIMAL256_PRECISION;
|
||||
|
||||
@ -29,7 +29,11 @@ public interface ComputePrecisionForSum extends ComputePrecision {
|
||||
DataType argumentType = getArgumentType(0);
|
||||
if (signature.getArgType(0) instanceof DecimalV3Type) {
|
||||
DecimalV3Type decimalV3Type = DecimalV3Type.forType(argumentType);
|
||||
boolean enableDecimal256 = ConnectContext.get().getSessionVariable().enableDecimal256();
|
||||
boolean enableDecimal256 = false;
|
||||
ConnectContext connectContext = ConnectContext.get();
|
||||
if (connectContext != null) {
|
||||
enableDecimal256 = connectContext.getSessionVariable().enableDecimal256();
|
||||
}
|
||||
return signature.withArgumentType(0, decimalV3Type)
|
||||
.withReturnType(DecimalV3Type.createDecimalV3Type(
|
||||
enableDecimal256 ? DecimalV3Type.MAX_DECIMAL256_PRECISION
|
||||
|
||||
@ -89,7 +89,11 @@ public class Avg extends NullableAggregateFunction
|
||||
public FunctionSignature computePrecision(FunctionSignature signature) {
|
||||
DataType argumentType = getArgumentType(0);
|
||||
if (signature.getArgType(0) instanceof DecimalV3Type) {
|
||||
boolean enableDecimal256 = ConnectContext.get().getSessionVariable().enableDecimal256();
|
||||
boolean enableDecimal256 = false;
|
||||
ConnectContext connectContext = ConnectContext.get();
|
||||
if (connectContext != null) {
|
||||
enableDecimal256 = connectContext.getSessionVariable().enableDecimal256();
|
||||
}
|
||||
DecimalV3Type decimalV3Type = DecimalV3Type.forType(argumentType);
|
||||
// DecimalV3 scale lower than DEFAULT_MIN_AVG_DECIMAL128_SCALE should do cast
|
||||
int precision = decimalV3Type.getPrecision();
|
||||
|
||||
@ -107,7 +107,11 @@ public class DecimalV3Type extends FractionalType {
|
||||
Preconditions.checkArgument(scale >= 0, "scale should not smaller than 0, but real scale is " + scale);
|
||||
Preconditions.checkArgument(precision >= scale, "precision should not smaller than scale,"
|
||||
+ " but precision is " + precision, ", scale is " + scale);
|
||||
boolean enableDecimal256 = ConnectContext.get().getSessionVariable().enableDecimal256();
|
||||
boolean enableDecimal256 = false;
|
||||
ConnectContext connectContext = ConnectContext.get();
|
||||
if (connectContext != null) {
|
||||
enableDecimal256 = connectContext.getSessionVariable().enableDecimal256();
|
||||
}
|
||||
if (precision > MAX_DECIMAL128_PRECISION && !enableDecimal256) {
|
||||
throw new NotSupportedException("Datatype DecimalV3 with precision " + precision
|
||||
+ ", which is greater than 38 is disabled by default. set enable_decimal256 = true to enable it.");
|
||||
@ -126,7 +130,11 @@ public class DecimalV3Type extends FractionalType {
|
||||
* create DecimalV3Type, not throwing NotSupportedException.
|
||||
*/
|
||||
public static DecimalV3Type createDecimalV3TypeLooseCheck(int precision, int scale) {
|
||||
boolean enableDecimal256 = ConnectContext.get().getSessionVariable().enableDecimal256();
|
||||
boolean enableDecimal256 = false;
|
||||
ConnectContext connectContext = ConnectContext.get();
|
||||
if (connectContext != null) {
|
||||
enableDecimal256 = connectContext.getSessionVariable().enableDecimal256();
|
||||
}
|
||||
if (enableDecimal256) {
|
||||
Preconditions.checkArgument(precision > 0 && precision <= MAX_DECIMAL256_PRECISION,
|
||||
"precision should in (0, " + MAX_DECIMAL256_PRECISION + "], but real precision is " + precision);
|
||||
@ -158,7 +166,11 @@ public class DecimalV3Type extends FractionalType {
|
||||
boolean overflowToDouble) {
|
||||
int scale = Math.max(leftScale, rightScale);
|
||||
int range = Math.max(leftPrecision - leftScale, rightPrecision - rightScale);
|
||||
boolean enableDecimal256 = ConnectContext.get().getSessionVariable().enableDecimal256();
|
||||
boolean enableDecimal256 = false;
|
||||
ConnectContext connectContext = ConnectContext.get();
|
||||
if (connectContext != null) {
|
||||
enableDecimal256 = connectContext.getSessionVariable().enableDecimal256();
|
||||
}
|
||||
if (range + scale > (enableDecimal256 ? MAX_DECIMAL256_PRECISION : MAX_DECIMAL128_PRECISION)
|
||||
&& overflowToDouble) {
|
||||
return DoubleType.INSTANCE;
|
||||
@ -232,7 +244,11 @@ public class DecimalV3Type extends FractionalType {
|
||||
} else if (precision <= MAX_DECIMAL128_PRECISION) {
|
||||
return 16;
|
||||
} else {
|
||||
boolean enableDecimal256 = ConnectContext.get().getSessionVariable().enableDecimal256();
|
||||
boolean enableDecimal256 = false;
|
||||
ConnectContext connectContext = ConnectContext.get();
|
||||
if (connectContext != null) {
|
||||
enableDecimal256 = connectContext.getSessionVariable().enableDecimal256();
|
||||
}
|
||||
if (enableDecimal256) {
|
||||
return 32;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user