Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance RequireTimeCondition to handle complex joins #17408

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

abhishek-chouhan
Copy link
Contributor

Fixes #17407 .

Description

Additions to NativeQueryMaker to handle JoinQueries.
Checks for a valid timefilter on the top level query if the left join data source is a TableDataSource. Makes sure both left and right datasources have valid timefilters and traverses nested join data sources recursively to check for valid time filter. We still ignore InlineDataSource if they're part of the JoinDataSource (existing behavior)

Fixed the bug ...

Renamed the class ...

Added a forbidden-apis entry ...

Release note


Key changed/added classes in this PR
  • NativeQueryMaker

This PR has:

  • [ x] been self-reviewed.
  • 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
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • [ x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

Comment on lines 93 to 95
if (plannerContext.getPlannerConfig().isRequireTimeCondition()
&& !(druidQuery.getDataSource() instanceof InlineDataSource)) {
if (Intervals.ONLY_ETERNITY.equals(findBaseDataSourceIntervals(query))) {
if (!queryHasTimeFilter(query)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this over to DataSourceAnalysis ?
I feel that this would fit better there.

you could use druidQuery.getDataSource().getAnalysis() to access it here.

I think that should also handle the druidQuery.getDataSource() instanceof InlineDataSource correctly; and shouldn't be checked at this point.

Comment on lines 213 to 228
if (dataSource instanceof InlineDataSource) {
return true;
}
if (dataSource instanceof QueryDataSource) {
return queryHasTimeFilter(((QueryDataSource) dataSource).getQuery());
}
if (dataSource instanceof JoinDataSource) {
return joinDataSourceHasTimeFilter((JoinDataSource) dataSource);
}
if (dataSource.getAnalysis().getBaseQuerySegmentSpec().isPresent()) {
return isIntervalNonEternity(dataSource.getAnalysis()
.getBaseQuerySegmentSpec()
.map(QuerySegmentSpec::getIntervals)
.get());
}
return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the pattern of this method makes me wonder if it would be better to have a method on DataSource instead (with a default implementation to return false) so that every relevant subclass could implement it correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for takin a look @kgyrtkirk . Makes sense to have this at the DataSource level. Made the necessary changes.

@github-actions github-actions bot added Area - Batch Ingestion Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 labels Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area - Batch Ingestion Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 Area - Querying
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RequireTimeCondition does not handle complex joins
2 participants