You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by li...@apache.org on 2023/01/11 13:37:34 UTC
[arrow-datafusion] branch master updated: Skip EliminateCrossJoin rule when meet non-empty join filter (#4869)
This is an automated email from the ASF dual-hosted git repository.
liukun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/master by this push:
new 98b46964a Skip EliminateCrossJoin rule when meet non-empty join filter (#4869)
98b46964a is described below
commit 98b46964ad127317e14197472af99970b9825230
Author: ygf11 <ya...@gmail.com>
AuthorDate: Wed Jan 11 21:37:26 2023 +0800
Skip EliminateCrossJoin rule when meet non-empty join filter (#4869)
* Skip EliminateCrossJoin rule when meet non-empty join filter
* fix cargo fmt
---
.../core/tests/sqllogictests/test_files/join.slt | 44 ++++++++++++++++++++++
datafusion/optimizer/src/eliminate_cross_join.rs | 6 +++
2 files changed, 50 insertions(+)
diff --git a/datafusion/core/tests/sqllogictests/test_files/join.slt b/datafusion/core/tests/sqllogictests/test_files/join.slt
new file mode 100644
index 000000000..4366d99a9
--- /dev/null
+++ b/datafusion/core/tests/sqllogictests/test_files/join.slt
@@ -0,0 +1,44 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+##########
+## JOIN Tests
+##########
+
+statement ok
+CREATE TABLE students(name TEXT, mark INT) AS VALUES
+('Stuart', 28),
+('Amina', 89),
+('Christen', 50),
+('Salma', 77),
+('Samantha', 21);
+
+statement ok
+CREATE TABLE grades(grade INT, min INT, max INT) AS VALUES
+(1, 0, 14),
+(2, 15, 35),
+(3, 36, 55),
+(4, 56, 79),
+(5, 80, 100);
+
+# Regression test: https://github.com/apache/arrow-datafusion/issues/4844
+query I
+SELECT s.*, g.grade FROM students s join grades g on s.mark between g.min and g.max WHERE grade > 2 ORDER BY s.mark DESC
+----
+Amina 89 5
+Salma 77 4
+Christen 50 3
diff --git a/datafusion/optimizer/src/eliminate_cross_join.rs b/datafusion/optimizer/src/eliminate_cross_join.rs
index 458eab959..e0bb11430 100644
--- a/datafusion/optimizer/src/eliminate_cross_join.rs
+++ b/datafusion/optimizer/src/eliminate_cross_join.rs
@@ -62,6 +62,12 @@ impl OptimizerRule for EliminateCrossJoin {
let mut all_inputs: Vec<LogicalPlan> = vec![];
match &input {
LogicalPlan::Join(join) if (join.join_type == JoinType::Inner) => {
+ // The filter of inner join will lost, skip this rule.
+ // issue: https://github.com/apache/arrow-datafusion/issues/4844
+ if join.filter.is_some() {
+ return Ok(None);
+ }
+
flatten_join_inputs(
&input,
&mut possible_join_keys,