This is an automated email from the ASF dual-hosted git repository.
liuneng 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 8b43ac728 [GLUTEN-4914][CH] Fix exceptions in ASTParser #4916
8b43ac728 is described below
commit 8b43ac7288db8a9237326b93350a177ab7811182
Author: 李扬 <[email protected]>
AuthorDate: Tue Mar 12 18:20:43 2024 +0800
[GLUTEN-4914][CH] Fix exceptions in ASTParser #4916
What changes were proposed in this pull request?
(Fixes: #4914)
---
cpp-ch/local-engine/Parser/FunctionParser.h | 2 +-
cpp-ch/local-engine/Parser/JoinRelParser.cpp | 2 +-
cpp-ch/local-engine/Parser/RelParser.h | 5 +++--
cpp-ch/local-engine/Parser/SerializedPlanParser.cpp | 7 ++++++-
cpp-ch/local-engine/Parser/SerializedPlanParser.h | 7 +++++--
5 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/cpp-ch/local-engine/Parser/FunctionParser.h
b/cpp-ch/local-engine/Parser/FunctionParser.h
index 0e9eaf07a..36cf9f5ce 100644
--- a/cpp-ch/local-engine/Parser/FunctionParser.h
+++ b/cpp-ch/local-engine/Parser/FunctionParser.h
@@ -49,8 +49,8 @@ public:
const substrait::Expression_ScalarFunction & substrait_func,
DB::ActionsDAGPtr & actions_dag) const;
-protected:
virtual String getCHFunctionName(const
substrait::Expression_ScalarFunction & substrait_func) const;
+protected:
virtual DB::ActionsDAG::NodeRawConstPtrs parseFunctionArguments(
const substrait::Expression_ScalarFunction & substrait_func,
diff --git a/cpp-ch/local-engine/Parser/JoinRelParser.cpp
b/cpp-ch/local-engine/Parser/JoinRelParser.cpp
index 75fd743af..60cc87b74 100644
--- a/cpp-ch/local-engine/Parser/JoinRelParser.cpp
+++ b/cpp-ch/local-engine/Parser/JoinRelParser.cpp
@@ -340,7 +340,7 @@ bool JoinRelParser::tryAddPushDownFilter(
{
try
{
- ASTParser astParser(context, function_mapping);
+ ASTParser astParser(context, function_mapping, getPlanParser());
ASTs args;
if (join.has_expression())
diff --git a/cpp-ch/local-engine/Parser/RelParser.h
b/cpp-ch/local-engine/Parser/RelParser.h
index d74950718..310ab7b5d 100644
--- a/cpp-ch/local-engine/Parser/RelParser.h
+++ b/cpp-ch/local-engine/Parser/RelParser.h
@@ -49,12 +49,13 @@ public:
const String & name, DB::DataTypes arg_types,
DB::AggregateFunctionProperties & properties, const DB::Array & parameters =
{});
protected:
- inline SerializedPlanParser * getPlanParser() { return plan_parser; }
- inline ContextPtr getContext() { return plan_parser->context; }
+ inline SerializedPlanParser * getPlanParser() const { return plan_parser; }
+ inline ContextPtr getContext() const { return plan_parser->context; }
inline String getUniqueName(const std::string & name) { return
plan_parser->getUniqueName(name); }
inline const std::unordered_map<std::string, std::string> &
getFunctionMapping() { return plan_parser->function_mapping; }
+
// Get function signature name.
std::optional<String> parseSignatureFunctionName(UInt32 function_ref);
// Get coresponding function name in ClickHouse.
diff --git a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
index 7bdc80ca8..405f9d6cb 100644
--- a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
+++ b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
@@ -1937,7 +1937,12 @@ ASTPtr ASTParser::parseToAST(const Names & names, const
substrait::Expression &
const auto & scalar_function = rel.scalar_function();
auto function_signature =
function_mapping.at(std::to_string(rel.scalar_function().function_reference()));
- auto function_name =
SerializedPlanParser::getFunctionName(function_signature, scalar_function);
+
+ auto substrait_name = function_signature.substr(0,
function_signature.find(':'));
+ auto func_parser =
FunctionParserFactory::instance().tryGet(substrait_name, plan_parser);
+ String function_name = func_parser ?
func_parser->getCHFunctionName(scalar_function)
+ :
SerializedPlanParser::getFunctionName(function_signature, scalar_function);
+
ASTs ast_args;
parseFunctionArgumentsToAST(names, scalar_function, ast_args);
diff --git a/cpp-ch/local-engine/Parser/SerializedPlanParser.h
b/cpp-ch/local-engine/Parser/SerializedPlanParser.h
index eb247a36b..9988df3d2 100644
--- a/cpp-ch/local-engine/Parser/SerializedPlanParser.h
+++ b/cpp-ch/local-engine/Parser/SerializedPlanParser.h
@@ -447,10 +447,12 @@ private:
class ASTParser
{
public:
- explicit ASTParser(const ContextPtr & _context,
std::unordered_map<std::string, std::string> & _function_mapping)
- : context(_context), function_mapping(_function_mapping)
+ explicit ASTParser(
+ const ContextPtr & context_, std::unordered_map<std::string,
std::string> & function_mapping_, SerializedPlanParser * plan_parser_)
+ : context(context_), function_mapping(function_mapping_),
plan_parser(plan_parser_)
{
}
+
~ASTParser() = default;
ASTPtr parseToAST(const Names & names, const substrait::Expression & rel);
@@ -459,6 +461,7 @@ public:
private:
ContextPtr context;
std::unordered_map<std::string, std::string> function_mapping;
+ SerializedPlanParser * plan_parser;
void parseFunctionArgumentsToAST(const Names & names, const
substrait::Expression_ScalarFunction & scalar_function, ASTs & ast_args);
ASTPtr parseArgumentToAST(const Names & names, const substrait::Expression
& rel);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]