You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "somu-imply (via GitHub)" <gi...@apache.org> on 2023/10/03 21:59:33 UTC
[PR] Updating plans when using joins with unnest on the left (druid)
somu-imply opened a new pull request, #15075:
URL: https://github.com/apache/druid/pull/15075
Previously a query as
```
with t1 as (
select * from foo, unnest(MV_TO_ARRAY("dim3")) as u(d3)
)
select * from t1 JOIN "numFoo" as t2
ON t1.d3 = t2."dim1"
```
would be planned as a join between a query data source on the left and a query data source on the right. Although the results were correct this is limiting performance as query data sources are evaluated at the broker where the number of rows is limited by `maxSubqueryRows`.
Additionally native queries like
```
{
"queryType" : "scan",
"dataSource" : {
"type" : "join",
"left" : {
"type" : "unnest",
"base" : {
"type" : "table",
"name" : "foo"
},
"virtualColumn" : {
"type" : "expression",
"name" : "j0.unnest",
"expression" : "\"dim3\"",
"outputType" : "STRING"
},
"unnestFilter" : null
},
"right" : {
"type" : "query",
"query" : {
"queryType" : "scan",
"dataSource" : {
"type" : "table",
"name" : "numfoo"
},
"intervals" : {
"type" : "intervals",
"intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ]
},
"resultFormat" : "compactedList",
"columns" : [ "__time", "cnt", "d1", "d2", "dim1", "dim2", "dim3", "dim4", "dim5", "dim6", "f1", "f2", "l1", "l2", "m1", "m2", "unique_dim1" ],
"legacy" : false,
"context" : {
"defaultTimeout" : 300000,
"maxScatterGatherBytes" : 9223372036854775807,
"sqlCurrentTimestamp" : "2000-01-01T00:00:00Z",
"sqlQueryId" : "dummy",
"vectorSize" : 2,
"vectorize" : "force",
"vectorizeVirtualColumns" : "force"
},
"granularity" : {
"type" : "all"
}
}
},
"rightPrefix" : "_j0.",
"condition" : "(\"j0.unnest\" == \"_j0.dim1\")",
"joinType" : "INNER"
},
"intervals" : {
"type" : "intervals",
"intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ]
},
"resultFormat" : "compactedList",
"columns" : [ "__time", "_j0.__time", "_j0.cnt", "_j0.d1", "_j0.d2", "_j0.dim1", "_j0.dim2", "_j0.dim3", "_j0.dim4", "_j0.dim5", "_j0.dim6", "_j0.f1", "_j0.f2", "_j0.l1", "_j0.l2", "_j0.m1", "_j0.m2", "_j0.unique_dim1", "cnt", "dim1", "dim2", "dim3", "j0.unnest", "m1", "m2", "unique_dim1" ],
"legacy" : false,
"context" : {
"defaultTimeout" : 300000,
"maxScatterGatherBytes" : 9223372036854775807,
"sqlCurrentTimestamp" : "2000-01-01T00:00:00Z",
"sqlQueryId" : "dummy",
"vectorSize" : 2,
"vectorize" : "force",
"vectorizeVirtualColumns" : "force"
},
"granularity" : {
"type" : "all"
}
}
```
would fail with an error
```
java.lang.ClassCastException: org.apache.druid.query.UnnestDataSource cannot be cast to org.apache.druid.query.TableDataSource
```
Through this PR we do the following to address this:
1. Refactor getAnalysis() for JoinDataSource to correctly use the base datasource if the left hand of a join has an UnnestDataSource
2. Update the createSegmentMapFunction for the JoinDataSource to use the segment map function correctly
3. Additional machinery for the correct query plan
4. Additional unit tests added to support our case
This PR has:
- [ ] been self-reviewed.
- [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Updating plans when using joins with unnest on the left (druid)
Posted by "somu-imply (via GitHub)" <gi...@apache.org>.
somu-imply commented on code in PR #15075:
URL: https://github.com/apache/druid/pull/15075#discussion_r1348986782
##########
processing/src/main/java/org/apache/druid/query/JoinDataSource.java:
##########
@@ -476,10 +476,18 @@ private Function<SegmentReference, SegmentReference> createSegmentMapFunctionInt
.orElse(null)
)
);
-
+ final Function<SegmentReference, SegmentReference> baseMapFn;
+ if (left instanceof JoinDataSource) {
Review Comment:
I'll add a comment as into why we are not using the isConcrete() check and instead using the instanceof check here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Updating plans when using joins with unnest on the left (druid)
Posted by "soumyava (via GitHub)" <gi...@apache.org>.
soumyava merged PR #15075:
URL: https://github.com/apache/druid/pull/15075
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Updating plans when using joins with unnest on the left (druid)
Posted by "somu-imply (via GitHub)" <gi...@apache.org>.
somu-imply commented on code in PR #15075:
URL: https://github.com/apache/druid/pull/15075#discussion_r1347979860
##########
processing/src/main/java/org/apache/druid/query/JoinDataSource.java:
##########
@@ -501,20 +509,37 @@ private static Triple<DataSource, DimFilter, List<PreJoinableClause>> flattenJoi
DimFilter currentDimFilter = null;
final List<PreJoinableClause> preJoinableClauses = new ArrayList<>();
- while (current instanceof JoinDataSource) {
- final JoinDataSource joinDataSource = (JoinDataSource) current;
- current = joinDataSource.getLeft();
- currentDimFilter = validateLeftFilter(current, joinDataSource.getLeftFilter());
- preJoinableClauses.add(
- new PreJoinableClause(
- joinDataSource.getRightPrefix(),
- joinDataSource.getRight(),
- joinDataSource.getJoinType(),
- joinDataSource.getConditionAnalysis()
- )
- );
+ // There can be queries like
+ // Join of Unnest of Join of Unnest of Filter
+ // so these checks are needed to be ORed
+ // to get the base
+ // This also means that an addition of a new datasource
+ // Will need an instanceof check here
+ // A future work should look into if the flattenJoin
+ // can be refactored to omit these instanceof checks
+ while (current instanceof JoinDataSource || current instanceof UnnestDataSource || current instanceof FilteredDataSource) {
Review Comment:
Thanks, added a test with self join on an unnest data source
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Updating plans when using joins with unnest on the left (druid)
Posted by "somu-imply (via GitHub)" <gi...@apache.org>.
somu-imply commented on code in PR #15075:
URL: https://github.com/apache/druid/pull/15075#discussion_r1349311177
##########
processing/src/main/java/org/apache/druid/query/JoinDataSource.java:
##########
@@ -501,20 +509,37 @@ private static Triple<DataSource, DimFilter, List<PreJoinableClause>> flattenJoi
DimFilter currentDimFilter = null;
final List<PreJoinableClause> preJoinableClauses = new ArrayList<>();
- while (current instanceof JoinDataSource) {
- final JoinDataSource joinDataSource = (JoinDataSource) current;
- current = joinDataSource.getLeft();
- currentDimFilter = validateLeftFilter(current, joinDataSource.getLeftFilter());
- preJoinableClauses.add(
- new PreJoinableClause(
- joinDataSource.getRightPrefix(),
- joinDataSource.getRight(),
- joinDataSource.getJoinType(),
- joinDataSource.getConditionAnalysis()
- )
- );
+ // There can be queries like
+ // Join of Unnest of Join of Unnest of Filter
+ // so these checks are needed to be ORed
+ // to get the base
+ // This also means that an addition of a new datasource
+ // Will need an instanceof check here
+ // A future work should look into if the flattenJoin
+ // can be refactored to omit these instanceof checks
+ while (current instanceof JoinDataSource || current instanceof UnnestDataSource || current instanceof FilteredDataSource) {
+ if (current instanceof JoinDataSource) {
+ final JoinDataSource joinDataSource = (JoinDataSource) current;
+ current = joinDataSource.getLeft();
+ currentDimFilter = validateLeftFilter(current, joinDataSource.getLeftFilter());
+ preJoinableClauses.add(
+ new PreJoinableClause(
+ joinDataSource.getRightPrefix(),
+ joinDataSource.getRight(),
+ joinDataSource.getJoinType(),
+ joinDataSource.getConditionAnalysis()
+ )
+ );
+ } else if (current instanceof UnnestDataSource) {
Review Comment:
Comment and unit test added
##########
processing/src/main/java/org/apache/druid/query/JoinDataSource.java:
##########
@@ -476,10 +476,18 @@ private Function<SegmentReference, SegmentReference> createSegmentMapFunctionInt
.orElse(null)
)
);
-
+ final Function<SegmentReference, SegmentReference> baseMapFn;
+ if (left instanceof JoinDataSource) {
Review Comment:
Comment is added
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Updating plans when using joins with unnest on the left (druid)
Posted by "pranavbhole (via GitHub)" <gi...@apache.org>.
pranavbhole commented on PR #15075:
URL: https://github.com/apache/druid/pull/15075#issuecomment-1749505768
looks good to me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Updating plans when using joins with unnest on the left (druid)
Posted by "kgyrtkirk (via GitHub)" <gi...@apache.org>.
kgyrtkirk commented on code in PR #15075:
URL: https://github.com/apache/druid/pull/15075#discussion_r1916747042
##########
processing/src/main/java/org/apache/druid/query/JoinDataSource.java:
##########
@@ -476,10 +476,18 @@ private Function<SegmentReference, SegmentReference> createSegmentMapFunctionInt
.orElse(null)
)
);
-
+ final Function<SegmentReference, SegmentReference> baseMapFn;
+ if (left instanceof JoinDataSource) {
Review Comment:
this means that processing will stop at the 1st nested join!
it could only be `Join -> Unnest -> Join`
and never `Join -> Join -> Unnest` ?
##########
processing/src/main/java/org/apache/druid/query/JoinDataSource.java:
##########
@@ -501,18 +516,39 @@ private static Triple<DataSource, DimFilter, List<PreJoinableClause>> flattenJoi
DimFilter currentDimFilter = null;
final List<PreJoinableClause> preJoinableClauses = new ArrayList<>();
- while (current instanceof JoinDataSource) {
- final JoinDataSource joinDataSource = (JoinDataSource) current;
- current = joinDataSource.getLeft();
- currentDimFilter = validateLeftFilter(current, joinDataSource.getLeftFilter());
- preJoinableClauses.add(
- new PreJoinableClause(
- joinDataSource.getRightPrefix(),
- joinDataSource.getRight(),
- joinDataSource.getJoinType(),
- joinDataSource.getConditionAnalysis()
- )
- );
+ // There can be queries like
+ // Join of Unnest of Join of Unnest of Filter
+ // so these checks are needed to be ORed
+ // to get the base
+ // This method is called to get the analysis for the join data source
+ // Since the analysis of an UnnestDS or FilteredDS always delegates to its base
+ // To obtain the base data source underneath a Join
+ // we also iterate through the base of the FilterDS and UnnestDS in its path
+ // the base of which can be a concrete data source
+ // This also means that an addition of a new datasource
+ // Will need an instanceof check here
+ // A future work should look into if the flattenJoin
+ // can be refactored to omit these instanceof checks
+ while (current instanceof JoinDataSource || current instanceof UnnestDataSource || current instanceof FilteredDataSource) {
+ if (current instanceof JoinDataSource) {
+ final JoinDataSource joinDataSource = (JoinDataSource) current;
+ current = joinDataSource.getLeft();
+ currentDimFilter = validateLeftFilter(current, joinDataSource.getLeftFilter());
+ preJoinableClauses.add(
+ new PreJoinableClause(
+ joinDataSource.getRightPrefix(),
+ joinDataSource.getRight(),
+ joinDataSource.getJoinType(),
+ joinDataSource.getConditionAnalysis()
+ )
+ );
+ } else if (current instanceof UnnestDataSource) {
+ final UnnestDataSource unnestDataSource = (UnnestDataSource) current;
+ current = unnestDataSource.getBase();
+ } else {
+ final FilteredDataSource filteredDataSource = (FilteredDataSource) current;
+ current = filteredDataSource.getBase();
+ }
Review Comment:
this logic is wrong ; the meaning of these datasources are discarded as `preJoinableClauses` are taken into account and nothing else
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Updating plans when using joins with unnest on the left (druid)
Posted by "somu-imply (via GitHub)" <gi...@apache.org>.
somu-imply commented on code in PR #15075:
URL: https://github.com/apache/druid/pull/15075#discussion_r1348995898
##########
processing/src/main/java/org/apache/druid/query/JoinDataSource.java:
##########
@@ -501,20 +509,37 @@ private static Triple<DataSource, DimFilter, List<PreJoinableClause>> flattenJoi
DimFilter currentDimFilter = null;
final List<PreJoinableClause> preJoinableClauses = new ArrayList<>();
- while (current instanceof JoinDataSource) {
- final JoinDataSource joinDataSource = (JoinDataSource) current;
- current = joinDataSource.getLeft();
- currentDimFilter = validateLeftFilter(current, joinDataSource.getLeftFilter());
- preJoinableClauses.add(
- new PreJoinableClause(
- joinDataSource.getRightPrefix(),
- joinDataSource.getRight(),
- joinDataSource.getJoinType(),
- joinDataSource.getConditionAnalysis()
- )
- );
+ // There can be queries like
+ // Join of Unnest of Join of Unnest of Filter
+ // so these checks are needed to be ORed
+ // to get the base
+ // This also means that an addition of a new datasource
+ // Will need an instanceof check here
+ // A future work should look into if the flattenJoin
+ // can be refactored to omit these instanceof checks
+ while (current instanceof JoinDataSource || current instanceof UnnestDataSource || current instanceof FilteredDataSource) {
+ if (current instanceof JoinDataSource) {
+ final JoinDataSource joinDataSource = (JoinDataSource) current;
+ current = joinDataSource.getLeft();
+ currentDimFilter = validateLeftFilter(current, joinDataSource.getLeftFilter());
+ preJoinableClauses.add(
+ new PreJoinableClause(
+ joinDataSource.getRightPrefix(),
+ joinDataSource.getRight(),
+ joinDataSource.getJoinType(),
+ joinDataSource.getConditionAnalysis()
+ )
+ );
+ } else if (current instanceof UnnestDataSource) {
Review Comment:
I'll add comments. The `getAnalysis()` of an Unnest or a filteredDS always delegates to its base. So flattening through a Join->Unnest->Join kind of scenario to get the base data source makes sense as it goes down to find the base concrete data source. In this PR, the filters on the filteredDataSource and unnestDataSource are not pushed down to the left of the join, the unnest filter and the filter on the filteredDataSource remain on the data source. I have added an unit test of Join->Unnest->Join will add another UT of Join->Unnest->Filter->Join
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Updating plans when using joins with unnest on the left (druid)
Posted by "somu-imply (via GitHub)" <gi...@apache.org>.
somu-imply commented on code in PR #15075:
URL: https://github.com/apache/druid/pull/15075#discussion_r1348995898
##########
processing/src/main/java/org/apache/druid/query/JoinDataSource.java:
##########
@@ -501,20 +509,37 @@ private static Triple<DataSource, DimFilter, List<PreJoinableClause>> flattenJoi
DimFilter currentDimFilter = null;
final List<PreJoinableClause> preJoinableClauses = new ArrayList<>();
- while (current instanceof JoinDataSource) {
- final JoinDataSource joinDataSource = (JoinDataSource) current;
- current = joinDataSource.getLeft();
- currentDimFilter = validateLeftFilter(current, joinDataSource.getLeftFilter());
- preJoinableClauses.add(
- new PreJoinableClause(
- joinDataSource.getRightPrefix(),
- joinDataSource.getRight(),
- joinDataSource.getJoinType(),
- joinDataSource.getConditionAnalysis()
- )
- );
+ // There can be queries like
+ // Join of Unnest of Join of Unnest of Filter
+ // so these checks are needed to be ORed
+ // to get the base
+ // This also means that an addition of a new datasource
+ // Will need an instanceof check here
+ // A future work should look into if the flattenJoin
+ // can be refactored to omit these instanceof checks
+ while (current instanceof JoinDataSource || current instanceof UnnestDataSource || current instanceof FilteredDataSource) {
+ if (current instanceof JoinDataSource) {
+ final JoinDataSource joinDataSource = (JoinDataSource) current;
+ current = joinDataSource.getLeft();
+ currentDimFilter = validateLeftFilter(current, joinDataSource.getLeftFilter());
+ preJoinableClauses.add(
+ new PreJoinableClause(
+ joinDataSource.getRightPrefix(),
+ joinDataSource.getRight(),
+ joinDataSource.getJoinType(),
+ joinDataSource.getConditionAnalysis()
+ )
+ );
+ } else if (current instanceof UnnestDataSource) {
Review Comment:
I'll add comments. The `getAnalysis()` of an Unnest or a filteredDS always delegates to its base. So flattening through a Join->Unnest->Join kind of scenario makes sense to go down to find the base concrete data source. In this PR, the filters on the filteredDataSource and unnestDataSource are not pushed down to the left of the join, the unnest filter and the filter on the filteredDataSource remain on the data source. I have added an unit test of Join->Unnest->Join will add another UT of Join->Unnest->Filter->Join
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Updating plans when using joins with unnest on the left (druid)
Posted by "clintropolis (via GitHub)" <gi...@apache.org>.
clintropolis commented on code in PR #15075:
URL: https://github.com/apache/druid/pull/15075#discussion_r1348208042
##########
processing/src/main/java/org/apache/druid/query/JoinDataSource.java:
##########
@@ -476,10 +476,18 @@ private Function<SegmentReference, SegmentReference> createSegmentMapFunctionInt
.orElse(null)
)
);
-
+ final Function<SegmentReference, SegmentReference> baseMapFn;
+ if (left instanceof JoinDataSource) {
Review Comment:
this seems worth a comment on what is going on. Is it still ok to do if left is not concrete?
##########
processing/src/main/java/org/apache/druid/query/JoinDataSource.java:
##########
@@ -501,20 +509,37 @@ private static Triple<DataSource, DimFilter, List<PreJoinableClause>> flattenJoi
DimFilter currentDimFilter = null;
final List<PreJoinableClause> preJoinableClauses = new ArrayList<>();
- while (current instanceof JoinDataSource) {
- final JoinDataSource joinDataSource = (JoinDataSource) current;
- current = joinDataSource.getLeft();
- currentDimFilter = validateLeftFilter(current, joinDataSource.getLeftFilter());
- preJoinableClauses.add(
- new PreJoinableClause(
- joinDataSource.getRightPrefix(),
- joinDataSource.getRight(),
- joinDataSource.getJoinType(),
- joinDataSource.getConditionAnalysis()
- )
- );
+ // There can be queries like
+ // Join of Unnest of Join of Unnest of Filter
+ // so these checks are needed to be ORed
+ // to get the base
+ // This also means that an addition of a new datasource
+ // Will need an instanceof check here
+ // A future work should look into if the flattenJoin
+ // can be refactored to omit these instanceof checks
+ while (current instanceof JoinDataSource || current instanceof UnnestDataSource || current instanceof FilteredDataSource) {
+ if (current instanceof JoinDataSource) {
+ final JoinDataSource joinDataSource = (JoinDataSource) current;
+ current = joinDataSource.getLeft();
+ currentDimFilter = validateLeftFilter(current, joinDataSource.getLeftFilter());
+ preJoinableClauses.add(
+ new PreJoinableClause(
+ joinDataSource.getRightPrefix(),
+ joinDataSource.getRight(),
+ joinDataSource.getJoinType(),
+ joinDataSource.getConditionAnalysis()
+ )
+ );
+ } else if (current instanceof UnnestDataSource) {
Review Comment:
it doesn't seem intuitive to me that we can flatten away unnest and filtered datasources, could we add comments explaining why its ok? is it still ok if the unnest datasource is wrapping a join datasource? like does it flatten through it? where does the unnest and filters go in that case?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Updating plans when using joins with unnest on the left (druid)
Posted by "pranavbhole (via GitHub)" <gi...@apache.org>.
pranavbhole commented on code in PR #15075:
URL: https://github.com/apache/druid/pull/15075#discussion_r1347863570
##########
processing/src/main/java/org/apache/druid/query/JoinDataSource.java:
##########
@@ -501,20 +509,37 @@ private static Triple<DataSource, DimFilter, List<PreJoinableClause>> flattenJoi
DimFilter currentDimFilter = null;
final List<PreJoinableClause> preJoinableClauses = new ArrayList<>();
- while (current instanceof JoinDataSource) {
- final JoinDataSource joinDataSource = (JoinDataSource) current;
- current = joinDataSource.getLeft();
- currentDimFilter = validateLeftFilter(current, joinDataSource.getLeftFilter());
- preJoinableClauses.add(
- new PreJoinableClause(
- joinDataSource.getRightPrefix(),
- joinDataSource.getRight(),
- joinDataSource.getJoinType(),
- joinDataSource.getConditionAnalysis()
- )
- );
+ // There can be queries like
+ // Join of Unnest of Join of Unnest of Filter
+ // so these checks are needed to be ORed
+ // to get the base
+ // This also means that an addition of a new datasource
+ // Will need an instanceof check here
+ // A future work should look into if the flattenJoin
+ // can be refactored to omit these instanceof checks
+ while (current instanceof JoinDataSource || current instanceof UnnestDataSource || current instanceof FilteredDataSource) {
Review Comment:
can we add test cases for self join with unnest datasource if we do not have already?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org