hvanhovell commented on code in PR #40651:
URL: https://github.com/apache/spark/pull/40651#discussion_r1159210563
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ordering.scala:
##########
@@ -57,20 +57,10 @@ class InterpretedOrdering(ordering: Seq[SortOrder]) extends
BaseOrdering {
return if (order.nullOrdering == NullsFirst) 1 else -1
} else {
val comparison = order.dataType match {
- case dt: AtomicType if order.direction == Ascending =>
- dt.ordering.asInstanceOf[Ordering[Any]].compare(left, right)
- case dt: AtomicType if order.direction == Descending =>
- - dt.ordering.asInstanceOf[Ordering[Any]].compare(left, right)
- case a: ArrayType if order.direction == Ascending =>
- a.interpretedOrdering.asInstanceOf[Ordering[Any]].compare(left,
right)
- case a: ArrayType if order.direction == Descending =>
- - a.interpretedOrdering.asInstanceOf[Ordering[Any]].compare(left,
right)
- case s: StructType if order.direction == Ascending =>
- s.interpretedOrdering.asInstanceOf[Ordering[Any]].compare(left,
right)
- case s: StructType if order.direction == Descending =>
- - s.interpretedOrdering.asInstanceOf[Ordering[Any]].compare(left,
right)
- case other =>
- throw
QueryExecutionErrors.orderedOperationUnsupportedByDataTypeError(other)
+ case dt if order.direction == Ascending =>
+ PhysicalDataType.ordering(dt).compare(left, right)
Review Comment:
We really shouldn't resolve the ordering during execution. I know the old
code does this, but the old is a bit quicker than the new code. It would be
better to resolve it once as a field and then keep reusing it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]