Skip to content

Commit

Permalink
Fix serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
adarshsanjeev committed Dec 13, 2024
1 parent 159df50 commit 3795ba7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ where w1.cityName='New York';
},
"rightPrefix" : "j0.",
"condition" : "(\"cityName\" == \"j0.cityName\")",
"joinType" : "INNER",
"joinAlgorithm" : "broadcast"
"joinType" : "INNER"
},
"intervals" : {
"type" : "intervals",
Expand Down Expand Up @@ -419,8 +418,7 @@ LogicalJoin:[[broadcast inheritPath:[0, 0]]]
},
"rightPrefix" : "j0.",
"condition" : "(\"cityName\" == \"j0.cityName\")",
"joinType" : "INNER",
"joinAlgorithm" : "broadcast"
"joinType" : "INNER"
},
"intervals" : {
"type" : "intervals",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,15 @@ where w1.cityName='New York';
},
"rightPrefix" : "j0.",
"condition" : "(\"regionName\" == \"j0.regionName\")",
"joinType" : "LEFT",
"joinAlgorithm" : "broadcast"
"joinType" : "LEFT"
},
"right" : {
"type" : "inputNumber",
"inputNumber" : 2
},
"rightPrefix" : "_j0.",
"condition" : "(\"cityName\" == \"_j0.cityName\")",
"joinType" : "INNER",
"joinAlgorithm" : "broadcast"
"joinType" : "INNER"
},
"intervals" : {
"type" : "intervals",
Expand Down Expand Up @@ -507,8 +505,7 @@ LogicalJoin:[[sort_merge inheritPath:[0]]]
},
"rightPrefix" : "_j0.",
"condition" : "(\"cityName\" == \"_j0.cityName\")",
"joinType" : "INNER",
"joinAlgorithm" : "broadcast"
"joinType" : "INNER"
},
"intervals" : {
"type" : "intervals",
Expand Down Expand Up @@ -677,8 +674,7 @@ where w1.cityName='New York';
},
"rightPrefix" : "j0.",
"condition" : "(\"regionName\" == \"j0.regionName\")",
"joinType" : "LEFT",
"joinAlgorithm" : "broadcast"
"joinType" : "LEFT"
},
"intervals" : {
"type" : "intervals",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
}
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
Expand Down Expand Up @@ -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()
);
Expand Down Expand Up @@ -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()
);
Expand Down Expand Up @@ -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()
);
Expand Down Expand Up @@ -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()
);
Expand Down Expand Up @@ -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()
);
Expand Down Expand Up @@ -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()
);
Expand Down Expand Up @@ -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()
);
Expand Down Expand Up @@ -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()
);
Expand Down

0 comments on commit 3795ba7

Please sign in to comment.