cloud-fan commented on code in PR #47521: URL: https://github.com/apache/spark/pull/47521#discussion_r1720573546
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/types/PhysicalDataType.scala: ########## @@ -234,10 +234,72 @@ case object PhysicalLongType extends PhysicalLongType case class PhysicalMapType(keyType: DataType, valueType: DataType, valueContainsNull: Boolean) extends PhysicalDataType { - override private[sql] def ordering = - throw QueryExecutionErrors.orderedOperationUnsupportedByDataTypeError("PhysicalMapType") - override private[sql] type InternalType = Any + // maps are not orderable, we use `ordering` just to support group by queries + override private[sql] def ordering = interpretedOrdering + override private[sql] type InternalType = MapData @transient private[sql] lazy val tag = typeTag[InternalType] + + @transient + private[sql] lazy val interpretedOrdering: Ordering[MapData] = new Ordering[MapData] { + private[this] val keyOrdering = + PhysicalDataType(keyType).ordering.asInstanceOf[Ordering[Any]] + private[this] val valuesOrdering = + PhysicalDataType(valueType).ordering.asInstanceOf[Ordering[Any]] + + override def compare(left: MapData, right: MapData): Int = { Review Comment: how do we sort map values in the codegen path? -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org