mirror of https://github.com/apache/druid.git
Fix hasBuiltInFilters for joins (#12894)
This commit is contained in:
parent
836430019a
commit
af700bba0c
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue