This is an automated email from the ASF dual-hosted git repository.

viirya pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-comet.git


The following commit(s) were added to refs/heads/main by this push:
     new a7a5f895 chore: Add more unsupported cases to supportedSortType (#825)
a7a5f895 is described below

commit a7a5f8959ce357b0c2d2063d6cd38f14eed9c997
Author: Liang-Chi Hsieh <[email protected]>
AuthorDate: Tue Aug 13 18:01:41 2024 -0700

    chore: Add more unsupported cases to supportedSortType (#825)
---
 .../org/apache/comet/serde/QueryPlanSerde.scala    | 30 +++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala 
b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
index 717b3598..8b994d62 100644
--- a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
+++ b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
@@ -3069,9 +3069,33 @@ object QueryPlanSerde extends Logging with 
ShimQueryPlanSerde with CometExprShim
   // TODO: Remove this constraint when we upgrade to new arrow-rs including
   // https://github.com/apache/arrow-rs/pull/6225
   def supportedSortType(op: SparkPlan, sortOrder: Seq[SortOrder]): Boolean = {
-    if (sortOrder.length == 1 && 
sortOrder.head.dataType.isInstanceOf[StructType]) {
-      withInfo(op, "Sort on single struct column is not supported")
-      false
+    def canRank(dt: DataType): Boolean = {
+      dt match {
+        case _: ByteType | _: ShortType | _: IntegerType | _: LongType | _: 
FloatType |
+            _: DoubleType | _: TimestampType | _: DecimalType | _: DateType =>
+          true
+        case _: BinaryType | _: StringType => true
+        case _ => false
+      }
+    }
+
+    if (sortOrder.length == 1) {
+      val canSort = sortOrder.head.dataType match {
+        case _: BooleanType => true
+        case _: ByteType | _: ShortType | _: IntegerType | _: LongType | _: 
FloatType |
+            _: DoubleType | _: TimestampType | _: DecimalType | _: DateType =>
+          true
+        case dt if isTimestampNTZType(dt) => true
+        case _: BinaryType | _: StringType => true
+        case ArrayType(elementType, _) => canRank(elementType)
+        case _ => false
+      }
+      if (!canSort) {
+        withInfo(op, s"Sort on single column of type 
${sortOrder.head.dataType} is not supported")
+        false
+      } else {
+        true
+      }
     } else {
       true
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to