Skip to content

Commit f4de93f

Browse files
committed
[SPARK-17618] Guard against invalid comparisons between UnsafeRow and other row formats
1 parent 00be16d commit f4de93f

File tree

1 file changed

+6
-1
lines changed
  • sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions

1 file changed

+6
-1
lines changed

sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeRow.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.esotericsoftware.kryo.io.Input;
3232
import com.esotericsoftware.kryo.io.Output;
3333

34+
import org.apache.spark.sql.catalyst.InternalRow;
3435
import org.apache.spark.sql.types.*;
3536
import org.apache.spark.unsafe.Platform;
3637
import org.apache.spark.unsafe.array.ByteArrayMethods;
@@ -577,8 +578,12 @@ public boolean equals(Object other) {
577578
return (sizeInBytes == o.sizeInBytes) &&
578579
ByteArrayMethods.arrayEquals(baseObject, baseOffset, o.baseObject, o.baseOffset,
579580
sizeInBytes);
581+
} else if (!(other instanceof InternalRow)) {
582+
return false;
583+
} else {
584+
throw new IllegalArgumentException(
585+
"Cannot compare UnsafeRow to " + other.getClass().getName());
580586
}
581-
return false;
582587
}
583588

584589
/**

0 commit comments

Comments
 (0)