AngersZhuuuu commented on a change in pull request #34077:
URL: https://github.com/apache/spark/pull/34077#discussion_r715462036
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/util/SQLOpenHashSet.scala
##########
@@ -60,6 +61,57 @@ class SQLOpenHashSet[@specialized(Long, Int, Double, Float)
T: ClassTag](
}
object SQLOpenHashSet {
+ def withNullCheckFunc(
+ dataType: DataType,
+ hashSet: SQLOpenHashSet[Any],
+ handleNotNull: Any => Unit,
+ handleNull: () => Unit): ArrayData => Int => Unit = {
+ (array: ArrayData) => {
+ (index: Int) =>
+ if (array.isNullAt(index)) {
+ if (!hashSet.containsNull) {
+ hashSet.addNull
+ handleNull()
+ }
+ } else {
+ val elem = array.get(index, dataType)
+ handleNotNull(elem)
+ }
+ }
+ }
+
+ def withNullCheckCode(
+ arrayType1: DataType,
+ arrayType2: DataType,
Review comment:
> why does this take 2 array types?
Hmm since for binary array type, need to check left right datatype if
contains null.
```
def withArray2NullCheck(body: String): String =
if (right.dataType.asInstanceOf[ArrayType].containsNull) {
if (left.dataType.asInstanceOf[ArrayType].containsNull) {
s"""
|if ($array2.isNullAt($i)) {
| $hashSet.addNull();
|} else {
| $body
|}
""".stripMargin
} else {
// if array1's element is not nullable, we don't need to track
the null element index.
s"""
|if (!$array2.isNullAt($i)) {
| $body
|}
""".stripMargin
}
} else {
body
}
```
--
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]