Skip to content

Commit 49d9372

Browse files
committed
address comments
1 parent e36a5d7 commit 49d9372

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -625,10 +625,10 @@ case class ArraysOverlap(left: Expression, right: Expression)
625625
*/
626626
private def fastEval(arr1: ArrayData, arr2: ArrayData): Any = {
627627
var hasNull = false
628-
val (bigger, smaller, biggerDt) = if (arr1.numElements() > arr2.numElements()) {
629-
(arr1, arr2, left.dataType.asInstanceOf[ArrayType])
628+
val (bigger, smaller) = if (arr1.numElements() > arr2.numElements()) {
629+
(arr1, arr2)
630630
} else {
631-
(arr2, arr1, right.dataType.asInstanceOf[ArrayType])
631+
(arr2, arr1)
632632
}
633633
if (smaller.numElements() > 0) {
634634
val smallestSet = new mutable.HashSet[Any]
@@ -766,15 +766,15 @@ case class ArraysOverlap(left: Expression, right: Expression)
766766
s"""
767767
|for (int $j = 0; $j < $smaller.numElements(); $j ++) {
768768
| $compareValues
769-
| if (${ev.value}) {
770-
| break;
771-
| }
772769
|}
773770
""".stripMargin,
774771
s"${ev.isNull} = true;")
775772
s"""
776773
|for (int $i = 0; $i < $bigger.numElements(); $i ++) {
777-
|$isInSmaller
774+
| $isInSmaller
775+
| if (${ev.value}) {
776+
| break;
777+
| }
778778
|}
779779
""".stripMargin
780780
}

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CollectionExpressionsSuite.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ class CollectionExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper
161161

162162
// null handling
163163
checkEvaluation(ArraysOverlap(emptyIntArray, a2), false)
164+
checkEvaluation(ArraysOverlap(
165+
emptyIntArray, Literal.create(Seq(null), ArrayType(IntegerType))), false)
164166
checkEvaluation(ArraysOverlap(Literal.create(null, ArrayType(IntegerType)), a0), null)
165167
checkEvaluation(ArraysOverlap(a0, Literal.create(null, ArrayType(IntegerType))), null)
166168
checkEvaluation(ArraysOverlap(

0 commit comments

Comments
 (0)