fix issues with join filter pushdown and virtual column resolution (#16702)

This commit is contained in:
Clint Wylie 2024-07-11 04:26:07 -07:00 committed by GitHub
parent 4b293fc2a9
commit d6c07270a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 119 additions and 189 deletions

View File

@ -48,13 +48,12 @@ import org.apache.druid.segment.virtual.VirtualizedColumnInspector;
import org.apache.druid.segment.virtual.VirtualizedColumnSelectorFactory; import org.apache.druid.segment.virtual.VirtualizedColumnSelectorFactory;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
/** /**
* Class allowing lookup and usage of virtual columns. * Class allowing lookup and usage of virtual columns.
@ -86,11 +85,21 @@ public class VirtualColumns implements Cacheable
} }
@JsonCreator @JsonCreator
public static VirtualColumns create(List<VirtualColumn> virtualColumns) public static VirtualColumns create(@Nullable List<VirtualColumn> virtualColumns)
{ {
if (virtualColumns == null || virtualColumns.isEmpty()) { if (virtualColumns == null || virtualColumns.isEmpty()) {
return EMPTY; return EMPTY;
} }
return fromIterable(virtualColumns);
}
public static VirtualColumns create(VirtualColumn... virtualColumns)
{
return create(Arrays.asList(virtualColumns));
}
public static VirtualColumns fromIterable(Iterable<VirtualColumn> virtualColumns)
{
Map<String, VirtualColumn> withDotSupport = new HashMap<>(); Map<String, VirtualColumn> withDotSupport = new HashMap<>();
Map<String, VirtualColumn> withoutDotSupport = new HashMap<>(); Map<String, VirtualColumn> withoutDotSupport = new HashMap<>();
for (VirtualColumn vc : virtualColumns) { for (VirtualColumn vc : virtualColumns) {
@ -115,11 +124,6 @@ public class VirtualColumns implements Cacheable
return new VirtualColumns(ImmutableList.copyOf(virtualColumns), withDotSupport, withoutDotSupport); return new VirtualColumns(ImmutableList.copyOf(virtualColumns), withDotSupport, withoutDotSupport);
} }
public static VirtualColumns create(VirtualColumn... virtualColumns)
{
return create(Arrays.asList(virtualColumns));
}
public static VirtualColumns nullToEmpty(@Nullable VirtualColumns virtualColumns) public static VirtualColumns nullToEmpty(@Nullable VirtualColumns virtualColumns)
{ {
return virtualColumns == null ? EMPTY : virtualColumns; return virtualColumns == null ? EMPTY : virtualColumns;
@ -134,6 +138,14 @@ public class VirtualColumns implements Cacheable
} }
} }
// For equals, hashCode, toString, and serialization:
private final List<VirtualColumn> virtualColumns;
private final List<String> virtualColumnNames;
// For getVirtualColumn:
private final Map<String, VirtualColumn> withDotSupport;
private final Map<String, VirtualColumn> withoutDotSupport;
private VirtualColumns( private VirtualColumns(
List<VirtualColumn> virtualColumns, List<VirtualColumn> virtualColumns,
Map<String, VirtualColumn> withDotSupport, Map<String, VirtualColumn> withDotSupport,
@ -143,19 +155,14 @@ public class VirtualColumns implements Cacheable
this.virtualColumns = virtualColumns; this.virtualColumns = virtualColumns;
this.withDotSupport = withDotSupport; this.withDotSupport = withDotSupport;
this.withoutDotSupport = withoutDotSupport; this.withoutDotSupport = withoutDotSupport;
this.virtualColumnNames = new ArrayList<>(virtualColumns.size());
for (VirtualColumn virtualColumn : virtualColumns) { for (VirtualColumn virtualColumn : virtualColumns) {
detectCycles(virtualColumn, null); detectCycles(virtualColumn, null);
virtualColumnNames.add(virtualColumn.getOutputName());
} }
} }
// For equals, hashCode, toString, and serialization:
private final List<VirtualColumn> virtualColumns;
// For getVirtualColumn:
private final Map<String, VirtualColumn> withDotSupport;
private final Map<String, VirtualColumn> withoutDotSupport;
/** /**
* Returns true if a virtual column exists with a particular columnName. * Returns true if a virtual column exists with a particular columnName.
* *
@ -468,6 +475,16 @@ public class VirtualColumns implements Cacheable
return new CacheKeyBuilder((byte) 0).appendCacheablesIgnoringOrder(virtualColumns).build(); return new CacheKeyBuilder((byte) 0).appendCacheablesIgnoringOrder(virtualColumns).build();
} }
public boolean isEmpty()
{
return virtualColumns.isEmpty();
}
public List<String> getColumnNames()
{
return virtualColumnNames;
}
private VirtualColumn getVirtualColumnForSelector(String columnName) private VirtualColumn getVirtualColumnForSelector(String columnName)
{ {
VirtualColumn virtualColumn = getVirtualColumn(columnName); VirtualColumn virtualColumn = getVirtualColumn(columnName);
@ -538,14 +555,4 @@ public class VirtualColumns implements Cacheable
((VirtualColumns) obj).virtualColumns.isEmpty(); ((VirtualColumns) obj).virtualColumns.isEmpty();
} }
} }
public boolean isEmpty()
{
return virtualColumns.isEmpty();
}
public List<String> getColumnNames()
{
return virtualColumns.stream().map(v -> v.getOutputName()).collect(Collectors.toList());
}
} }

View File

@ -19,7 +19,10 @@
package org.apache.druid.segment.join; package org.apache.druid.segment.join;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.ISE;
import org.apache.druid.java.util.common.granularity.Granularity; import org.apache.druid.java.util.common.granularity.Granularity;
import org.apache.druid.java.util.common.guava.Sequence; import org.apache.druid.java.util.common.guava.Sequence;
@ -30,7 +33,6 @@ import org.apache.druid.query.filter.Filter;
import org.apache.druid.segment.Cursor; import org.apache.druid.segment.Cursor;
import org.apache.druid.segment.Metadata; import org.apache.druid.segment.Metadata;
import org.apache.druid.segment.StorageAdapter; import org.apache.druid.segment.StorageAdapter;
import org.apache.druid.segment.VirtualColumn;
import org.apache.druid.segment.VirtualColumns; import org.apache.druid.segment.VirtualColumns;
import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.column.ColumnCapabilities;
import org.apache.druid.segment.data.Indexed; import org.apache.druid.segment.data.Indexed;
@ -46,13 +48,10 @@ import org.joda.time.Interval;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
public class HashJoinSegmentStorageAdapter implements StorageAdapter public class HashJoinSegmentStorageAdapter implements StorageAdapter
{ {
@ -292,43 +291,40 @@ public class HashJoinSegmentStorageAdapter implements StorageAdapter
); );
final JoinFilterPreAnalysisKey keyCached = joinFilterPreAnalysis.getKey(); final JoinFilterPreAnalysisKey keyCached = joinFilterPreAnalysis.getKey();
final JoinFilterSplit joinFilterSplit; final JoinFilterPreAnalysis preAnalysis;
if (keyIn.equals(keyCached)) { if (keyIn.equals(keyCached)) {
// Common case: key used during filter pre-analysis (keyCached) matches key implied by makeCursors call (keyIn). // Common case: key used during filter pre-analysis (keyCached) matches key implied by makeCursors call (keyIn).
joinFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis, baseFilter); preAnalysis = joinFilterPreAnalysis;
} else { } else {
// Less common case: key differs. Re-analyze the filter. This case can happen when an unnest datasource is // Less common case: key differs. Re-analyze the filter. This case can happen when an unnest datasource is
// layered on top of a join datasource. // layered on top of a join datasource.
joinFilterSplit = JoinFilterAnalyzer.splitFilter( preAnalysis = JoinFilterAnalyzer.computeJoinFilterPreAnalysis(keyIn);
JoinFilterAnalyzer.computeJoinFilterPreAnalysis(keyIn),
baseFilter
);
} }
final List<VirtualColumn> preJoinVirtualColumns = new ArrayList<>();
final List<VirtualColumn> postJoinVirtualColumns = new ArrayList<>();
determineBaseColumnsWithPreAndPostJoinVirtualColumns( final JoinFilterSplit joinFilterSplit = JoinFilterAnalyzer.splitFilter(
virtualColumns, preAnalysis,
preJoinVirtualColumns, baseFilter
postJoinVirtualColumns
); );
// We merge the filter on base table specified by the user and filter on the base table that is pushed from
// the join
preJoinVirtualColumns.addAll(joinFilterSplit.getPushDownVirtualColumns());
final Sequence<Cursor> baseCursorSequence = baseAdapter.makeCursors( final Sequence<Cursor> baseCursorSequence = baseAdapter.makeCursors(
joinFilterSplit.getBaseTableFilter().isPresent() ? joinFilterSplit.getBaseTableFilter().get() : null, joinFilterSplit.getBaseTableFilter().isPresent() ? joinFilterSplit.getBaseTableFilter().get() : null,
interval, interval,
VirtualColumns.create(preJoinVirtualColumns), VirtualColumns.fromIterable(
Iterables.concat(
Sets.difference(
ImmutableSet.copyOf(virtualColumns.getVirtualColumns()),
joinFilterPreAnalysis.getPostJoinVirtualColumns()
),
joinFilterSplit.getPushDownVirtualColumns()
)
),
gran, gran,
descending, descending,
queryMetrics queryMetrics
); );
Closer joinablesCloser = Closer.create(); final Closer joinablesCloser = Closer.create();
return Sequences.<Cursor, Cursor>map( return Sequences.<Cursor, Cursor>map(
baseCursorSequence, baseCursorSequence,
cursor -> { cursor -> {
@ -341,7 +337,7 @@ public class HashJoinSegmentStorageAdapter implements StorageAdapter
return PostJoinCursor.wrap( return PostJoinCursor.wrap(
retVal, retVal,
VirtualColumns.create(postJoinVirtualColumns), VirtualColumns.fromIterable(preAnalysis.getPostJoinVirtualColumns()),
joinFilterSplit.getJoinTableFilter().orElse(null) joinFilterSplit.getJoinTableFilter().orElse(null)
); );
} }
@ -357,47 +353,6 @@ public class HashJoinSegmentStorageAdapter implements StorageAdapter
return !getClauseForColumn(column).isPresent(); return !getClauseForColumn(column).isPresent();
} }
/**
* Return a String set containing the name of columns that belong to the base table (including any pre-join virtual
* columns as well).
*
* Additionally, if the preJoinVirtualColumns and/or postJoinVirtualColumns arguments are provided, this method
* will add each VirtualColumn in the provided virtualColumns to either preJoinVirtualColumns or
* postJoinVirtualColumns based on whether the virtual column is pre-join or post-join.
*
* @param virtualColumns List of virtual columns from the query
* @param preJoinVirtualColumns If provided, virtual columns determined to be pre-join will be added to this list
* @param postJoinVirtualColumns If provided, virtual columns determined to be post-join will be added to this list
*
* @return The set of base column names, including any pre-join virtual columns.
*/
public Set<String> determineBaseColumnsWithPreAndPostJoinVirtualColumns(
VirtualColumns virtualColumns,
@Nullable List<VirtualColumn> preJoinVirtualColumns,
@Nullable List<VirtualColumn> postJoinVirtualColumns
)
{
final Set<String> baseColumns = new HashSet<>(baseAdapter.getRowSignature().getColumnNames());
for (VirtualColumn virtualColumn : virtualColumns.getVirtualColumns()) {
// Virtual columns cannot depend on each other, so we don't need to check transitive dependencies.
if (baseColumns.containsAll(virtualColumn.requiredColumns())) {
// Since pre-join virtual columns can be computed using only base columns, we include them in the
// base column set.
baseColumns.add(virtualColumn.getOutputName());
if (preJoinVirtualColumns != null) {
preJoinVirtualColumns.add(virtualColumn);
}
} else {
if (postJoinVirtualColumns != null) {
postJoinVirtualColumns.add(virtualColumn);
}
}
}
return baseColumns;
}
/** /**
* Returns the JoinableClause corresponding to a particular column, based on the clauses' prefixes. * Returns the JoinableClause corresponding to a particular column, based on the clauses' prefixes.
* *

View File

@ -69,8 +69,8 @@ import java.util.Set;
* *
* The result of this pre-analysis method should be passed into the next step of join filter analysis, described below. * The result of this pre-analysis method should be passed into the next step of join filter analysis, described below.
* *
* The {@link #splitFilter(JoinFilterPreAnalysis)} method takes the pre-analysis result and optionally applies the * The {@link #splitFilter(JoinFilterPreAnalysis, Filter)} method takes the pre-analysis result and optionally applies
* filter rewrite and push down operations on a per-segment level. * the filter rewrite and push down operations on a per-segment level.
*/ */
public class JoinFilterAnalyzer public class JoinFilterAnalyzer
{ {
@ -90,11 +90,10 @@ public class JoinFilterAnalyzer
*/ */
public static JoinFilterPreAnalysis computeJoinFilterPreAnalysis(final JoinFilterPreAnalysisKey key) public static JoinFilterPreAnalysis computeJoinFilterPreAnalysis(final JoinFilterPreAnalysisKey key)
{ {
final List<VirtualColumn> preJoinVirtualColumns = new ArrayList<>();
final List<VirtualColumn> postJoinVirtualColumns = new ArrayList<>();
final JoinableClauses joinableClauses = JoinableClauses.fromList(key.getJoinableClauses()); final JoinableClauses joinableClauses = JoinableClauses.fromList(key.getJoinableClauses());
joinableClauses.splitVirtualColumns(key.getVirtualColumns(), preJoinVirtualColumns, postJoinVirtualColumns); final Set<VirtualColumn> postJoinVirtualColumns = joinableClauses.getPostJoinVirtualColumns(
key.getVirtualColumns()
);
final JoinFilterPreAnalysis.Builder preAnalysisBuilder = final JoinFilterPreAnalysis.Builder preAnalysisBuilder =
new JoinFilterPreAnalysis.Builder(key, postJoinVirtualColumns); new JoinFilterPreAnalysis.Builder(key, postJoinVirtualColumns);
@ -159,13 +158,6 @@ public class JoinFilterAnalyzer
return preAnalysisBuilder.withCorrelations(correlations).build(); return preAnalysisBuilder.withCorrelations(correlations).build();
} }
public static JoinFilterSplit splitFilter(
JoinFilterPreAnalysis joinFilterPreAnalysis
)
{
return splitFilter(joinFilterPreAnalysis, null);
}
/** /**
* @param joinFilterPreAnalysis The pre-analysis computed by {@link #computeJoinFilterPreAnalysis)} * @param joinFilterPreAnalysis The pre-analysis computed by {@link #computeJoinFilterPreAnalysis)}
* @param baseFilter - Filter on base table that was specified in the query itself * @param baseFilter - Filter on base table that was specified in the query itself
@ -210,7 +202,8 @@ public class JoinFilterAnalyzer
); );
if (joinFilterAnalysis.isCanPushDown()) { if (joinFilterAnalysis.isCanPushDown()) {
//noinspection OptionalGetWithoutIsPresent isCanPushDown checks isPresent //noinspection OptionalGetWithoutIsPresent isCanPushDown checks isPresent
leftFilters.add(joinFilterAnalysis.getPushDownFilter().get()); final Filter pushDown = joinFilterAnalysis.getPushDownFilter().get();
leftFilters.add(pushDown);
} }
if (joinFilterAnalysis.isRetainAfterJoin()) { if (joinFilterAnalysis.isRetainAfterJoin()) {
rightFilters.add(joinFilterAnalysis.getOriginalFilter()); rightFilters.add(joinFilterAnalysis.getOriginalFilter());
@ -519,7 +512,7 @@ public class JoinFilterAnalyzer
} }
private static boolean isColumnFromPostJoinVirtualColumns( private static boolean isColumnFromPostJoinVirtualColumns(
List<VirtualColumn> postJoinVirtualColumns, Set<VirtualColumn> postJoinVirtualColumns,
String column String column
) )
{ {
@ -532,7 +525,7 @@ public class JoinFilterAnalyzer
} }
private static boolean areSomeColumnsFromPostJoinVirtualColumns( private static boolean areSomeColumnsFromPostJoinVirtualColumns(
List<VirtualColumn> postJoinVirtualColumns, Set<VirtualColumn> postJoinVirtualColumns,
Collection<String> columns Collection<String> columns
) )
{ {

View File

@ -50,12 +50,12 @@ public class JoinFilterPreAnalysis
private final List<Filter> normalizedBaseTableClauses; private final List<Filter> normalizedBaseTableClauses;
private final List<Filter> normalizedJoinTableClauses; private final List<Filter> normalizedJoinTableClauses;
private final JoinFilterCorrelations correlations; private final JoinFilterCorrelations correlations;
private final List<VirtualColumn> postJoinVirtualColumns; private final Set<VirtualColumn> postJoinVirtualColumns;
private final Equiconditions equiconditions; private final Equiconditions equiconditions;
private JoinFilterPreAnalysis( private JoinFilterPreAnalysis(
final JoinFilterPreAnalysisKey key, final JoinFilterPreAnalysisKey key,
final List<VirtualColumn> postJoinVirtualColumns, final Set<VirtualColumn> postJoinVirtualColumns,
final List<Filter> normalizedBaseTableClauses, final List<Filter> normalizedBaseTableClauses,
final List<Filter> normalizedJoinTableClauses, final List<Filter> normalizedJoinTableClauses,
final JoinFilterCorrelations correlations, final JoinFilterCorrelations correlations,
@ -86,7 +86,7 @@ public class JoinFilterPreAnalysis
return key.getFilter(); return key.getFilter();
} }
public List<VirtualColumn> getPostJoinVirtualColumns() public Set<VirtualColumn> getPostJoinVirtualColumns()
{ {
return postJoinVirtualColumns; return postJoinVirtualColumns;
} }
@ -140,13 +140,13 @@ public class JoinFilterPreAnalysis
@Nullable @Nullable
private JoinFilterCorrelations correlations; private JoinFilterCorrelations correlations;
@Nonnull @Nonnull
private final List<VirtualColumn> postJoinVirtualColumns; private final Set<VirtualColumn> postJoinVirtualColumns;
@Nonnull @Nonnull
private Equiconditions equiconditions = new Equiconditions(Collections.emptyMap()); private Equiconditions equiconditions = new Equiconditions(Collections.emptyMap());
public Builder( public Builder(
@Nonnull JoinFilterPreAnalysisKey key, @Nonnull JoinFilterPreAnalysisKey key,
@Nonnull List<VirtualColumn> postJoinVirtualColumns @Nonnull Set<VirtualColumn> postJoinVirtualColumns
) )
{ {
this.key = key; this.key = key;

View File

@ -68,6 +68,7 @@ public class JoinFilterPreAnalysisKey
return virtualColumns; return virtualColumns;
} }
@Nullable
public Filter getFilter() public Filter getFilter()
{ {
return filter; return filter;

View File

@ -32,8 +32,10 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class JoinableClauses public class JoinableClauses
@ -88,19 +90,20 @@ public class JoinableClauses
return joinableClauses; return joinableClauses;
} }
public void splitVirtualColumns( /**
final VirtualColumns virtualColumns, * Retrieve subset of virtual columns which require inputs which are only present on the join table
final List<VirtualColumn> preJoinVirtualColumns, */
final List<VirtualColumn> postJoinVirtualColumns public Set<VirtualColumn> getPostJoinVirtualColumns(
final VirtualColumns virtualColumns
) )
{ {
final Set<VirtualColumn> postJoinVirtualColumns = new HashSet<>();
for (VirtualColumn virtualColumn : virtualColumns.getVirtualColumns()) { for (VirtualColumn virtualColumn : virtualColumns.getVirtualColumns()) {
if (areSomeColumnsFromJoin(virtualColumn.requiredColumns())) { if (areSomeColumnsFromJoin(virtualColumn.requiredColumns())) {
postJoinVirtualColumns.add(virtualColumn); postJoinVirtualColumns.add(virtualColumn);
} else {
preJoinVirtualColumns.add(virtualColumn);
} }
} }
return postJoinVirtualColumns;
} }
public boolean areSomeColumnsFromJoin( public boolean areSomeColumnsFromJoin(

View File

@ -33,7 +33,6 @@ import org.apache.druid.query.filter.Filter;
import org.apache.druid.query.filter.InDimFilter; import org.apache.druid.query.filter.InDimFilter;
import org.apache.druid.query.filter.OrDimFilter; import org.apache.druid.query.filter.OrDimFilter;
import org.apache.druid.query.filter.SelectorDimFilter; import org.apache.druid.query.filter.SelectorDimFilter;
import org.apache.druid.segment.VirtualColumn;
import org.apache.druid.segment.VirtualColumns; import org.apache.druid.segment.VirtualColumns;
import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.column.ColumnCapabilities;
import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.column.ValueType;
@ -45,7 +44,6 @@ import org.apache.druid.segment.join.table.IndexedTableJoinable;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -2294,42 +2292,6 @@ public class HashJoinSegmentStorageAdapterTest extends BaseHashJoinSegmentStorag
); );
} }
@Test
public void test_determineBaseColumnsWithPreAndPostJoinVirtualColumns()
{
List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryOnIsoCode(JoinType.LEFT));
JoinFilterPreAnalysis analysis = makeDefaultConfigPreAnalysis(null, joinableClauses, VirtualColumns.EMPTY);
HashJoinSegmentStorageAdapter adapter = new HashJoinSegmentStorageAdapter(
factSegment.asStorageAdapter(),
joinableClauses,
analysis
);
List<VirtualColumn> expectedPreJoin = ImmutableList.of(
makeExpressionVirtualColumn("concat(countryIsoCode,'L')", "v0"),
makeExpressionVirtualColumn("concat(countryIsoCode, countryNumber)", "v1"),
makeExpressionVirtualColumn("channel_uniques - 1", "v2"),
makeExpressionVirtualColumn("channel_uniques - __time", "v3")
);
List<VirtualColumn> expectedPostJoin = ImmutableList.of(
makeExpressionVirtualColumn("concat(countryIsoCode, dummyColumn)", "v4"),
makeExpressionVirtualColumn("dummyMetric - __time", "v5")
);
List<VirtualColumn> actualPreJoin = new ArrayList<>();
List<VirtualColumn> actualPostJoin = new ArrayList<>();
List<VirtualColumn> allVirtualColumns = new ArrayList<>();
allVirtualColumns.addAll(expectedPreJoin);
allVirtualColumns.addAll(expectedPostJoin);
adapter.determineBaseColumnsWithPreAndPostJoinVirtualColumns(
VirtualColumns.create(allVirtualColumns),
actualPreJoin,
actualPostJoin
);
Assert.assertEquals(expectedPreJoin, actualPreJoin);
Assert.assertEquals(expectedPostJoin, actualPostJoin);
}
@Test @Test
public void test_hasBuiltInFiltersForSingleJoinableClauseWithVariousJoinTypes() public void test_hasBuiltInFiltersForSingleJoinableClauseWithVariousJoinTypes()
{ {

View File

@ -119,7 +119,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
null, null,
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -183,7 +183,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
new SelectorFilter("rtc.countryName", "United States"), new SelectorFilter("rtc.countryName", "United States"),
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -249,7 +249,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -320,7 +320,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -382,7 +382,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -461,7 +461,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -521,7 +521,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -685,7 +685,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -758,7 +758,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
ExpressionVirtualColumn expectedVirtualColumn = new ExpressionVirtualColumn( ExpressionVirtualColumn expectedVirtualColumn = new ExpressionVirtualColumn(
"JOIN-FILTER-PUSHDOWN-VIRTUAL-COLUMN-0", "JOIN-FILTER-PUSHDOWN-VIRTUAL-COLUMN-0",
@ -933,7 +933,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1013,7 +1013,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
) )
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals( Assert.assertEquals(
expectedFilterSplit.getBaseTableFilter(), expectedFilterSplit.getBaseTableFilter(),
actualFilterSplit.getBaseTableFilter() actualFilterSplit.getBaseTableFilter()
@ -1103,7 +1103,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
) )
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals( Assert.assertEquals(
expectedFilterSplit.getBaseTableFilter(), expectedFilterSplit.getBaseTableFilter(),
actualFilterSplit.getBaseTableFilter() actualFilterSplit.getBaseTableFilter()
@ -1171,7 +1171,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1228,7 +1228,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1284,7 +1284,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1341,7 +1341,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1396,7 +1396,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1460,7 +1460,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1523,7 +1523,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1578,7 +1578,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1632,7 +1632,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1690,7 +1690,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1747,7 +1747,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1803,7 +1803,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1858,7 +1858,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1924,7 +1924,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -1995,7 +1995,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -2074,7 +2074,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -2133,7 +2133,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -2241,7 +2241,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -2494,7 +2494,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
expectedVirtualColumns expectedVirtualColumns
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -2556,7 +2556,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -2630,7 +2630,7 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis); JoinFilterSplit actualFilterSplit = split(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
@ -2674,7 +2674,16 @@ public class JoinFilterAnalyzerTest extends BaseHashJoinSegmentStorageAdapterTes
null, null,
ImmutableSet.of() ImmutableSet.of()
); );
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis, baseTableFilter); JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(
joinFilterPreAnalysis,
baseTableFilter
);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit); Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
} }
private JoinFilterSplit split(JoinFilterPreAnalysis preAnalysis)
{
return JoinFilterAnalyzer.splitFilter(preAnalysis, null);
}
} }