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

changchen 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 171601b97 [GLUTEN-5049][CH] Clean code in substring function parser 
and fix s3 building issue(#5050)
171601b97 is described below

commit 171601b97e07e3d0d69b0c2608b28dcebf268a8b
Author: 李扬 <654010...@qq.com>
AuthorDate: Thu Mar 21 11:31:08 2024 +0800

    [GLUTEN-5049][CH] Clean code in substring function parser and fix s3 
building issue(#5050)
---
 .../Parser/scalar_function_parser/substring.cpp    | 34 ++++++++++------------
 .../Storages/SubstraitSource/ReadBufferBuilder.cpp |  5 +++-
 2 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/cpp-ch/local-engine/Parser/scalar_function_parser/substring.cpp 
b/cpp-ch/local-engine/Parser/scalar_function_parser/substring.cpp
index 2a44c3e38..64c97da80 100644
--- a/cpp-ch/local-engine/Parser/scalar_function_parser/substring.cpp
+++ b/cpp-ch/local-engine/Parser/scalar_function_parser/substring.cpp
@@ -43,27 +43,23 @@ public:
     ActionsDAGPtr & actions_dag) const override
     {
         auto parsed_args = parseFunctionArguments(substrait_func, "", 
actions_dag);
-        if (parsed_args.size() != 2 && parsed_args.size() != 3)
+        if (parsed_args.size() != 3)
             throw Exception(DB::ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, 
"Function {} requires two or three arguments", getName());
-        DB::DataTypePtr start_index_data_type = 
removeNullable(parsed_args[1]->result_type);
-        if (!isInteger(start_index_data_type))
-            throw Exception(DB::ErrorCodes::BAD_ARGUMENTS, "Function {}'s 
second arguments must be int type", getName());
-         /**
-            parse substring(str, start_index, length) as
-            if (start_index == 0)
-                substring(str, 1, length)
-            else
-                substring(str, start_index, length)
+
+        /*
+            parse substring(str, index, length) as
+                substring(str, if(index = 0, 1, index), length)
         */
-        auto * const_zero_node = addColumnToActionsDAG(actions_dag, 
start_index_data_type, Field(0));
-        auto * const_one_node = addColumnToActionsDAG(actions_dag, 
start_index_data_type, Field(1));
-        auto * equals_zero_node = toFunctionNode(actions_dag, "equals", 
{parsed_args[1], const_zero_node});
-        auto * if_node = toFunctionNode(actions_dag, "if", {equals_zero_node, 
const_one_node, parsed_args[1]});
-        const DB::ActionsDAG::Node * substring_func_node;
-        if (parsed_args.size() == 2)
-            substring_func_node = toFunctionNode(actions_dag, "substringUTF8", 
{parsed_args[0], if_node});
-        else
-            substring_func_node = toFunctionNode(actions_dag, "substringUTF8", 
{parsed_args[0], if_node, parsed_args[2]});
+        const auto * str_arg = parsed_args[0];
+        const auto * index_arg = parsed_args[1];
+        const auto * length_arg = parsed_args[2];
+
+        auto index_type = std::make_shared<DB::DataTypeInt32>();
+        const auto * const_zero_node = addColumnToActionsDAG(actions_dag, 
index_type, 0);
+        const auto * const_one_node = addColumnToActionsDAG(actions_dag, 
index_type, 1);
+        const auto * equals_zero_node = toFunctionNode(actions_dag, "equals", 
{index_arg, const_zero_node});
+        const auto * if_node = toFunctionNode(actions_dag, "if", 
{equals_zero_node, const_one_node, index_arg});
+        const auto * substring_func_node = toFunctionNode(actions_dag, 
"substringUTF8", {str_arg, if_node, length_arg});
         return convertNodeTypeIfNeeded(substrait_func, substring_func_node, 
actions_dag);
     }
 protected:
diff --git a/cpp-ch/local-engine/Storages/SubstraitSource/ReadBufferBuilder.cpp 
b/cpp-ch/local-engine/Storages/SubstraitSource/ReadBufferBuilder.cpp
index f6862ca79..33243c7a0 100644
--- a/cpp-ch/local-engine/Storages/SubstraitSource/ReadBufferBuilder.cpp
+++ b/cpp-ch/local-engine/Storages/SubstraitSource/ReadBufferBuilder.cpp
@@ -32,7 +32,6 @@
 #include <Storages/StorageS3Settings.h>
 #include <Storages/SubstraitSource/ReadBufferBuilder.h>
 #include <Storages/SubstraitSource/SubstraitFileSource.h>
-#include <aws/core/client/DefaultRetryStrategy.h>
 
 #include <sys/stat.h>
 #include <Poco/URI.h>
@@ -49,9 +48,13 @@
 #include <Interpreters/Cache/FileCacheFactory.h>
 #include <Interpreters/Cache/FileCacheSettings.h>
 
+#if USE_AWS_S3
+#include <aws/core/client/DefaultRetryStrategy.h>
 #include <aws/s3/model/CopyObjectRequest.h>
 #include <aws/s3/model/DeleteObjectsRequest.h>
 #include <aws/s3/model/ListObjectsV2Request.h>
+#endif
+
 #include <Common/CHUtil.h>
 
 #include <shared_mutex>


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

Reply via email to