Skip to content

Commit

Permalink
better sort expr APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Sep 28, 2024
1 parent e645d06 commit 7d19e41
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions datafusion/physical-expr-common/src/sort_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,26 +96,34 @@ impl PhysicalSortExpr {
}

/// Set the sort sort options to ASC
pub fn asc(mut self) -> Self {
self.options.descending = false;
self
pub fn asc(self) -> Self {
self.with_descending(false)
}

/// Set the sort sort options to DESC
pub fn desc(mut self) -> Self {
self.options.descending = true;
self
pub fn desc(self) -> Self {
self.with_descending(true)
}

/// Set the sort sort options to NULLS FIRST
pub fn nulls_first(mut self) -> Self {
self.options.nulls_first = true;
/// set the sort options `descending` flag
pub fn with_descending(mut self, descending: bool) -> Self {
self.options.descending = descending;
self
}

/// Set the sort sort options to NULLS LAST
pub fn nulls_last(mut self) -> Self {
self.options.nulls_first = false;
/// Set the sort options to NULLS FIRST
pub fn nulls_first(self) -> Self {
self.with_nulls_first(true)
}

/// Set the sort options to NULLS LAST
pub fn nulls_last(self) -> Self {
self.with_nulls_first(false)
}

/// set the sort options `nulls_first` flag
pub fn with_nulls_first(mut self, nulls_first: bool) -> Self {
self.options.nulls_first = nulls_first;
self
}
}
Expand Down

0 comments on commit 7d19e41

Please sign in to comment.