Skip to content

Commit

Permalink
fix issue #6561
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyang-li committed Jul 26, 2024
1 parent 874ef56 commit 0398932
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <Poco/Logger.h>
#include <Common/logger_useful.h>
#include <Common/CHUtil.h>
#include "DataTypes/DataTypeArray.h"
#include <DataTypes/DataTypeFunction.h>
#include <DataTypes/DataTypeNullable.h>
#include <Core/Types.h>
Expand Down Expand Up @@ -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<DataTypeArray>(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.
Expand Down

0 comments on commit 0398932

Please sign in to comment.