diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FloatLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FloatLiteral.java index 1fba4edfb9..ef0493d8e0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FloatLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FloatLiteral.java @@ -137,6 +137,11 @@ public class FloatLiteral extends NumericLiteralExpr { } NumberFormat nf = NumberFormat.getInstance(); nf.setGroupingUsed(false); + if (type == Type.FLOAT) { + nf.setMaximumFractionDigits(7); + } else { + nf.setMaximumFractionDigits(16); + } return nf.format(value); } diff --git a/regression-test/data/nereids_p0/sql_functions/cast_function/test_cast_function.out b/regression-test/data/nereids_p0/sql_functions/cast_function/test_cast_function.out index 25455036ab..f62e9e8675 100644 --- a/regression-test/data/nereids_p0/sql_functions/cast_function/test_cast_function.out +++ b/regression-test/data/nereids_p0/sql_functions/cast_function/test_cast_function.out @@ -17,6 +17,9 @@ -- !sql -- 20 +-- !sql -- +10000.00001 + -- !sql_null_cast_bitmap -- true diff --git a/regression-test/data/query_p0/sql_functions/cast_function/test_cast_function.out b/regression-test/data/query_p0/sql_functions/cast_function/test_cast_function.out index 2958bce0bf..8430f51a8b 100644 --- a/regression-test/data/query_p0/sql_functions/cast_function/test_cast_function.out +++ b/regression-test/data/query_p0/sql_functions/cast_function/test_cast_function.out @@ -17,6 +17,9 @@ -- !sql -- 20 +-- !sql -- +10000.00001 + -- !select1 -- 0 2022-12-01T22:23:24.123 2022-12-01 22:23:24.123 2022-12-01 2022-12-01 2022-12-01 2022-12-01 78.123 78.123 78.12345 78.12345 1 2022-12-01T22:23:24.123 2022-12-01 22:23:24.123456789 2022-12-01 2022-12-01 2022-12-01 2022-12-01 78.123 78.123 78.12345 78.12345 diff --git a/regression-test/suites/nereids_p0/sql_functions/cast_function/test_cast_function.groovy b/regression-test/suites/nereids_p0/sql_functions/cast_function/test_cast_function.groovy index 954c8562a1..9f348449d1 100644 --- a/regression-test/suites/nereids_p0/sql_functions/cast_function/test_cast_function.groovy +++ b/regression-test/suites/nereids_p0/sql_functions/cast_function/test_cast_function.groovy @@ -24,6 +24,7 @@ suite("test_cast_function") { qt_sql """ select cast ("0.0000031417" as datetime) """ qt_sql """ select cast (NULL AS CHAR(1)); """ qt_sql """ select cast ('20190101' AS CHAR(2)); """ + qt_sql """ select cast(cast(10000.00001 as double) as string); """ qt_sql_null_cast_bitmap """ select cast (case when BITMAP_EMPTY() is NULL then null else null end as bitmap) is NULL; """ qt_sql_to_tiny """ select cast('1212.31' as tinyint);""" qt_sql_to_small """ select cast('1212.31' as smallint);""" diff --git a/regression-test/suites/query_p0/sql_functions/cast_function/test_cast_function.groovy b/regression-test/suites/query_p0/sql_functions/cast_function/test_cast_function.groovy index 30a9fbae94..fe85ba43dc 100644 --- a/regression-test/suites/query_p0/sql_functions/cast_function/test_cast_function.groovy +++ b/regression-test/suites/query_p0/sql_functions/cast_function/test_cast_function.groovy @@ -22,6 +22,7 @@ suite("test_cast_function") { qt_sql """ select cast ("0.0000031417" as datetime) """ qt_sql """ select cast (NULL AS CHAR(1)); """ qt_sql """ select cast ('20190101' AS CHAR(2)); """ + qt_sql """ select cast(cast(10000.00001 as double) as string); """ def tableName = "test_cast_function_nullable" sql "DROP TABLE IF EXISTS ${tableName}"