-
Notifications
You must be signed in to change notification settings - Fork 180
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
RUST-1604 Add custom bucketing fields to timeseries options #907
Conversation
805ec5c
to
8b5200e
Compare
8b5200e
to
b12e1af
Compare
src/db/options.rs
Outdated
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, TypedBuilder)] | ||
#[serde(rename_all = "camelCase")] | ||
#[builder(field_defaults(default, setter(into)))] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
The drivers ticket description only details a test sync, but the new tests were using options we hadn't implemented yet.