dbatomic commented on code in PR #45592:
URL: https://github.com/apache/spark/pull/45592#discussion_r1535254272
##########
sql/api/src/main/scala/org/apache/spark/sql/types/StringType.scala:
##########
@@ -41,12 +37,22 @@ class StringType private(val collationId: Int) extends
AtomicType with Serializa
*/
def isBinaryCollation: Boolean =
CollationFactory.fetchCollation(collationId).isBinaryCollation
+ /**
+ * Spark internal collation implies that strings are considered equal only
if they are
+ * byte for byte equal. E.g. all accent or case-insensitive collations are
considered non-binary.
+ * Also their comparison does not require ICU library calls, as ordering
follows
+ * spark internal implementation. If this field is true, byte level
operations can be
+ * used against this datatype (e.g. for equality, hashing and sorting).
+ */
+ def isUTF8BinaryCollation: Boolean =
Review Comment:
Maybe this should be the naming:
1) Keep `isUTF8Binary` (or explicitly check id). This is mostly used for
naming - e.g. typeName in StringType needs to check this. If that is the only
place we don't need to expose it in CollationFactory.
2) Add `supportsBinaryEquality` - check whether equality can be done on
binary level for this collation.
3) Add `supportBinaryOrdering` - check whether sort can be done on binary
level.
Probably isUTF8Binary and supportsBinaryOrdering will be true only for
UTF8_BINARY, since I don't think that any other ICU driven library supports
binary sort. But in future, user defined collations may support 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]