-
Notifications
You must be signed in to change notification settings - Fork 165
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
feat: add product function #250
Conversation
extensions/functions_arithmetic.yaml
Outdated
- value: fp32 | ||
nullability: DECLARED_OUTPUT | ||
decomposable: MANY | ||
intermediate: fp64? | ||
return: fp64? |
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.
As with other PRs, why the promotion? For floats especially since all floats represent all real numbers (to some degree of accuracy), but likewise for integers.
See #251 (you're not the first to do it this way and probably won't be the last)
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 pointing this out. I also had the same doubt and I just followed the promotion. Waiting to see how the discussion progress on the promotion conclusion.
extensions/functions_arithmetic.yaml
Outdated
description: Product of a set of values. | ||
impls: | ||
- args: | ||
- options: [ SILENT, SATURATE, ERROR ] |
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.
I'm not sure this should be solved in this PR immediately because it probably also applies to existing stuff, but something to think about for SATURATE
in the context of these types of aggregates... What if the internal accumulator overflows but the net result would be within range? For example, sum:opt_i64(2^63-1, 2^63-1, -2^63-1, -2^63-1)
. Is that required to always yield 0? Or for ERROR
, is it required to throw an error (after all, if the second and third element are swapped it wouldn't overflow)?
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.
Yes this is a valid point. But I guess this is hard to determine. I would say it is better to leave room for overflows. But I could be wrong.
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.
Maybe we should wait with this until we get some more opinions in #251. I'm inclined to say the intermediate value should be the same type, if only because picking i64 feels like an arbitrary "eh, that's probably good enough" decision that doesn't actually solve the problem, but that just makes the overflow question all the more important.
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.
Sure, let’s do that.
bce31a6
to
085ae7a
Compare
@jvanstraten I updated the PR with some modifications. |
It would be clearer if you said 'arithmetic product'. Many people would assume cartesian product. What value does this function return if the input is empty? The documentation should specify. In the discussion for |
It does, we mimicked sum and had it return null. IMO we should either embrace the SQL way and apply its null nonsense consistently across all similar arithmetic aggregations (and also define a @vibhatha, you'll need to rewrite your commit messages (or just rebase them all into one) to make CI pass. |
@jvanstraten I will rebase with an accurate commit msg. |
SQL seems to be getting smarter. For example For statistical functions such as |
99b19b8
to
6e91b75
Compare
@jvanstraten I squashed to a single commit, let's see the CIs. |
6e91b75
to
23bb131
Compare
@jvanstraten I updated the PR with |
a937851
to
648679a
Compare
This PR includes aggregate function
product
.