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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/ExpressionNormalization.java:
##########
@@ -61,7 +62,8 @@ public class ExpressionNormalization extends 
ExpressionRewrite {
                 SimplifyArithmeticComparisonRule.INSTANCE,
                 ConvertAggStateCast.INSTANCE,
                 MergeDateTrunc.INSTANCE,
-                CheckCast.INSTANCE
+                CheckCast.INSTANCE,
+                JsonFunctionRewrite.INSTANCE

Review Comment:
   add before checkCast



##########
regression-test/suites/query_p0/sql_functions/json_function/test_query_json_array.groovy:
##########
@@ -50,17 +50,38 @@ suite("test_query_json_array", "query") {
     qt_sql_array """ SELECT json_array(array(1,2)); """
     qt_sql_array """ SELECT json_array(array(1.1,2.2)); """
     qt_sql_array """ SELECT json_array(array(1.1,2)); """
-    qt_sql_array """ SELECT json_array(array(cast(1 as decimal), cast(1.2 as 
decimal))); """
+    

Review Comment:
   add nagtive case, to test could forfid any type that cannot be processed by 
to_json



##########
regression-test/suites/query_p0/sql_functions/json_function/test_query_json_array.groovy:
##########
@@ -50,17 +50,38 @@ suite("test_query_json_array", "query") {
     qt_sql_array """ SELECT json_array(array(1,2)); """
     qt_sql_array """ SELECT json_array(array(1.1,2.2)); """
     qt_sql_array """ SELECT json_array(array(1.1,2)); """
-    qt_sql_array """ SELECT json_array(array(cast(1 as decimal), cast(1.2 as 
decimal))); """
+    
+    // Disable `enable_fold_constant_by_be`
+    // FIXME: different results with `enable_fold_constant_by_be=1`
+    """
+      ```
+      mysql> SELECT /*+ set_var(enable_fold_constant_by_be=1) */ 
json_array(array(cast(1 as decimal), cast(1.2 as decimal)));
+      +-------------------------------------------------------------+
+      | json_array(array(cast(1 as decimal), cast(1.2 as decimal))) |
+      +-------------------------------------------------------------+
+      | [[1.0,1.2]]                                                 |
+      +-------------------------------------------------------------+
+
+      mysql> SELECT /*+ set_var(enable_fold_constant_by_be=0) */ 
json_array(array(cast(1 as decimal), cast(1.2 as decimal)));
+      +-------------------------------------------------------------+
+      | json_array(array(cast(1 as decimal), cast(1.2 as decimal))) |
+      +-------------------------------------------------------------+
+      | [[1.000000000,1.200000000]]                                 |
+      +-------------------------------------------------------------+
+      ```
+    """
+    qt_sql_array """ SELECT /*+ set_var(enable_fold_constant_by_be=0) */ 
json_array(array(cast(1 as decimal), cast(1.2 as decimal))); """
+
     // map
-    qt_sql_map """ SELECT json_array(map('a', 'b', 'c', 'd')); """
-    qt_sql_map """ SELECT json_array(map('a', 1, 'c', 2)); """
-    qt_sql_map """ SELECT json_array(map('a', 1.1, 'c', 2.2)); """
-    qt_sql_map """ SELECT json_array(map('a', 1.1, 'c', 2)); """
-    qt_sql_map """ SELECT json_array(map('a', cast(1 as decimal), 'c', 
cast(1.2 as decimal))); """
+    qt_sql_map """ SELECT json_array(cast(map('a', 'b', 'c', 'd') as json)); 
"""
+    qt_sql_map """ SELECT json_array(cast(map('a', 1, 'c', 2) as json)); """
+    qt_sql_map """ SELECT json_array(cast(map('a', 1.1, 'c', 2.2) as json)); 
"""
+    qt_sql_map """ SELECT json_array(cast(map('a', 1.1, 'c', 2) as json)); """
+    qt_sql_map """ SELECT /*+ set_var(enable_fold_constant_by_be=0) */ 
json_array(cast(map('a', cast(1 as decimal), 'c', cast(1.2 as decimal)) as 
json)); """
     // struct
     qt_sql_struct """ SELECT json_array(named_struct('name', 'a', 'age', 1)); 
"""
     qt_sql_struct """ SELECT json_array(named_struct('name', 'a', 'age', 
1.1)); """
-    qt_sql_struct """ SELECT json_array(named_struct('name', 'a', 'age', 
cast(1 as decimal))); """
+    qt_sql_struct """ SELECT /*+ set_var(enable_fold_constant_by_be=0) */ 
json_array(named_struct('name', 'a', 'age', cast(1 as decimal))); """

Review Comment:
   why forbid be constant folding?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to