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

taiyangli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 6ab62fcd6 [GLUTEN-6669][CH] Fix diff of cast string to boolean (#6711)
6ab62fcd6 is described below

commit 6ab62fcd67e16c751d7551486497f4a25b3b5f74
Author: exmy <[email protected]>
AuthorDate: Tue Aug 6 11:06:45 2024 +0800

    [GLUTEN-6669][CH] Fix diff of cast string to boolean (#6711)
---
 .../tpch/GlutenClickHouseTPCHSaltNullParquetSuite.scala        | 10 ++++++++++
 cpp-ch/local-engine/Parser/SerializedPlanParser.cpp            |  8 +++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git 
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/tpch/GlutenClickHouseTPCHSaltNullParquetSuite.scala
 
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/tpch/GlutenClickHouseTPCHSaltNullParquetSuite.scala
index d90330436..0efc1414c 100644
--- 
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/tpch/GlutenClickHouseTPCHSaltNullParquetSuite.scala
+++ 
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/tpch/GlutenClickHouseTPCHSaltNullParquetSuite.scala
@@ -2435,6 +2435,16 @@ class GlutenClickHouseTPCHSaltNullParquetSuite extends 
GlutenClickHouseTPCHAbstr
     }
   }
 
+  test("GLUTEN-6669: test cast string to boolean") {
+    withSQLConf(
+      SQLConf.OPTIMIZER_EXCLUDED_RULES.key -> (ConstantFolding.ruleName + "," 
+ NullPropagation.ruleName)) {
+      runQueryAndCompare(
+        "select cast('1' as boolean), cast('t' as boolean), cast('all' as 
boolean), cast('f' as boolean)",
+        noFallBack = false
+      )(checkGlutenOperatorMatch[ProjectExecTransformer])
+    }
+  }
+
   test("GLUTEN-4032: fix shuffle read coredump after union") {
     val sql =
       """
diff --git a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp 
b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
index bff296de5..d0924a745 100644
--- a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
+++ b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
@@ -1105,6 +1105,7 @@ const ActionsDAG::Node * 
SerializedPlanParser::parseExpression(ActionsDAG& actio
                 throw Exception(ErrorCodes::BAD_ARGUMENTS, "Doesn't have type 
or input in cast node.");
             ActionsDAG::NodeRawConstPtrs args;
 
+            String cast_function = "CAST";
             const auto & input = rel.cast().input();
             args.emplace_back(parseExpression(actions_dag, input));
 
@@ -1144,10 +1145,15 @@ const ActionsDAG::Node * 
SerializedPlanParser::parseExpression(ActionsDAG& actio
                     /// Refer to 
https://github.com/apache/incubator-gluten/issues/4956
                     args[0] = toFunctionNode(actions_dag, "trim", {args[0]});
                 }
+                else if (isString(non_nullable_input_type) && 
substrait_type.has_bool_())
+                {
+                    /// cast(string to boolean)
+                    cast_function = "accurateCastOrNull";
+                }
 
                 /// Common process
                 args.emplace_back(addColumn(actions_dag, 
std::make_shared<DataTypeString>(), output_type->getName()));
-                function_node = toFunctionNode(actions_dag, "CAST", args);
+                function_node = toFunctionNode(actions_dag, cast_function, 
args);
             }
 
             actions_dag.addOrReplaceInOutputs(*function_node);


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

Reply via email to