Skip to content

Remove timerange root search #5760

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tontinton
Copy link
Contributor

Extract and remove time range from query ast.

To allow for the optimization stage to run if the resulting ast after extracting the time range is a simple query.

Copy link
Collaborator

@rdettai rdettai left a comment

Choose a reason for hiding this comment

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

The change being pretty big, I couldn't go through all of it yet. Here are a few comments already.

Comment on lines +14 to +33
pub(crate) fn extract_start_end_timestamp_from_ast(
query_ast: QueryAst,
timestamp_field: &str,
start_timestamp: &mut Option<i64>,
end_timestamp: &mut Option<i64>,
) -> QueryAst {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This signature is confusing as it is both transforming an owned input and mutating references.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, do you maybe prefer:

pub(crate) fn extract_start_end_timestamp_from_ast(
    query_ast: QueryAst,
    timestamp_field: &str,
    start_timestamp: Option<i64>,
    end_timestamp: Option<i64>,
) -> (QueryAst, Option<i64>, Option<i64>) {

?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the gain from making both the boundary refinement and the extraction at once is marginal, and it would make this PR a lot easier to review (and the code easier to read) to keep refine_start_end_timestamp_from_ast() as is and add a separate method for the extraction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is with transform accepting a value and not borrow of QueryAst, meaning I would need to clone to keep the old signature of refine_start_end_timestamp_from_ast which accepts a &QueryAst, are you ok with this clone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@tontinton tontinton requested a review from rdettai April 29, 2025 17:45
@tontinton tontinton force-pushed the remove-timerange-root-search branch 2 times, most recently from a8afa5d to 28e5e76 Compare April 29, 2025 18:51
To allow for the optimization stage to run if the resulting ast after
extracting the time range is a simple query.
Does the same as RemoveTimestampRange, but even does a little more.
@tontinton tontinton force-pushed the remove-timerange-root-search branch from 28e5e76 to d10c70c Compare April 30, 2025 12:20
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.

2 participants