This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new 30ba78b9895 branch-4.0: [p0](to_string) add p0 tests for casting int 
and decimal to string #57335 (#57342)
30ba78b9895 is described below

commit 30ba78b989550119a36e875cb303640b6bd0f44a
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Oct 27 16:27:07 2025 +0800

    branch-4.0: [p0](to_string) add p0 tests for casting int and decimal to 
string #57335 (#57342)
    
    Cherry-picked from #57335
    
    Co-authored-by: TengJianPing <[email protected]>
---
 .../test_cast_to_string_from_decimalv3.out         | 73 ++++++++++++++++++++++
 .../to_string/test_cast_to_string_from_int.out     | 59 +++++++++++++++++
 .../test_cast_to_string_from_decimalv3.groovy      | 53 ++++++++++++++++
 .../to_string/test_cast_to_string_from_int.groovy  | 51 +++++++++++++++
 4 files changed, 236 insertions(+)

diff --git 
a/regression-test/data/function_p0/cast/to_string/test_cast_to_string_from_decimalv3.out
 
b/regression-test/data/function_p0/cast/to_string/test_cast_to_string_from_decimalv3.out
new file mode 100644
index 00000000000..036090ab2c1
--- /dev/null
+++ 
b/regression-test/data/function_p0/cast/to_string/test_cast_to_string_from_decimalv3.out
@@ -0,0 +1,73 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !cast_decimal_const --
+0      0.00    0.00
+
+-- !cast_decimal_const --
+-0     0.00    0.00
+
+-- !cast_decimal_const --
+-1.1   -1.10   -1.10
+
+-- !cast_decimal_const --
+1.1    1.10    1.10
+
+-- !cast_decimal_const --
+123.45 123.45  123.45
+
+-- !cast_decimal_const --
+-123.45        -123.45 -123.45
+
+-- !cast_decimal_const --
+2147483647     2147483647.00   2147483647.00
+
+-- !cast_decimal_const --
+-2147483648    -2147483648.00  -2147483648.00
+
+-- !cast_decimal_const --
+9999999999.99  9999999999.99   9999999999.99
+
+-- !cast_decimal_const --
+-9999999999.99 -9999999999.99  -9999999999.99
+
+-- !cast_decimal_const --
+0      0.00    0.00
+
+-- !cast_decimal_const --
+-0     0.00    0.00
+
+-- !cast_decimal_const --
+-1.1   -1.10   -1.10
+
+-- !cast_decimal_const --
+1.1    1.10    1.10
+
+-- !cast_decimal_const --
+123.45 123.45  123.45
+
+-- !cast_decimal_const --
+-123.45        -123.45 -123.45
+
+-- !cast_decimal_const --
+2147483647     2147483647.00   2147483647.00
+
+-- !cast_decimal_const --
+-2147483648    -2147483648.00  -2147483648.00
+
+-- !cast_decimal_const --
+9999999999.99  9999999999.99   9999999999.99
+
+-- !cast_decimal_const --
+-9999999999.99 -9999999999.99  -9999999999.99
+
+-- !sql_decimal_to_string --
+0      0.00    0.00
+1      0.00    0.00
+2      -1.10   -1.10
+3      1.10    1.10
+4      123.45  123.45
+5      -123.45 -123.45
+6      2147483647.00   2147483647.00
+7      -2147483648.00  -2147483648.00
+8      9999999999.99   9999999999.99
+9      -9999999999.99  -9999999999.99
+
diff --git 
a/regression-test/data/function_p0/cast/to_string/test_cast_to_string_from_int.out
 
b/regression-test/data/function_p0/cast/to_string/test_cast_to_string_from_int.out
new file mode 100644
index 00000000000..43d135f1bf1
--- /dev/null
+++ 
b/regression-test/data/function_p0/cast/to_string/test_cast_to_string_from_int.out
@@ -0,0 +1,59 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !cast_int_const --
+0      0       0
+
+-- !cast_int_const --
+-0     0       0
+
+-- !cast_int_const --
+-1     -1      -1
+
+-- !cast_int_const --
+1      1       1
+
+-- !cast_int_const --
+123    123     123
+
+-- !cast_int_const --
+-123   -123    -123
+
+-- !cast_int_const --
+2147483647     2147483647      2147483647
+
+-- !cast_int_const --
+-2147483648    -2147483648     -2147483648
+
+-- !cast_int_const --
+0      0       0
+
+-- !cast_int_const --
+-0     0       0
+
+-- !cast_int_const --
+-1     -1      -1
+
+-- !cast_int_const --
+1      1       1
+
+-- !cast_int_const --
+123    123     123
+
+-- !cast_int_const --
+-123   -123    -123
+
+-- !cast_int_const --
+2147483647     2147483647      2147483647
+
+-- !cast_int_const --
+-2147483648    -2147483648     -2147483648
+
+-- !sql_int_to_string --
+0      0       0
+1      0       0
+2      -1      -1
+3      1       1
+4      123     123
+5      -123    -123
+6      2147483647      2147483647
+7      -2147483648     -2147483648
+
diff --git 
a/regression-test/suites/function_p0/cast/to_string/test_cast_to_string_from_decimalv3.groovy
 
b/regression-test/suites/function_p0/cast/to_string/test_cast_to_string_from_decimalv3.groovy
new file mode 100644
index 00000000000..38fffd971f8
--- /dev/null
+++ 
b/regression-test/suites/function_p0/cast/to_string/test_cast_to_string_from_decimalv3.groovy
@@ -0,0 +1,53 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+
+suite("test_cast_to_string_from_decimalv3") {
+    def decimal_values = [
+        "0", "-0", "-1.1", "1.1", "123.45", "-123.45", "2147483647", 
"-2147483648",
+        "9999999999.99", "-9999999999.99"
+
+    ]
+    for (b in ["false", "true"]) {
+        sql """set debug_skip_fold_constant = "${b}";"""
+        for (test_str in decimal_values) {
+            qt_cast_decimal_const """select "${test_str}", cast("${test_str}" 
as decimalv3(12, 2)), cast(cast("${test_str}" as decimalv3(12, 2)) as 
string);"""
+        }
+    }
+
+    sql """
+        drop table if exists test_cast_to_string_from_decimalv3;
+    """
+    sql """
+        create table test_cast_to_string_from_decimalv3 (
+            k1 int,
+            v1 decimalv3(12, 2)
+        ) properties("replication_num" = "1");
+    """
+    def insert_sql_str_decimal = "insert into 
test_cast_to_string_from_decimalv3 values "
+    def index = 0
+    for (test_str in decimal_values) {
+        insert_sql_str_decimal += """(${index}, "${test_str}"), """
+        index++
+    }
+    insert_sql_str_decimal = insert_sql_str_decimal[0..-3]
+    sql insert_sql_str_decimal
+    qt_sql_decimal_to_string """
+        select k1, v1, cast(v1 as string) from 
test_cast_to_string_from_decimalv3 order by k1;
+    """
+
+}
diff --git 
a/regression-test/suites/function_p0/cast/to_string/test_cast_to_string_from_int.groovy
 
b/regression-test/suites/function_p0/cast/to_string/test_cast_to_string_from_int.groovy
new file mode 100644
index 00000000000..a57c87e3d6b
--- /dev/null
+++ 
b/regression-test/suites/function_p0/cast/to_string/test_cast_to_string_from_int.groovy
@@ -0,0 +1,51 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+
+suite("test_cast_to_string_from_int") {
+    def int_values = [
+        "0", "-0", "-1", "1", "123", "-123", "2147483647", "-2147483648",
+    ]
+    for (b in ["false", "true"]) {
+        sql """set debug_skip_fold_constant = "${b}";"""
+        for (test_str in int_values) {
+            qt_cast_int_const """select "${test_str}", cast("${test_str}" as 
int), cast(cast("${test_str}" as int) as string);"""
+        }
+    }
+
+    sql """
+        drop table if exists test_cast_to_string_from_int;
+    """
+    sql """
+        create table test_cast_to_string_from_int (
+            k1 int,
+            v1 int
+        ) properties("replication_num" = "1");
+    """
+    def insert_sql_str_int = "insert into test_cast_to_string_from_int values "
+    def index = 0
+    for (test_str in int_values) {
+        insert_sql_str_int += """(${index}, "${test_str}"), """
+        index++
+    }
+    insert_sql_str_int = insert_sql_str_int[0..-3]
+    sql insert_sql_str_int
+    qt_sql_int_to_string """
+        select k1, v1, cast(v1 as string) from test_cast_to_string_from_int 
order by k1;
+    """
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to