-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Convert variance sample to udaf #10713
Convert variance sample to udaf #10713
Conversation
@jayzhan211 I'm working on a change, but can you help me understand the semantics here:
Why should the first query succeed but not the second one? Feel free to point me to any SQL / datafusion doc. |
I think it is because of optimize rule |
Ah that makes sense. Thanks! |
I'm thinking about the right way to implement error-raising. Before migration, the logic was implemented in After migration, the error should probably be raised in
What do you think? |
We have |
4fbdb47
to
d9a1562
Compare
4e043ac
to
a26170a
Compare
@yyin-dev There are some error left to fix You can try |
Thanks! I just ran the 3 commands and fixed all problems. Can you trigger the CI again? I don't think I can trigger it myself. |
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.
Thank you @yyin-dev and @jayzhan211 -- I think this looks really nice. I had one very minor comment about use
but otherwise I think this is ready to go
@@ -651,6 +653,7 @@ async fn roundtrip_expr_api() -> Result<()> { | |||
covar_pop(lit(1.5), lit(2.2)), | |||
sum(lit(1)), | |||
median(lit(2)), | |||
var_sample(lit(2.2)), |
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.
💯
use datafusion::functions_aggregate::covariance::{covar_pop, covar_samp}; | ||
use datafusion::functions_aggregate::expr_fn::first_value; |
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.
Can you please change this to use
the exports from datafusion::functions_aggregate::expr_fn
(which I think is the intended external facing API)?
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.
Updated to use exports from expr_fn
.
@@ -149,7 +149,6 @@ impl From<protobuf::AggregateFunction> for AggregateFunction { | |||
protobuf::AggregateFunction::Count => Self::Count, | |||
protobuf::AggregateFunction::ApproxDistinct => Self::ApproxDistinct, | |||
protobuf::AggregateFunction::ArrayAgg => Self::ArrayAgg, | |||
protobuf::AggregateFunction::Variance => Self::Variance, |
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.
🎉
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.
👍
* Without migrating tests * Should fail VAR(DISTINCT) but doesn't * Pass all other tests. * Return error for var(distinct) * Migrate tests * Fix tests * Lint * Fix tests * Fix use
Which issue does this PR close?
Closes #10667 .
Are these changes tested?