LakshSingla commented on code in PR #14890:
URL: https://github.com/apache/druid/pull/14890#discussion_r1401517608
##########
sql/src/main/java/org/apache/druid/sql/calcite/run/NativeQueryMaker.java:
##########
@@ -155,12 +163,47 @@ public QueryResponse<Object[]> runQuery(final DruidQuery
druidQuery)
);
}
- private List<Interval> findBaseDataSourceIntervals(Query<?> query)
+ private List<Interval> findMaxBaseDataSourceIntervals(DataSource dataSource,
DataSourceAnalysis dsAnalysis, List<Interval> defaults)
{
- return query.getDataSource().getAnalysis()
- .getBaseQuerySegmentSpec()
- .map(QuerySegmentSpec::getIntervals)
- .orElseGet(query::getIntervals);
+ Optional<List<Interval>> intervals =
dsAnalysis.getBaseQuerySegmentSpec().map(QuerySegmentSpec::getIntervals);
+ if (intervals.isPresent()) {
+ return intervals.get();
+ }
+
+ // If dataSource is a instance of JoinDataSource, find the base intervals
of left and right data sources
+ if (dataSource instanceof JoinDataSource) {
+ JoinDataSource joinDataSource = (JoinDataSource) dataSource;
+ DataSource right = joinDataSource.getRight();
+ DataSource left = joinDataSource.getLeft();
+
+ // right data source has a subquery
+ if (right instanceof QueryDataSource) {
+ DataSource rightInner = ((QueryDataSource)
right).getQuery().getDataSource();
+ DataSourceAnalysis rightAnlaysisInner = rightInner.getAnalysis();
+ if (rightInner instanceof JoinDataSource) {
+ return findMaxBaseDataSourceIntervals(rightInner,
rightAnlaysisInner, defaults);
Review Comment:
There is also a DruidQuery#getFiltration method that checks and creates
filtration on a data source. We can refactor the whole thing and move the check
to there instead as well, however, that would need further testing because we
don't want the method's semantics to change. Also, it would only be applicable
to SQL queries.
--
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]