morrySnow commented on code in PR #49416:
URL: https://github.com/apache/doris/pull/49416#discussion_r2011250900


##########
regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_string_arithmatic.groovy:
##########
@@ -1723,5 +1723,13 @@ suite("fold_constant_string_arithmatic") {
     testFoldConst("select split_by_string('a😁a😁a', '')")
     testFoldConst("select character_length('a😁a😁a')")
     testFoldConst("select replace_empty('a😁a😁a', '', '2')")
+

Review Comment:
   add a new file used to check all cast behavior



##########
regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_string_arithmatic.groovy:
##########
@@ -1723,5 +1723,13 @@ suite("fold_constant_string_arithmatic") {
     testFoldConst("select split_by_string('a😁a😁a', '')")
     testFoldConst("select character_length('a😁a😁a')")
     testFoldConst("select replace_empty('a😁a😁a', '', '2')")
+
+    // bug_fix
+    testFoldConst("select concat(substr('2025-03-20',1,4)-1,'-01-01')")
+    testFoldConst("select concat(substr('2025-03-20',1,4)-1.0,'-01-01')")
+    testFoldConst("select concat(substr('2025-03-20',1,4)+1.0,'-01-01')")
+    testFoldConst("select concat(substr('2025-03-20',1,4)-0.5,'-01-01')")
+    testFoldConst("select cast(cast(2025.00 as double) as string)")
+    testFoldConst("select cast(cast(2025.00 as float) as string)")

Review Comment:
   Add other case to ensure that numbers not ending in 0 are processed 
correctly. for example:
   ```
   SELECT CAST(CAST(123 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(123.456 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(-123.456 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(0.001 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(-0.001 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(1e+10 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(1e-10 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(-1e+10 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(-1e-10 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(123456789.123456789 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(-123456789.123456789 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(0 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(0.1 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(-0.1 AS DOUBLE) AS STRING);
   SELECT CAST(CAST(123 AS FLOAT) AS STRING);
   SELECT CAST(CAST(123.456 AS FLOAT) AS STRING);
   SELECT CAST(CAST(-123.456 AS FLOAT) AS STRING);
   SELECT CAST(CAST(0.001 AS FLOAT) AS STRING);
   SELECT CAST(CAST(-0.001 AS FLOAT) AS STRING);
   SELECT CAST(CAST(1e+10 AS FLOAT) AS STRING);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to