jacktengg commented on code in PR #25386:
URL: https://github.com/apache/doris/pull/25386#discussion_r1368357670
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java:
##########
@@ -99,18 +103,49 @@ public static DecimalV3Type createDecimalV3Type(int
precision) {
/** createDecimalV3Type. */
public static DecimalV3Type createDecimalV3Type(int precision, int scale) {
- Preconditions.checkArgument(precision > 0 && precision <=
MAX_DECIMAL128_PRECISION,
- "precision should in (0, " + MAX_DECIMAL128_PRECISION + "],
but real precision is " + precision);
+ Preconditions.checkArgument(precision > 0 && precision <=
MAX_DECIMAL256_PRECISION,
+ "precision should in (0, " + MAX_DECIMAL256_PRECISION + "],
but real precision is " + precision);
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);
- return new DecimalV3Type(precision, scale);
+ boolean enableDecimal256 =
ConnectContext.get().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.");
+ } else {
+ return new DecimalV3Type(precision, scale);
+ }
}
public static DecimalV3Type createDecimalV3Type(BigDecimal bigDecimal) {
int precision =
org.apache.doris.analysis.DecimalLiteral.getBigDecimalPrecision(bigDecimal);
int scale =
org.apache.doris.analysis.DecimalLiteral.getBigDecimalScale(bigDecimal);
- return createDecimalV3Type(precision, scale);
+ return createDecimalV3TypeLooseCheck(precision, scale);
+ }
+
+ /**
+ * create DecimalV3Type, not throwing NotSupportedException.
+ */
+ public static DecimalV3Type createDecimalV3TypeLooseCheck(int precision,
int scale) {
Review Comment:
`createDecimalV3TypeLooseCheck` is for literal number with precision bigger
than `MAX_DECIMAL128_PRECISION`(e.g. `select 1e39;` ) and
`enable_decimal256=false`, in this case it should throw
`IllegalArgumentException` and fallback to old planner, instead of return an
error.
`createDecimalV3TypeNoCheck` is for `IntersectCount -> DataType.trivialTypes
-> DataType::fromCatalogType`, this is used to initialize function signature
and should not throw exceptions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]