-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Convert Option<Vec<sort expression>> to Vec<sort expression> #16615
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
base: main
Are you sure you want to change the base?
Conversation
@findepi Please take a look. |
from_substrait_sorts(consumer, &f.sorts, input.schema()) | ||
.await?, | ||
) | ||
from_substrait_sorts(consumer, &f.sorts, input.schema()).await? |
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 we make from_substrait_sorts
work with an empty slice?
Some(exprs) => create_physical_sort_exprs( | ||
exprs, | ||
let order_bys = if !order_by.is_empty() { | ||
create_physical_sort_exprs( |
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 we make create_physical_sort_exprs
work with empty slices?
datafusion/expr/src/expr.rs
Outdated
/// List of expressions to feed to the functions as arguments | ||
pub args: Vec<Expr>, | ||
/// Optional filter | ||
pub filter: Option<Box<Expr>>, | ||
/// Optional ORDER BY applied prior to aggregating | ||
pub order_by: Option<Vec<Expr>>, | ||
pub order_by: Vec<Sort>, |
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 understand why the Optional was removed (that's the purpose of this PR). I don't yet understand why Expr was replaced with Sort thought.
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.
This was a mistake during the batch replacement process, but since this struct has never been used in the project, it did not cause any exceptions. I'll change it back.
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.
And we can open another issue to discuss whether it is more reasonable to change it to the Sort type, because other order_by fields are defined as the Sort type. Or we can directly delete this unused struct.
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.
if it's unused, let's delete it, prefferrably in a separate PR
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.
OK. Should it be before or after this PR?
pub fn first_value(expression: Expr, order_by: Option<Vec<SortExpr>>) -> Expr { | ||
if let Some(order_by) = order_by { | ||
pub fn first_value(expression: Expr, order_by: Vec<SortExpr>) -> Expr { | ||
if !order_by.is_empty() { |
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.
This condition seems redundant now.
pub fn last_value(expression: Expr, order_by: Option<Vec<SortExpr>>) -> Expr { | ||
if let Some(order_by) = order_by { | ||
pub fn last_value(expression: Expr, order_by: Vec<SortExpr>) -> Expr { | ||
if !order_by.is_empty() { |
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.
This condition seems redundant now.
&& a.nulls_first == b.nulls_first | ||
&& a.expr.normalize_eq(&b.expr) | ||
}) | ||
&& self_order_by.len() == other_order_by.len() |
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.
The length check was missing, thanks for adding it.
Coincidentally, recently i was reflecting about precisely this -- how Iter::zip
is error-prone to use.
@@ -821,7 +821,7 @@ impl ExprFuncBuilder { | |||
|
|||
let fun_expr = match fun { | |||
ExprFuncKind::Aggregate(mut udaf) => { | |||
udaf.params.order_by = order_by; | |||
udaf.params.order_by = order_by.unwrap_or_default(); |
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 a follow-up, the builder order_by
field can be changed to non-optional as well
@alamb this is a breaking change, right? |
Probably -- we normally add the api change label, which I just did This is the stated policy: https://datafusion.apache.org/contributor-guide/api-health.html |
We have a long history of releasing breaking API changes so i think it is best just to use your judgement here |
Which issue does this PR close?
Option<Vec<sort expression>>
toVec<sort expression>
#12195.Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?