kgyrtkirk commented on code in PR #17354:
URL: https://github.com/apache/druid/pull/17354#discussion_r1812666590
##########
processing/src/main/java/org/apache/druid/query/Query.java:
##########
@@ -285,4 +298,22 @@ default Interval getSingleInterval()
)
);
}
+
+ default Query<T> withDataSources(List<DataSource> children)
+ {
+ if (children.size() != 1) {
+ throw new IAE("Must have exactly one child");
+ }
+ return withDataSource(Iterables.getOnlyElement(children));
+ }
Review Comment:
these were needed for 2 reasons:
* before this PR the `DataSource` class alredy had [[get|with]Children
methods](https://github.com/apache/druid/blob/1e96c85b383fdaff34faad7c3afbe3eb67c5d6c4/processing/src/main/java/org/apache/druid/query/DataSource.java#L56-L65)
; since this changes the the `Query` to have multiple of them - it feeled like
communicating it clearly is better - so that all existing places it
* I had to also use this in `recursivelyClearContext`
* `generateSubqueryIds` and `insertSubqueryIds` use these to set context
variables
alternative options could be:
* there is possibly another way to not have these methods: provide a visitor
interface which could "visit" all queries / datasources optionally rewriting
them
* it might worth a try to service these differently from `QueryDataSource`
(so that it does not appear on the main `Query` interface)
I've done the second approach from above; I'm not sure about the complexity
that will cause in the long run but its not that bad right now...I had to add 3
instanceof-s:
* 2 in `QueryDataSource`
* 1 in a test related `clearRecursivelyContext` method
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]