MaxGekk commented on code in PR #48598:
URL: https://github.com/apache/spark/pull/48598#discussion_r1812633025


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala:
##########
@@ -767,6 +777,35 @@ case class InSet(child: Expression, hset: Set[Any]) 
extends UnaryExpression with
   override protected def withNewChildInternal(newChild: Expression): InSet = 
copy(child = newChild)
 }
 
+object InSet {
+  class LCaseSet(inputSet: Set[Any]) extends immutable.Set[Any] with 
Serializable {
+    private val strSet = inputSet.map { s =>
+      if (s == null) null
+      else 
CollationAwareUTF8String.lowerCaseCodePoints(s.asInstanceOf[UTF8String])
+    }
+    override def incl(elem: Any): Set[Any] = inputSet.incl(elem)
+    override def excl(elem: Any): Set[Any] = inputSet.excl(elem)
+    override def iterator: Iterator[Any] = inputSet.iterator
+    override def contains(elem: Any): Boolean = {
+      assert(elem != null, "InSet guarantees non-null input")
+      
strSet.contains(CollationAwareUTF8String.lowerCaseCodePoints(elem.asInstanceOf[UTF8String]))

Review Comment:
   Till it sits inside of the scope of `InSet`, it doesn't matter from my point 
of view. But as soon as you move it out to some common place like 
`CollationUtils`, you cannot make any assumptions. For example:
   1. `InSet` guarantees non-null inputs, and we will have to add explicit 
checks
   2. `InSet` assumes `set` is serializable. So, you have to make it such.
   3. Properly implement other methods besides of the default constructor and 
`contains()`. `InSet` doesn't need them.   



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

Reply via email to