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

What's the best way to aggregate on duration? #55

Open
psirenny opened this issue Oct 12, 2023 · 4 comments
Open

What's the best way to aggregate on duration? #55

psirenny opened this issue Oct 12, 2023 · 4 comments

Comments

@psirenny
Copy link

psirenny commented Oct 12, 2023

Hey @benjie!

Our team is trying to add support for aggregating on durations with an interval data type but noticed that's not supported by the library yet. Is it straightforward to add that support? If so, we can take a stab at implementing it and submit PR. Alternatively, we could switch to representing durations with float instead if you recommend that.

@benjie
Copy link
Member

benjie commented Oct 12, 2023

V4 or V5?

@psirenny
Copy link
Author

Sorry, I should have mentioned that it's on V5.

@benjie
Copy link
Member

benjie commented Oct 12, 2023

Weirdly... we already have interval in the codebase:

[INTERVAL_OID]: TYPES.interval, // interval -> interval

I think the isNumberLike detection is too narrow:

isSuitableType: isNumberLike,
/
if (pgType.typcategory === "N") {
if (!pgCodec.extensions) {
pgCodec.extensions = Object.create(null);
}
pgCodec.extensions!.isNumberLike = true;
}
.

Looks like it should be relatively straightforward to fix this; just expand to isNumberLike || isIntervalLike (or similar).

@psirenny
Copy link
Author

Copy that! We'll submit a PR to add support.

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 a pull request may close this issue.

2 participants