diff --git a/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.quidem.MSQQuidemTest/msqJoinHint.iq b/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.quidem.MSQQuidemTest/msqJoinHint.iq index 89cc38d13c6d..d6319fadf9ed 100644 --- a/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.quidem.MSQQuidemTest/msqJoinHint.iq +++ b/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.quidem.MSQQuidemTest/msqJoinHint.iq @@ -176,8 +176,7 @@ where w1.cityName='New York'; }, "rightPrefix" : "j0.", "condition" : "(\"cityName\" == \"j0.cityName\")", - "joinType" : "INNER", - "joinAlgorithm" : "broadcast" + "joinType" : "INNER" }, "intervals" : { "type" : "intervals", @@ -419,8 +418,7 @@ LogicalJoin:[[broadcast inheritPath:[0, 0]]] }, "rightPrefix" : "j0.", "condition" : "(\"cityName\" == \"j0.cityName\")", - "joinType" : "INNER", - "joinAlgorithm" : "broadcast" + "joinType" : "INNER" }, "intervals" : { "type" : "intervals", diff --git a/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.quidem.MSQQuidemTest/msqNestedJoinHint.iq b/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.quidem.MSQQuidemTest/msqNestedJoinHint.iq index 9a61a9605b8a..acf6240d5467 100644 --- a/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.quidem.MSQQuidemTest/msqNestedJoinHint.iq +++ b/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.quidem.MSQQuidemTest/msqNestedJoinHint.iq @@ -179,8 +179,7 @@ where w1.cityName='New York'; }, "rightPrefix" : "j0.", "condition" : "(\"regionName\" == \"j0.regionName\")", - "joinType" : "LEFT", - "joinAlgorithm" : "broadcast" + "joinType" : "LEFT" }, "right" : { "type" : "inputNumber", @@ -188,8 +187,7 @@ where w1.cityName='New York'; }, "rightPrefix" : "_j0.", "condition" : "(\"cityName\" == \"_j0.cityName\")", - "joinType" : "INNER", - "joinAlgorithm" : "broadcast" + "joinType" : "INNER" }, "intervals" : { "type" : "intervals", @@ -507,8 +505,7 @@ LogicalJoin:[[sort_merge inheritPath:[0]]] }, "rightPrefix" : "_j0.", "condition" : "(\"cityName\" == \"_j0.cityName\")", - "joinType" : "INNER", - "joinAlgorithm" : "broadcast" + "joinType" : "INNER" }, "intervals" : { "type" : "intervals", @@ -677,8 +674,7 @@ where w1.cityName='New York'; }, "rightPrefix" : "j0.", "condition" : "(\"regionName\" == \"j0.regionName\")", - "joinType" : "LEFT", - "joinAlgorithm" : "broadcast" + "joinType" : "LEFT" }, "intervals" : { "type" : "intervals", diff --git a/processing/src/main/java/org/apache/druid/query/JoinDataSource.java b/processing/src/main/java/org/apache/druid/query/JoinDataSource.java index d0714e62737a..0473ae89689a 100644 --- a/processing/src/main/java/org/apache/druid/query/JoinDataSource.java +++ b/processing/src/main/java/org/apache/druid/query/JoinDataSource.java @@ -100,6 +100,19 @@ public class JoinDataSource implements DataSource private static final Logger log = new Logger(JoinDataSource.class); private final DataSourceAnalysis analysis; +// private JoinDataSource() +// { +// analysis = null; +// leftFilter = null; +// joinableFactoryWrapper = null; +// joinAlgorithm = JoinAlgorithm.BROADCAST; +// conditionAnalysis = null; +// joinType = null; +// rightPrefix = null; +// right = null; +// left = null; +// } + private JoinDataSource( DataSource left, DataSource right, @@ -118,7 +131,7 @@ private JoinDataSource( this.joinType = Preconditions.checkNotNull(joinType, "joinType"); this.leftFilter = validateLeftFilter(left, leftFilter); this.joinableFactoryWrapper = joinableFactoryWrapper; - this.joinAlgorithm = joinAlgorithm; + this.joinAlgorithm = JoinAlgorithm.BROADCAST.equals(joinAlgorithm) ? null : joinAlgorithm; this.analysis = this.getAnalysisForDataSource(); } @@ -371,13 +384,18 @@ public DataSourceAnalysis getAnalysis() return analysis; } - @Nullable @JsonProperty("joinAlgorithm") - public JoinAlgorithm getJoinAlgorithm() + @JsonInclude(Include.NON_NULL) + private JoinAlgorithm getJoinAlgorithmForSerialization() { return joinAlgorithm; } + public JoinAlgorithm getJoinAlgorithm() + { + return joinAlgorithm == null ? JoinAlgorithm.BROADCAST : joinAlgorithm; + } + @Override public boolean equals(Object o) { diff --git a/processing/src/test/java/org/apache/druid/query/metadata/SegmentMetadataQueryTest.java b/processing/src/test/java/org/apache/druid/query/metadata/SegmentMetadataQueryTest.java index a05650e11f51..9bcf69f0aa8b 100644 --- a/processing/src/test/java/org/apache/druid/query/metadata/SegmentMetadataQueryTest.java +++ b/processing/src/test/java/org/apache/druid/query/metadata/SegmentMetadataQueryTest.java @@ -1618,7 +1618,7 @@ public void testSegmentMetadataQueryWithInvalidDatasourceTypes() DruidExceptionMatcher .invalidInput() .expectMessageIs( - "Invalid dataSource type [JoinDataSource{left=table1, right=table2, rightPrefix='j.', condition=x == \"j.x\", joinType=LEFT, leftFilter=null, joinAlgorithm=broadcast}]. SegmentMetadataQuery only supports table or union datasources.") + "Invalid dataSource type [JoinDataSource{left=table1, right=table2, rightPrefix='j.', condition=x == \"j.x\", joinType=LEFT, leftFilter=null, joinAlgorithm=null}]. SegmentMetadataQuery only supports table or union datasources.") ); } diff --git a/processing/src/test/java/org/apache/druid/query/planning/DataSourceAnalysisTest.java b/processing/src/test/java/org/apache/druid/query/planning/DataSourceAnalysisTest.java index 522e58daf1f5..a9c4510ae9fb 100644 --- a/processing/src/test/java/org/apache/druid/query/planning/DataSourceAnalysisTest.java +++ b/processing/src/test/java/org/apache/druid/query/planning/DataSourceAnalysisTest.java @@ -246,9 +246,9 @@ public void testJoinSimpleLeftLeaning() Assert.assertEquals(Optional.empty(), analysis.getBaseQuerySegmentSpec()); Assert.assertEquals( ImmutableList.of( - new PreJoinableClause("1.", LOOKUP_LOOKYLOO, JoinType.INNER, joinClause("1."), JoinAlgorithm.BROADCAST), - new PreJoinableClause("2.", INLINE, JoinType.LEFT, joinClause("2."), JoinAlgorithm.BROADCAST), - new PreJoinableClause("3.", subquery(LOOKUP_LOOKYLOO), JoinType.FULL, joinClause("3."), JoinAlgorithm.BROADCAST) + new PreJoinableClause("1.", LOOKUP_LOOKYLOO, JoinType.INNER, joinClause("1."), null), + new PreJoinableClause("2.", INLINE, JoinType.LEFT, joinClause("2."), null), + new PreJoinableClause("3.", subquery(LOOKUP_LOOKYLOO), JoinType.FULL, joinClause("3."), null) ), analysis.getPreJoinableClauses() ); @@ -297,9 +297,9 @@ public void testJoinSimpleLeftLeaningWithLeftFilter() Assert.assertEquals(Optional.empty(), analysis.getBaseQuerySegmentSpec()); Assert.assertEquals( ImmutableList.of( - new PreJoinableClause("1.", LOOKUP_LOOKYLOO, JoinType.INNER, joinClause("1."), JoinAlgorithm.BROADCAST), - new PreJoinableClause("2.", INLINE, JoinType.LEFT, joinClause("2."), JoinAlgorithm.BROADCAST), - new PreJoinableClause("3.", subquery(LOOKUP_LOOKYLOO), JoinType.FULL, joinClause("3."), JoinAlgorithm.BROADCAST) + new PreJoinableClause("1.", LOOKUP_LOOKYLOO, JoinType.INNER, joinClause("1."), null), + new PreJoinableClause("2.", INLINE, JoinType.LEFT, joinClause("2."), null), + new PreJoinableClause("3.", subquery(LOOKUP_LOOKYLOO), JoinType.FULL, joinClause("3."), null) ), analysis.getPreJoinableClauses() ); @@ -354,7 +354,7 @@ public void testJoinSimpleRightLeaning() Assert.assertEquals(Optional.empty(), analysis.getBaseQuerySegmentSpec()); Assert.assertEquals( ImmutableList.of( - new PreJoinableClause("3.", rightLeaningJoinStack, JoinType.RIGHT, joinClause("3."), JoinAlgorithm.BROADCAST) + new PreJoinableClause("3.", rightLeaningJoinStack, JoinType.RIGHT, joinClause("3."), null) ), analysis.getPreJoinableClauses() ); @@ -404,7 +404,7 @@ public void testJoinSimpleRightLeaningWithLeftFilter() Assert.assertEquals(Optional.empty(), analysis.getBaseQuerySegmentSpec()); Assert.assertEquals( ImmutableList.of( - new PreJoinableClause("3.", rightLeaningJoinStack, JoinType.RIGHT, joinClause("3."), JoinAlgorithm.BROADCAST) + new PreJoinableClause("3.", rightLeaningJoinStack, JoinType.RIGHT, joinClause("3."), null) ), analysis.getPreJoinableClauses() ); @@ -438,7 +438,7 @@ public void testJoinOverTableSubquery() Assert.assertEquals(Optional.empty(), analysis.getBaseUnionDataSource()); Assert.assertEquals( ImmutableList.of( - new PreJoinableClause("1.", subquery(TABLE_FOO), JoinType.INNER, joinClause("1."), JoinAlgorithm.BROADCAST) + new PreJoinableClause("1.", subquery(TABLE_FOO), JoinType.INNER, joinClause("1."), null) ), analysis.getPreJoinableClauses() ); @@ -472,7 +472,7 @@ public void testJoinTableUnionToLookup() Assert.assertEquals(Optional.empty(), analysis.getBaseQuerySegmentSpec()); Assert.assertEquals( ImmutableList.of( - new PreJoinableClause("1.", LOOKUP_LOOKYLOO, JoinType.INNER, joinClause("1."), JoinAlgorithm.BROADCAST) + new PreJoinableClause("1.", LOOKUP_LOOKYLOO, JoinType.INNER, joinClause("1."), null) ), analysis.getPreJoinableClauses() ); @@ -527,7 +527,7 @@ public void testJoinUnderTopLevelSubqueries() ); Assert.assertEquals( ImmutableList.of( - new PreJoinableClause("1.", LOOKUP_LOOKYLOO, JoinType.INNER, joinClause("1."), JoinAlgorithm.BROADCAST) + new PreJoinableClause("1.", LOOKUP_LOOKYLOO, JoinType.INNER, joinClause("1."), null) ), analysis.getPreJoinableClauses() ); @@ -560,7 +560,7 @@ public void testJoinLookupToLookup() Assert.assertEquals(Optional.empty(), analysis.getJoinBaseTableFilter()); Assert.assertEquals( ImmutableList.of( - new PreJoinableClause("1.", LOOKUP_LOOKYLOO, JoinType.INNER, joinClause("1."), JoinAlgorithm.BROADCAST) + new PreJoinableClause("1.", LOOKUP_LOOKYLOO, JoinType.INNER, joinClause("1."), null) ), analysis.getPreJoinableClauses() ); @@ -593,7 +593,7 @@ public void testJoinLookupToTable() Assert.assertEquals(Optional.empty(), analysis.getJoinBaseTableFilter()); Assert.assertEquals( ImmutableList.of( - new PreJoinableClause("1.", TABLE_FOO, JoinType.INNER, joinClause("1."), JoinAlgorithm.BROADCAST) + new PreJoinableClause("1.", TABLE_FOO, JoinType.INNER, joinClause("1."), null) ), analysis.getPreJoinableClauses() );