Skip to content

SortOrder Unevaluable Expression

SortOrder is an Expression that represents the following operators in a structured query:

Creating Instance

SortOrder takes the following to be created:

SortDirection

SortDirection Default Null Ordering SQL
Ascending NullsFirst ASC
Descending NullsLast DESC

NullOrdering

NullOrdering SQL
NullsFirst NULLS FIRST
NullsLast NULLS LAST

Creating SortOrder

apply(
  child: Expression,
  direction: SortDirection,
  sameOrderExpressions: Seq[Expression] = Seq.empty): SortOrder

apply creates a SortOrder (with the defaultNullOrdering of the given SortDirection).

Catalyst DSL

Catalyst DSL defines the following operators to create SortOrders:

import org.apache.spark.sql.catalyst.dsl.expressions._
val sortNullsLast = 'id.asc_nullsLast
scala> println(sortNullsLast.sql)
`id` ASC NULLS LAST

Unevaluable

SortOrder is an Unevaluable expression.

Physical Operators

SortOrder is used to specify the output data ordering requirements and the required child ordering of physical operators.

Back to top