Skip to content

RUST-1604 Add custom bucketing fields to timeseries options #907

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

Merged
merged 4 commits into from
Jul 5, 2023

Conversation

isabelatkinson
Copy link
Contributor

@isabelatkinson isabelatkinson commented Jun 29, 2023

The drivers ticket description only details a test sync, but the new tests were using options we hadn't implemented yet.

@isabelatkinson isabelatkinson force-pushed the timeseries-scalability branch 2 times, most recently from 805ec5c to 8b5200e Compare June 29, 2023 22:05
@isabelatkinson isabelatkinson force-pushed the timeseries-scalability branch from 8b5200e to b12e1af Compare June 29, 2023 22:05
@isabelatkinson isabelatkinson marked this pull request as ready for review June 30, 2023 15:58
@isabelatkinson isabelatkinson requested a review from abr-egn June 30, 2023 15:59
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, TypedBuilder)]
#[serde(rename_all = "camelCase")]
#[builder(field_defaults(default, setter(into)))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a backwards-compatible change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. I did some testing and it looks like setter(into) will break this:

let options = TimeseriesOptions::builder()
        .time_field("x".into())
        .meta_field(Some("y".into()))
        .granularity(Some(TimeseriesGranularity::Hours))
        .build();

so we'll need to leave that out for now. We could also override the default setting for the existing fields using #[builder(setter(!into))] (see docs), but the inconsistency between fields might be confusing.

The lack of default here, however, is currently pretty prohibitive, as the following won't compile:

let options = TimeseriesOptions::builder().time_field("x".into()).build();

because the builder doesn't default the optional fields to None. This means that users currently need to specify all fields, and therefore adding new fields will break code. I can't think of a scenario in which default will break anything so I think it's a fine addition, but if we want to play it safe we could just defer these fields until 3.0.

As an aside, I know we decided a while back that these we should use default and setter(into) for all of our TypedBuilder implementations, but I can't find any documentation of this choice outside of (#368). I remember some convos about this in the team channel and the Prisma channel, but those would've been cleared a long time ago because of the slack retention policy. It looks like there are some structs in our API that don't have these options set, so I filed RUST-1695 to fix this for 3.0 and document/enforce the policy to avoid running into this in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for testing this! I also can't see any way default would be breaking, so that seems like the right way here.

@isabelatkinson isabelatkinson requested a review from abr-egn July 5, 2023 16:40
Copy link
Contributor

@abr-egn abr-egn left a comment

Choose a reason for hiding this comment

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

LGTM!

@isabelatkinson isabelatkinson merged commit 83a2271 into mongodb:main Jul 5, 2023
@isabelatkinson isabelatkinson deleted the timeseries-scalability branch August 30, 2023 16: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