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

Handle half-eternity intervals while fetching segments with created dates #15608

Merged

Conversation

AmatyaAvadhanula
Copy link
Contributor

This PR aims to fix a bug in retrieveUsedSegmentsAndCreatedDates where segments would not be returned for input intervals that partially overlap with eternity.

When the year does not lie in [1000, 9999], we fetch segments without a condition on the interval, and filter the results later (Similar to the method in SqlSegmentsMetadataQuery to fetch only payloads for segments)

This PR has:

  • 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.
  • 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.

@kfaraz kfaraz self-requested a review January 8, 2024 03:34
Copy link
Contributor

@kfaraz kfaraz left a comment

Choose a reason for hiding this comment

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

Approach makes sense but minor changes needed in the code.

break;
}
}
final boolean compareAsString = intervals.stream().allMatch(Intervals::canCompareEndpointsAsStrings);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename to compareIntervalsAsString or compareIntervalEndpointsAsString.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

r.getString("created_date")
)
)
.list()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would prefer to build this list and then filter it later in a separate statement only if intervals is non-empty and we couldn't compare as strings.

So something like:

List<Pair<>> list = query.map().list();

if (intervals.isEmpty() || compareAsString) {
  return list;
} else {
  return list.stream().filter().collect();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@kfaraz kfaraz left a comment

Choose a reason for hiding this comment

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

LGTM

@kfaraz kfaraz changed the title Handle all intervals while fetching segments with created dates Handle half-eternity intervals while fetching segments with created dates Jan 8, 2024
@AmatyaAvadhanula AmatyaAvadhanula merged commit 63bfb3e into apache:master Jan 8, 2024
83 checks passed
@LakshSingla LakshSingla added this to the 29.0.0 milestone Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants