Skip to content

Commit bfe1451

Browse files
committed
Update to allow sorting by null literals
1 parent 2f1b802 commit bfe1451

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,14 @@ trait CheckAnalysis {
9898

9999
aggregateExprs.foreach(checkValidAggregateExpression)
100100

101-
case Sort(order, _, _) if !order.forall(_.dataType.isInstanceOf[AtomicType]) =>
102-
val c = order.filterNot(_.dataType.isInstanceOf[AtomicType]).head
103-
failAnalysis(s"Sorting is not supported for columns of type ${c.dataType.simpleString}")
101+
case Sort(orders, _, _) =>
102+
def checkValidSortOrder(order: SortOrder): Unit = order.dataType match {
103+
case t: AtomicType => // OK
104+
case NullType => // OK
105+
case t =>
106+
failAnalysis(s"Sorting is not supported for columns of type ${t.simpleString}")
107+
}
108+
orders.foreach(checkValidSortOrder)
104109

105110
case _ => // Fallbacks to the following checks
106111
}

0 commit comments

Comments
 (0)