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 a5daf1c4e [GLUTEN-5957][CH]Fix get_json_object on filter condition
(#5989)
a5daf1c4e is described below
commit a5daf1c4ed59b8123838a50df22f9c744f489d11
Author: KevinyhZou <[email protected]>
AuthorDate: Thu Jun 6 10:41:22 2024 +0800
[GLUTEN-5957][CH]Fix get_json_object on filter condition (#5989)
What changes were proposed in this pull request?
(Please fill in changes proposed in this fix)
(Fixes: #5957)
How was this patch tested?
TEST BY UT
---
.../gluten/execution/GlutenFunctionValidateSuite.scala | 6 ++++++
cpp-ch/local-engine/Parser/FilterRelParser.cpp | 3 +--
cpp-ch/local-engine/Parser/SerializedPlanParser.cpp | 3 ---
cpp-ch/local-engine/Rewriter/ExpressionRewriter.h | 13 ++++++++++++-
4 files changed, 19 insertions(+), 6 deletions(-)
diff --git
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenFunctionValidateSuite.scala
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenFunctionValidateSuite.scala
index a561fe7cb..9327137fa 100644
---
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenFunctionValidateSuite.scala
+++
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenFunctionValidateSuite.scala
@@ -281,6 +281,12 @@ class GlutenFunctionValidateSuite extends
GlutenClickHouseWholeStageTransformerS
}
}
+ test("Test get_json_object 11") {
+ runQueryAndCompare(
+ "SELECT string_field1 from json_test where" +
+ " get_json_object(string_field1, '$.a') is not null") { _ => }
+ }
+
test("Test covar_samp") {
runQueryAndCompare("SELECT covar_samp(double_field1, int_field1) from
json_test") { _ => }
}
diff --git a/cpp-ch/local-engine/Parser/FilterRelParser.cpp
b/cpp-ch/local-engine/Parser/FilterRelParser.cpp
index 19facf3bf..4c71cc312 100644
--- a/cpp-ch/local-engine/Parser/FilterRelParser.cpp
+++ b/cpp-ch/local-engine/Parser/FilterRelParser.cpp
@@ -31,7 +31,7 @@ DB::QueryPlanPtr FilterRelParser::parse(DB::QueryPlanPtr
query_plan, const subst
substrait::Rel final_rel = rel;
rewriter.rewrite(final_rel);
- const auto & filter_rel = rel.filter();
+ const auto & filter_rel = final_rel.filter();
std::string filter_name;
auto input_header = query_plan->getCurrentDataStream().header;
@@ -66,7 +66,6 @@ DB::QueryPlanPtr FilterRelParser::parse(DB::QueryPlanPtr
query_plan, const subst
{
steps.emplace_back(remove_null_step);
}
-
return query_plan;
}
diff --git a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
index 25ea86e5b..c2bcd1a36 100644
--- a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
+++ b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
@@ -1004,9 +1004,6 @@ const ActionsDAG::Node *
SerializedPlanParser::parseFunctionWithDAG(
}
}
- if (ch_func_name == "JSON_VALUE")
- result_node->function->setResolver(function_builder);
-
if (keep_result)
actions_dag->addOrReplaceInOutputs(*result_node);
diff --git a/cpp-ch/local-engine/Rewriter/ExpressionRewriter.h
b/cpp-ch/local-engine/Rewriter/ExpressionRewriter.h
index cdea86133..c22c64eae 100644
--- a/cpp-ch/local-engine/Rewriter/ExpressionRewriter.h
+++ b/cpp-ch/local-engine/Rewriter/ExpressionRewriter.h
@@ -38,7 +38,7 @@ public:
void rewrite(substrait::Rel & rel) override
{
- if (!rel.has_project())
+ if (!rel.has_filter() && !rel.has_project())
{
return;
}
@@ -51,6 +51,11 @@ private:
/// Collect all get_json_object functions and group by json strings
void prepare(const substrait::Rel & rel)
{
+ if (rel.has_filter())
+ {
+ auto & expr = rel.filter().condition();
+ prepareOnExpression(expr);
+ }
if (rel.has_project())
{
for (auto & expr : rel.project().expressions())
@@ -62,6 +67,12 @@ private:
void rewriteImpl(substrait::Rel & rel)
{
+ if (rel.has_filter())
+ {
+ auto * filter = rel.mutable_filter();
+ auto * expression = filter->mutable_condition();
+ rewriteExpression(*expression);
+ }
if (rel.has_project())
{
auto * project = rel.mutable_project();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]