From 039893242cded594df7da0beb29b2cfd1f743c62 Mon Sep 17 00:00:00 2001 From: taiyang-li <654010905@qq.com> Date: Fri, 26 Jul 2024 10:33:29 +0800 Subject: [PATCH] fix issue https://github.com/apache/incubator-gluten/issues/6561 --- .../scalar_function_parser/arrayHighOrderFunctions.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cpp-ch/local-engine/Parser/scalar_function_parser/arrayHighOrderFunctions.cpp b/cpp-ch/local-engine/Parser/scalar_function_parser/arrayHighOrderFunctions.cpp index eacd72ed044fa..e509f12c9a6c7 100644 --- a/cpp-ch/local-engine/Parser/scalar_function_parser/arrayHighOrderFunctions.cpp +++ b/cpp-ch/local-engine/Parser/scalar_function_parser/arrayHighOrderFunctions.cpp @@ -20,6 +20,7 @@ #include #include #include +#include "DataTypes/DataTypeArray.h" #include #include #include @@ -90,7 +91,14 @@ class ArrayTransform : public FunctionParser assert(parsed_args.size() == 2); if (lambda_args.size() == 1) { - return toFunctionNode(actions_dag, ch_func_name, {parsed_args[1], parsed_args[0]}); + /// Convert Array(T) to Array(U) if needed, Array(T) is the type of the first argument of transform. + /// U is the argument type of lambda function. In some cases Array(T) is not equal to Array(U). + /// e.g. in the second query of https://github.com/apache/incubator-gluten/issues/6561, T is String, and U is Nullable(String) + /// The difference of both types will result in runtime exceptions in function capture. + auto dst_array_type = std::make_shared(lambda_args.front().type); + const auto * dst_array_arg = ActionsDAGUtil::convertNodeType(actions_dag, parsed_args[0], dst_array_type->getName()); + std::cout << "actions_dag:" << actions_dag->dumpDAG() << std::endl; + return toFunctionNode(actions_dag, ch_func_name, {parsed_args[1], dst_array_arg}); } /// transform with index argument.