carloea2 commented on code in PR #4024:
URL: https://github.com/apache/texera/pull/4024#discussion_r2512968222


##########
common/workflow-operator/src/main/scala/org/apache/amber/operator/sortPartitions/SortPartitionsOpExec.scala:
##########
@@ -47,18 +47,11 @@ class SortPartitionsOpExec(descString: String) extends 
OperatorExecutor {
 
   override def onFinish(port: Int): Iterator[TupleLike] = sortTuples()
 
-  private def compareTuples(t1: Tuple, t2: Tuple): Boolean = {
-    val attributeType = 
t1.getSchema.getAttribute(desc.sortAttributeName).getType
-    val attributeIndex = t1.getSchema.getIndex(desc.sortAttributeName)
-    attributeType match {
-      case AttributeType.LONG =>
-        t1.getField[Long](attributeIndex) < t2.getField[Long](attributeIndex)
-      case AttributeType.INTEGER =>
-        t1.getField[Int](attributeIndex) < t2.getField[Int](attributeIndex)
-      case AttributeType.DOUBLE =>
-        t1.getField[Double](attributeIndex) < 
t2.getField[Double](attributeIndex)
-      case _ =>
-        true // unsupported type
-    }
-  }
+  private def compareTuples(t1: Tuple, t2: Tuple): Boolean =

Review Comment:
   `sortWith `needs a `(Tuple, Tuple) => Boolean`, while 
`AttributeTypeUtils.compare` returns an `Int`
   
   Keeping `compareTuples` separate makes the code easier to read/test and 
reuse, instead of burying that logic inside `sortWith`.



-- 
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]

Reply via email to