From 4281077d40ab8437bdab1674fb8604d74c974182 Mon Sep 17 00:00:00 2001 From: kaka11chen Date: Sat, 22 Apr 2023 15:12:02 +0800 Subject: [PATCH] [Enhancement](multi-catalogs) Use decimal V3 type in multi-catalogs module. 1. Use decimal V3 type in JDBC and Iceberg tables. 2. Fix hdfs TVF decimal V3 type and regression test. --- .../src/main/java/org/apache/doris/catalog/ScalarType.java | 1 + .../doris/catalog/external/IcebergExternalTable.java | 2 +- .../java/org/apache/doris/external/jdbc/JdbcClient.java | 7 +------ .../correctness_p0/table_valued_function/test_hdfs_tvf.out | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java b/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java index 42cc886e8d4c8a..103c5b59ca43fb 100644 --- a/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java +++ b/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java @@ -137,6 +137,7 @@ public static ScalarType createType(PrimitiveType type, int len, int precision, case DECIMAL32: case DECIMAL64: case DECIMAL128: + return createDecimalV3Type(precision, scale); case DECIMALV2: return createDecimalType(precision, scale); default: diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/external/IcebergExternalTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/external/IcebergExternalTable.java index 43c270ac1793ef..6189e8c6522a12 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/external/IcebergExternalTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/external/IcebergExternalTable.java @@ -87,7 +87,7 @@ private Type icebergPrimitiveTypeToDorisType(org.apache.iceberg.types.Type.Primi return ScalarType.createCharType(fixed.length()); case DECIMAL: Types.DecimalType decimal = (Types.DecimalType) primitive; - return ScalarType.createDecimalType(decimal.precision(), decimal.scale()); + return ScalarType.createDecimalV3Type(decimal.precision(), decimal.scale()); case DATE: return ScalarType.createDateV2Type(); case TIMESTAMP: diff --git a/fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java b/fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java index 15cb5846af182f..08e04321f8e3da 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java +++ b/fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java @@ -23,7 +23,6 @@ import org.apache.doris.catalog.PrimitiveType; import org.apache.doris.catalog.ScalarType; import org.apache.doris.catalog.Type; -import org.apache.doris.common.Config; import org.apache.doris.common.DdlException; import org.apache.doris.common.util.Util; @@ -880,11 +879,7 @@ public Type trinoTypeToDoris(JdbcFieldSchema fieldSchema) { private Type createDecimalOrStringType(int precision, int scale) { if (precision <= ScalarType.MAX_DECIMAL128_PRECISION) { - if (!Config.enable_decimal_conversion && (precision > ScalarType.MAX_DECIMALV2_PRECISION - || scale > ScalarType.MAX_DECIMALV2_SCALE)) { - return ScalarType.createStringType(); - } - return ScalarType.createDecimalType(precision, scale); + return ScalarType.createDecimalV3Type(precision, scale); } return ScalarType.createStringType(); } diff --git a/regression-test/data/correctness_p0/table_valued_function/test_hdfs_tvf.out b/regression-test/data/correctness_p0/table_valued_function/test_hdfs_tvf.out index 12f186616240fa..b8bcccb3cdb1ae 100644 --- a/regression-test/data/correctness_p0/table_valued_function/test_hdfs_tvf.out +++ b/regression-test/data/correctness_p0/table_valued_function/test_hdfs_tvf.out @@ -293,6 +293,6 @@ s_name TEXT Yes false \N NONE s_address TEXT Yes false \N NONE s_nationkey INT Yes false \N NONE s_phone TEXT Yes false \N NONE -s_acctbal DECIMAL(12, 2) Yes false \N NONE +s_acctbal DECIMALV3(12, 2) Yes false \N NONE s_comment TEXT Yes false \N NONE