This is an automated email from the ASF dual-hosted git repository.
rohangarg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new af700bba0c Fix hasBuiltInFilters for joins (#12894)
af700bba0c is described below
commit af700bba0c8408d63de7374d77f681bf8fdeb2f7
Author: Rohan Garg <[email protected]>
AuthorDate: Sat Aug 13 16:26:24 2022 +0530
Fix hasBuiltInFilters for joins (#12894)
---
.../druid/segment/join/HashJoinSegmentStorageAdapter.java | 7 +++++--
.../segment/join/HashJoinSegmentStorageAdapterTest.java | 15 +++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git
a/processing/src/main/java/org/apache/druid/segment/join/HashJoinSegmentStorageAdapter.java
b/processing/src/main/java/org/apache/druid/segment/join/HashJoinSegmentStorageAdapter.java
index 6335f34825..9eb5f3dbde 100644
---
a/processing/src/main/java/org/apache/druid/segment/join/HashJoinSegmentStorageAdapter.java
+++
b/processing/src/main/java/org/apache/druid/segment/join/HashJoinSegmentStorageAdapter.java
@@ -212,8 +212,11 @@ public class HashJoinSegmentStorageAdapter implements
StorageAdapter
@Override
public boolean hasBuiltInFilters()
{
- return clauses.stream()
- .anyMatch(clause -> clause.getJoinType() == JoinType.INNER
&& !clause.getCondition().isAlwaysTrue());
+ // if the baseFilter is not null, then rows from underlying storage
adapter can be potentially filtered.
+ // otherwise, a filtering inner join can also filter rows.
+ return baseFilter != null || clauses.stream().anyMatch(
+ clause -> clause.getJoinType() == JoinType.INNER &&
!clause.getCondition().isAlwaysTrue()
+ );
}
@Override
diff --git
a/processing/src/test/java/org/apache/druid/segment/join/HashJoinSegmentStorageAdapterTest.java
b/processing/src/test/java/org/apache/druid/segment/join/HashJoinSegmentStorageAdapterTest.java
index 99002e59c1..5f7a10b970 100644
---
a/processing/src/test/java/org/apache/druid/segment/join/HashJoinSegmentStorageAdapterTest.java
+++
b/processing/src/test/java/org/apache/druid/segment/join/HashJoinSegmentStorageAdapterTest.java
@@ -20,6 +20,7 @@
package org.apache.druid.segment.join;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import org.apache.druid.common.config.NullHandling;
import org.apache.druid.java.util.common.DateTimes;
@@ -29,6 +30,7 @@ import
org.apache.druid.java.util.common.granularity.Granularities;
import org.apache.druid.math.expr.ExprMacroTable;
import org.apache.druid.query.filter.ExpressionDimFilter;
import org.apache.druid.query.filter.Filter;
+import org.apache.druid.query.filter.InDimFilter;
import org.apache.druid.query.filter.OrDimFilter;
import org.apache.druid.query.filter.SelectorDimFilter;
import org.apache.druid.segment.VirtualColumn;
@@ -2305,6 +2307,19 @@ public class HashJoinSegmentStorageAdapterTest extends
BaseHashJoinSegmentStorag
);
}
+ @Test
+ public void test_hasBuiltInFiltersForConvertedJoin()
+ {
+ Assert.assertTrue(
+ new HashJoinSegmentStorageAdapter(
+ factSegment.asStorageAdapter(),
+ new InDimFilter("dim", ImmutableSet.of("foo", "bar")),
+ ImmutableList.of(),
+ null
+ ).hasBuiltInFilters()
+ );
+ }
+
@Test
public void
test_hasBuiltInFiltersForMultipleJoinableClausesWithVariousJoinTypes()
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]