This is an automated email from the ASF dual-hosted git repository.
abhishek 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 bcff35f798 Pushdown join filter with right side referencing columns
(#12749)
bcff35f798 is described below
commit bcff35f798ffbce235adf34d68f1901bcbc6b909
Author: Rohan Garg <[email protected]>
AuthorDate: Fri Jul 8 19:59:41 2022 +0530
Pushdown join filter with right side referencing columns (#12749)
---
.../apache/druid/segment/join/JoinableFactoryWrapper.java | 8 +++++---
.../druid/segment/join/JoinableFactoryWrapperTest.java | 12 ++++++------
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git
a/processing/src/main/java/org/apache/druid/segment/join/JoinableFactoryWrapper.java
b/processing/src/main/java/org/apache/druid/segment/join/JoinableFactoryWrapper.java
index 235ff6d197..c0831b352e 100644
---
a/processing/src/main/java/org/apache/druid/segment/join/JoinableFactoryWrapper.java
+++
b/processing/src/main/java/org/apache/druid/segment/join/JoinableFactoryWrapper.java
@@ -261,7 +261,9 @@ public class JoinableFactoryWrapper
* - the right-hand columns referenced by the condition must not have any
duplicate values. If there are duplicates
* values in the column, then the join is tried to be converted to a
filter while maintaining the join clause on top
* as well for correct results.
- * - no columns from the right-hand side can appear in "requiredColumns"
+ * - no columns from the right-hand side can appear in "requiredColumns". If
the columns from right side are required
+ * (ie they are directly or indirectly projected in the join output), then
the join is tried to be converted to a
+ * filter while maintaining the join clause on top as well for correct
results.
*
* @return {@link JoinClauseToFilterConversion} object which contains the
converted filter for the clause and a boolean
* to represent whether the converted filter encapsulates the whole clause
or not. More semantics of the object are
@@ -275,12 +277,12 @@ public class JoinableFactoryWrapper
)
{
if (clause.getJoinType() == JoinType.INNER
- && requiredColumns.stream().noneMatch(clause::includesColumn)
&& clause.getCondition().getNonEquiConditions().isEmpty()
&& clause.getCondition().getEquiConditions().size() > 0) {
final List<Filter> filters = new ArrayList<>();
int numValues = maxNumFilterValues;
- boolean joinClauseFullyConverted = true;
+ // if the right side columns are required, the clause cannot be fully
converted
+ boolean joinClauseFullyConverted =
requiredColumns.stream().noneMatch(clause::includesColumn);
for (final Equality condition :
clause.getCondition().getEquiConditions()) {
final String leftColumn =
condition.getLeftExpr().getBindingIfIdentifier();
diff --git
a/processing/src/test/java/org/apache/druid/segment/join/JoinableFactoryWrapperTest.java
b/processing/src/test/java/org/apache/druid/segment/join/JoinableFactoryWrapperTest.java
index 014dd7648b..d430fb7e8f 100644
---
a/processing/src/test/java/org/apache/druid/segment/join/JoinableFactoryWrapperTest.java
+++
b/processing/src/test/java/org/apache/druid/segment/join/JoinableFactoryWrapperTest.java
@@ -674,7 +674,7 @@ public class JoinableFactoryWrapperTest extends
NullHandlingTest
}
@Test
- public void test_convertJoinsToFilters_dontConvertWhenColumnIsUsed()
+ public void test_convertJoinsToFilters_partialConvertWhenColumnIsUsed()
{
final JoinableClause clause = new JoinableClause(
"j.",
@@ -691,7 +691,7 @@ public class JoinableFactoryWrapperTest extends
NullHandlingTest
Assert.assertEquals(
Pair.of(
- ImmutableList.of(),
+ ImmutableList.of(new InDimFilter("x", TEST_LOOKUP_KEYS)),
ImmutableList.of(clause)
),
conversion
@@ -799,7 +799,7 @@ public class JoinableFactoryWrapperTest extends
NullHandlingTest
}
@Test
- public void
test_convertJoinsToFilters_dontConvertJoinsDependedOnByLaterJoins()
+ public void
test_convertJoinsToFilters_partialConvertJoinsDependedOnByLaterJoins()
{
final ImmutableList<JoinableClause> clauses = ImmutableList.of(
new JoinableClause(
@@ -830,7 +830,7 @@ public class JoinableFactoryWrapperTest extends
NullHandlingTest
Assert.assertEquals(
Pair.of(
- ImmutableList.of(),
+ ImmutableList.of(new InDimFilter("x", TEST_LOOKUP_KEYS)),
clauses
),
conversion
@@ -838,7 +838,7 @@ public class JoinableFactoryWrapperTest extends
NullHandlingTest
}
@Test
- public void
test_convertJoinsToFilters_dontConvertJoinsDependedOnByLaterJoins2()
+ public void
test_convertJoinsToFilters_partialConvertJoinsDependedOnByLaterJoins2()
{
final ImmutableList<JoinableClause> clauses = ImmutableList.of(
new JoinableClause(
@@ -869,7 +869,7 @@ public class JoinableFactoryWrapperTest extends
NullHandlingTest
Assert.assertEquals(
Pair.of(
- ImmutableList.of(new InDimFilter("x", TEST_LOOKUP_KEYS)),
+ ImmutableList.of(new InDimFilter("x", TEST_LOOKUP_KEYS), new
InDimFilter("x", TEST_LOOKUP_KEYS)),
clauses.subList(1, clauses.size())
),
conversion
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]