pub struct SortOptions {
pub descending: bool,
pub nulls_first: bool,
}
Expand description
Options that define the sort order of a given column
The default sorts equivalently to of ASC NULLS FIRST
in SQL (i.e.
ascending order with nulls sorting before any other values).
§Example creation
// configure using explicit initialization
let options = SortOptions {
descending: false,
nulls_first: true,
};
// Default is ASC NULLs First
assert_eq!(options, SortOptions::default());
assert_eq!(options.to_string(), "ASC NULLS FIRST");
// Configure using builder APIs
let options = SortOptions::default()
.desc()
.nulls_first();
assert_eq!(options.to_string(), "DESC NULLS FIRST");
// configure using explicit field values
let options = SortOptions::default()
.with_descending(false)
.with_nulls_first(false);
assert_eq!(options.to_string(), "ASC NULLS LAST");
§Example operations
It is also possible to negate the sort options using the !
operator.
use arrow_schema::SortOptions;
let options = !SortOptions::default();
assert_eq!(options.to_string(), "DESC NULLS LAST");
Fields§
§descending: bool
Whether to sort in descending order
nulls_first: bool
Whether to sort nulls first
Implementations§
Source§impl SortOptions
impl SortOptions
Sourcepub fn desc(self) -> Self
pub fn desc(self) -> Self
Set this sort options to sort in descending order
See Self::with_descending to explicitly set the underlying field
Sourcepub fn asc(self) -> Self
pub fn asc(self) -> Self
Set this sort options to sort in ascending order
See Self::with_descending to explicitly set the underlying field
Sourcepub fn nulls_first(self) -> Self
pub fn nulls_first(self) -> Self
Set this sort options to sort nulls first
See Self::with_nulls_first to explicitly set the underlying field
Sourcepub fn nulls_last(self) -> Self
pub fn nulls_last(self) -> Self
Set this sort options to sort nulls last
See Self::with_nulls_first to explicitly set the underlying field
Sourcepub fn with_descending(self, descending: bool) -> Self
pub fn with_descending(self, descending: bool) -> Self
Set this sort options to sort descending if argument is true
Sourcepub fn with_nulls_first(self, nulls_first: bool) -> Self
pub fn with_nulls_first(self, nulls_first: bool) -> Self
Set this sort options to sort nulls first if argument is true
Trait Implementations§
Source§impl Clone for SortOptions
impl Clone for SortOptions
Source§fn clone(&self) -> SortOptions
fn clone(&self) -> SortOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SortOptions
impl Debug for SortOptions
Source§impl Default for SortOptions
impl Default for SortOptions
Source§impl Display for SortOptions
impl Display for SortOptions
Source§impl Hash for SortOptions
impl Hash for SortOptions
Source§impl Not for SortOptions
!
operator is overloaded for SortOptions
to invert boolean
fields of the struct.
impl Not for SortOptions
!
operator is overloaded for SortOptions
to invert boolean
fields of the struct.
Source§type Output = SortOptions
type Output = SortOptions
!
operator.Source§fn not(self) -> SortOptions
fn not(self) -> SortOptions
!
operation. Read more