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>) -> Self
pub fn new(expr: Arc<dyn PhysicalExpr>, options: Option<SortOptions>) -> Self
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>) -> Self
pub fn with_expr(self, expr: Arc<dyn PhysicalExpr>) -> Self
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>
) -> Vec<PhysicalSortRequirement>
pub fn from_sort_exprs<'a>( ordering: impl IntoIterator<Item = &'a PhysicalSortExpr> ) -> Vec<PhysicalSortRequirement>
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>
) -> Vec<PhysicalSortExpr>
pub fn to_sort_exprs( requirements: impl IntoIterator<Item = PhysicalSortRequirement> ) -> Vec<PhysicalSortExpr>
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) -> Self
fn from(value: PhysicalSortExpr) -> Self
source§impl From<PhysicalSortRequirement> for PhysicalSortExpr
impl From<PhysicalSortRequirement> for PhysicalSortExpr
source§fn from(value: PhysicalSortRequirement) -> Self
fn from(value: PhysicalSortRequirement) -> Self
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 PartialEq<PhysicalSortRequirement> for PhysicalSortRequirement
impl PartialEq<PhysicalSortRequirement> for PhysicalSortRequirement
source§fn eq(&self, other: &PhysicalSortRequirement) -> bool
fn eq(&self, other: &PhysicalSortRequirement) -> bool
self
and other
values to be equal, and is used
by ==
.