cloud-fan commented on code in PR #45290:
URL: https://github.com/apache/spark/pull/45290#discussion_r1507922548


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/UnsafeRowUtils.scala:
##########
@@ -197,4 +197,21 @@ object UnsafeRowUtils {
       s"rowSizeInBytes: ${row.getSizeInBytes}\nfieldStatus:\n" +
       fieldStatusArr.mkString("\n")
   }
+
+  /**
+   * True if comparisons, equality and hashing can be done purely on binary 
representation of
+   * Unsafe row. i.e. binary(e1) = binary(e2) <=> e1 = e2.
+   * e.g. this is not true for non-binary collations (any case/accent 
insensitive collation
+   * can lead to rows being semantically equal even though their binary 
representations differ).
+   */
+  def isBinaryStable(dataType: DataType): Boolean = dataType match {
+    case st: StringType => 
CollationFactory.fetchCollation(st.collationId).isBinaryCollation
+    case _: AtomicType => true
+    case _: ArrayType => 
isBinaryStable(dataType.asInstanceOf[ArrayType].elementType)
+    case _: MapType => isBinaryStable(dataType.asInstanceOf[MapType].keyType) 
&&
+      isBinaryStable(dataType.asInstanceOf[MapType].valueType)
+    case _: StructType =>

Review Comment:
   ditto, `case StructType(fields) => ...`



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

Reply via email to