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

zhangstar333 pushed a commit to branch revert-43410-fix-1106
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 44eca049e01829319f989cf3d16b13e14c0a54dc
Author: zhangstar333 <2561612...@qq.com>
AuthorDate: Wed Feb 19 17:35:52 2025 +0800

    Revert "[fix](fold) fixed an issue with be computing constants (#43410)"
    
    This reverts commit b515f86669bc118cc03cf9f8332b6397194dc337.
---
 .../rules/expression/rules/FoldConstantRuleOnBE.java    |  12 ++----------
 .../doris/nereids/trees/expressions/LiteralTest.java    |   8 ++------
 .../expression/fold_constant/fold_constant_by_be.out    | Bin 222 -> 132 bytes
 .../expression/fold_constant/fold_constant_by_be.groovy |  11 ++++-------
 4 files changed, 8 insertions(+), 23 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
index 90b044e2b81..ff8fb67b17c 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
@@ -490,16 +490,8 @@ public class FoldConstantRuleOnBE implements 
ExpressionPatternRuleFactory {
         } else if (type.isStringLikeType()) {
             int num = resultContent.getStringValueCount();
             for (int i = 0; i < num; ++i) {
-                // get the raw byte data to avoid character encoding 
conversion problems
-                ByteString bytesValues = resultContent.getBytesValue(i);
-                // use UTF-8 encoding to ensure proper handling of binary data
-                String stringValue = bytesValues.toStringUtf8();
-                // handle special NULL value cases
-                if ("\\N".equalsIgnoreCase(stringValue) && 
resultContent.hasHasNull()) {
-                    res.add(new NullLiteral(type));
-                } else {
-                    res.add(new StringLiteral(stringValue));
-                }
+                Literal literal = new 
StringLiteral(resultContent.getStringValue(i));
+                res.add(literal);
             }
         } else if (type.isArrayType()) {
             ArrayType arrayType = (ArrayType) type;
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/LiteralTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/LiteralTest.java
index 9c7e2e5b151..fcb64ff0bfa 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/LiteralTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/LiteralTest.java
@@ -233,9 +233,7 @@ class LiteralTest {
         PValues.Builder resultContentBuilder = PValues.newBuilder();
         for (int i = 0; i < elementsArray.length; i = i + 2) {
             childBuilder1.addInt32Value(elementsArray[i]);
-            String strValue = "str" + (i + 1);
-            childBuilder2.addStringValue(strValue);
-            
childBuilder2.addBytesValue(com.google.protobuf.ByteString.copyFromUtf8(strValue));
+            childBuilder2.addStringValue("str" + (i + 1));
         }
         childBuilder1.setType(childTypeBuilder1.build());
         childBuilder2.setType(childTypeBuilder2.build());
@@ -282,9 +280,7 @@ class LiteralTest {
         PValues.Builder resultContentBuilder = PValues.newBuilder();
         for (int i = 0; i < elementsArray.length; i = i + 2) {
             childBuilder1.addInt32Value(elementsArray[i]);
-            String strValue = "str" + (i + 1);
-            childBuilder2.addStringValue(strValue);
-            
childBuilder2.addBytesValue(com.google.protobuf.ByteString.copyFromUtf8(strValue));
+            childBuilder2.addStringValue("str" + (i + 1));
         }
         childBuilder1.setType(childTypeBuilder1.build());
         childBuilder2.setType(childTypeBuilder2.build());
diff --git 
a/regression-test/data/nereids_p0/expression/fold_constant/fold_constant_by_be.out
 
b/regression-test/data/nereids_p0/expression/fold_constant/fold_constant_by_be.out
index 8d9d704684e..c7c506292a5 100644
Binary files 
a/regression-test/data/nereids_p0/expression/fold_constant/fold_constant_by_be.out
 and 
b/regression-test/data/nereids_p0/expression/fold_constant/fold_constant_by_be.out
 differ
diff --git 
a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_by_be.groovy
 
b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_by_be.groovy
index f3b1b0cdcd5..09a80209c04 100644
--- 
a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_by_be.groovy
+++ 
b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_by_be.groovy
@@ -22,9 +22,6 @@ suite("fold_constant_by_be") {
     sql 'set enable_fallback_to_original_planner=false'
     sql 'set enable_fold_constant_by_be=true'
 
-    qt_sql """ select hex(from_base64('wr2JEDVXzL9+2XtRhgIloA==')); """
-    qt_sql """ select hex(s) from (select 
from_base64('wr2JEDVXzL9+2XtRhgIloA==') as s) t; """
-
     test {
         sql '''
             select if(
@@ -35,8 +32,8 @@ suite("fold_constant_by_be") {
         result([['9999-07-31']])
     }
 
-    sql """
-        CREATE TABLE IF NOT EXISTS str_tb (k1 VARCHAR(10) NULL, v1 STRING NULL)
+    sql """ 
+        CREATE TABLE IF NOT EXISTS str_tb (k1 VARCHAR(10) NULL, v1 STRING 
NULL) 
         UNIQUE KEY(k1) DISTRIBUTED BY HASH(k1) BUCKETS 5 
properties("replication_num" = "1");
     """
 
@@ -56,7 +53,7 @@ suite("fold_constant_by_be") {
 
     sql 'set query_timeout=12;'
     qt_sql "select sleep(sign(1)*5);"
-
+    
     explain {
         sql("verbose select substring('123456', 1, 3)")
         contains "varchar(3)"
@@ -74,7 +71,7 @@ suite("fold_constant_by_be") {
                     col_varchar_1000__undef_signed varchar(1000)  null  ,
                     col_varchar_1000__undef_signed_not_null varchar(1000)  not 
null  ,
                     col_varchar_1001__undef_signed varchar(1001)  null  ,
-                    col_varchar_1001__undef_signed_not_null varchar(1001)  not 
null
+                    col_varchar_1001__undef_signed_not_null varchar(1001)  not 
null  
                     ) engine=olap
                     DUPLICATE KEY(pk, col_char_255__undef_signed, 
col_char_100__undef_signed)
                     distributed by hash(pk) buckets 10


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

Reply via email to