pub struct PhysicalSortRequirement {
pub expr: Arc<dyn PhysicalExpr>,
pub options: Option<SortOptions>,
}
Expand description
Represents sort requirement associated with a plan
If the requirement includes SortOptions
then both the
expression and the sort options must match.
If the requirement does not include SortOptions
) then only the
expressions must match.
§Examples
With sort options (A
, DESC NULLS FIRST
):
ORDER BY A DESC NULLS FIRST
matchesORDER BY A ASC NULLS FIRST
does not match (ASC
vsDESC
)ORDER BY B DESC NULLS FIRST
does not match (different expr)
Without sort options (A
, None):
ORDER BY A DESC NULLS FIRST
matchesORDER BY A ASC NULLS FIRST
matches (ASC
andNULL
options ignored)ORDER BY B DESC NULLS FIRST
does not match (different expr)
Fields§
§expr: Arc<dyn PhysicalExpr>
Physical expression representing the column to sort
options: Option<SortOptions>
Option to specify how the given column should be sorted. If unspecified, there are no constraints on sort options.
Implementations§
Source§impl PhysicalSortRequirement
impl PhysicalSortRequirement
Sourcepub fn new(
expr: Arc<dyn PhysicalExpr>,
options: Option<SortOptions>,
) -> PhysicalSortRequirement
pub fn new( expr: Arc<dyn PhysicalExpr>, options: Option<SortOptions>, ) -> PhysicalSortRequirement
Creates a new requirement.
If options
is Some(..)
, creates an exact
requirement,
which must match both options
and expr
.
If options
is None
, Creates a new expr_only
requirement,
which must match only expr
.
See PhysicalSortRequirement
for examples.
Sourcepub fn with_expr(self, expr: Arc<dyn PhysicalExpr>) -> PhysicalSortRequirement
pub fn with_expr(self, expr: Arc<dyn PhysicalExpr>) -> PhysicalSortRequirement
Replace the required expression for this requirement with the new one
Sourcepub fn compatible(&self, other: &PhysicalSortRequirement) -> bool
pub fn compatible(&self, other: &PhysicalSortRequirement) -> bool
Returns whether this requirement is equal or more specific than other
.
Sourcepub fn from_sort_exprs<'a>(
ordering: impl IntoIterator<Item = &'a PhysicalSortExpr>,
) -> LexRequirement
pub fn from_sort_exprs<'a>( ordering: impl IntoIterator<Item = &'a PhysicalSortExpr>, ) -> LexRequirement
Returns PhysicalSortRequirement
that requires the exact
sort of the PhysicalSortExpr
s in ordering
This method takes &'a PhysicalSortExpr
to make it easy to
use implementing ExecutionPlan::required_input_ordering
.
Sourcepub fn to_sort_exprs(
requirements: impl IntoIterator<Item = PhysicalSortRequirement>,
) -> LexOrdering
pub fn to_sort_exprs( requirements: impl IntoIterator<Item = PhysicalSortRequirement>, ) -> LexOrdering
Converts an iterator of PhysicalSortRequirement
into a Vec
of PhysicalSortExpr
s.
This function converts PhysicalSortRequirement
to PhysicalSortExpr
for each entry in the input. If required ordering is None for an entry
default ordering ASC, NULLS LAST
if given (see the PhysicalSortExpr::from
).
Trait Implementations§
Source§impl Clone for PhysicalSortRequirement
impl Clone for PhysicalSortRequirement
Source§fn clone(&self) -> PhysicalSortRequirement
fn clone(&self) -> PhysicalSortRequirement
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PhysicalSortRequirement
impl Debug for PhysicalSortRequirement
Source§impl Display for PhysicalSortRequirement
impl Display for PhysicalSortRequirement
Source§impl From<PhysicalSortExpr> for PhysicalSortRequirement
impl From<PhysicalSortExpr> for PhysicalSortRequirement
Source§fn from(value: PhysicalSortExpr) -> PhysicalSortRequirement
fn from(value: PhysicalSortExpr) -> PhysicalSortRequirement
Source§impl From<PhysicalSortRequirement> for PhysicalSortExpr
impl From<PhysicalSortRequirement> for PhysicalSortExpr
Source§fn from(value: PhysicalSortRequirement) -> PhysicalSortExpr
fn from(value: PhysicalSortRequirement) -> PhysicalSortExpr
If options is None
, the default sort options ASC, NULLS LAST
is used.
The default is picked to be consistent with PostgreSQL: https://www.postgresql.org/docs/current/queries-order.html
Source§impl FromIterator<PhysicalSortRequirement> for LexRequirement
impl FromIterator<PhysicalSortRequirement> for LexRequirement
Source§fn from_iter<T>(iter: T) -> LexRequirementwhere
T: IntoIterator<Item = PhysicalSortRequirement>,
fn from_iter<T>(iter: T) -> LexRequirementwhere
T: IntoIterator<Item = PhysicalSortRequirement>,
Source§impl PartialEq for PhysicalSortRequirement
impl PartialEq for PhysicalSortRequirement
Auto Trait Implementations§
impl Freeze for PhysicalSortRequirement
impl !RefUnwindSafe for PhysicalSortRequirement
impl Send for PhysicalSortRequirement
impl Sync for PhysicalSortRequirement
impl Unpin for PhysicalSortRequirement
impl !UnwindSafe for PhysicalSortRequirement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more