[fix](nereids) cannot collect decimal column stats (#13961)

When execute analyze table, doris fails on decimal columns.
The root cause is the scale in decimalV2 is 9, but 2 in schema.
There is no need to check scale for decimalV2, since it is not a float point type.
This commit is contained in:
minghong
2022-11-10 11:06:38 +08:00
committed by GitHub
parent 184cee2d2b
commit 994d563f52
4 changed files with 11 additions and 4 deletions

View File

@ -348,6 +348,9 @@ public class ColumnDef {
new FloatLiteral(defaultValue);
break;
case DECIMALV2:
//no need to check precision and scale, since V2 is fixed point
new DecimalLiteral(defaultValue);
break;
case DECIMAL32:
case DECIMAL64:
case DECIMAL128:

View File

@ -110,10 +110,10 @@ public class DecimalLiteral extends LiteralExpr {
public void checkPrecisionAndScale(int precision, int scale) throws AnalysisException {
Preconditions.checkNotNull(this.value);
int realPrecision = this.value.precision();
int realScale = this.value.scale();
boolean valid = true;
if (precision != -1 && scale != -1) {
int realPrecision = this.value.precision();
int realScale = this.value.scale();
if (precision < realPrecision || scale < realScale) {
valid = false;
}
@ -122,7 +122,9 @@ public class DecimalLiteral extends LiteralExpr {
}
if (!valid) {
throw new AnalysisException("Invalid precision and scale: " + precision + ", " + scale);
throw new AnalysisException(
String.format("Invalid precision and scale - expect (%d, %d), but (%d, %d)",
precision, scale, realPrecision, realScale));
}
}

View File

@ -407,6 +407,8 @@ public class ColumnStat {
case DOUBLE:
return new FloatLiteral(columnValue);
case DECIMALV2:
//no need to check precision and scale, since V2 is fixed point
return new DecimalLiteral(columnValue);
case DECIMAL32:
case DECIMAL64:
case DECIMAL128:

View File

@ -166,7 +166,7 @@ public class StatisticsTaskScheduler extends MasterDaemon {
} catch (TimeoutException | ExecutionException | InterruptedException
| CancellationException e) {
errorMsg = e.getMessage();
LOG.info("Failed to get statistics. jobId: {}, taskId: {}, e: {}", jobId, taskId, e);
LOG.error("Failed to get statistics. jobId: {}, taskId: {}, e: {}", jobId, taskId, e);
}
try {