[Fix](mutli-catalog) Use decimal v3 type to fix decimal loss issue in multi-catalog module. (#18835)

Fix decimal v3 precision loss issues in the multi-catalog module.
Now it will use decimal v3 to represent decimal type in the multi-catalog module.
Regression Test: `test_load_with_decimal.groovy`
This commit is contained in:
Qi Chen
2023-04-20 11:02:53 +08:00
committed by GitHub
parent ab9500bfa6
commit 3328a65b75
18 changed files with 2918 additions and 2756 deletions

View File

@ -144,6 +144,10 @@ public class Column implements Writable, GsonPostProcessable {
this(name, ScalarType.createType(dataType), isAllowNull);
}
public Column(String name, PrimitiveType dataType, int len, int precision, int scale, boolean isAllowNull) {
this(name, ScalarType.createType(dataType, len, precision, scale), isAllowNull);
}
public Column(String name, Type type, boolean isAllowNull) {
this(name, type, false, null, isAllowNull, null, "");
}

View File

@ -797,7 +797,7 @@ public class HiveMetaStoreClientHelper {
if (match.find()) {
scale = Integer.parseInt(match.group(1));
}
return ScalarType.createDecimalType(precision, scale);
return ScalarType.createDecimalV3Type(precision, scale);
}
return Type.UNSUPPORTED;
}

View File

@ -380,7 +380,9 @@ public abstract class ExternalFileTableValuedFunction extends TableValuedFunctio
// only support ScalarType.
PScalarType scalarType = typeNode.getScalarType();
TPrimitiveType tPrimitiveType = TPrimitiveType.findByValue(scalarType.getType());
columns.add(new Column(colName, PrimitiveType.fromThrift(tPrimitiveType), true));
columns.add(new Column(colName, PrimitiveType.fromThrift(tPrimitiveType),
scalarType.getLen() <= 0 ? -1 : scalarType.getLen(), scalarType.getPrecision(),
scalarType.getScale(), true));
}
}
}
@ -426,3 +428,4 @@ public abstract class ExternalFileTableValuedFunction extends TableValuedFunctio
.setFileScanRange(ByteString.copyFrom(new TSerializer().serialize(fileScanRange))).build();
}
}