-
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
Fixes missing nth_value
UDAF expr function
#12279
Conversation
/// Returns the nth value in a group of values. | ||
pub fn nth_value( | ||
expr: datafusion_expr::Expr, | ||
n: i64, | ||
order_by: Option<Vec<SortExpr>>, | ||
) -> datafusion_expr::Expr { | ||
let args = vec![expr, lit(n)]; | ||
if let Some(order_by) = order_by { | ||
nth_value_udaf() | ||
.call(args) | ||
.order_by(order_by) | ||
.build() | ||
.unwrap() | ||
} else { | ||
nth_value_udaf().call(args) | ||
} | ||
} |
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.
API changed here.
pub fn nth_value( | ||
expr: datafusion_expr::Expr, | ||
n: i64, | ||
order_by: Option<Vec<SortExpr>>, |
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.
Do we need Option for no ordering case? Can we represent no ordering case with empty vec?
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.
You are right. The option type is extraneous here. I'll make this 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.
Done.
I lack permission to apply the |
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 @jcsherin |
Which issue does this PR close?
Closes #12278.
Rationale for this change
Same as #12278.
What changes are included in this PR?
The API in v40 is:
A better API would be this:
Are these changes tested?
Yes. Logical roundtrip tests, both with and without order by expression.
Are there any user-facing changes?
Yes, this is a breaking change of user-facing API.