Skip to content
Snippets Groups Projects
Commit 7c7c7529 authored by Liang-Chi Hsieh's avatar Liang-Chi Hsieh Committed by Reynold Xin
Browse files

[MINOR] [SQL] Remove canEqual in Row

As `InternalRow` does not extend `Row` now, I think we can remove it.

Author: Liang-Chi Hsieh <viirya@appier.com>

Closes #8170 from viirya/remove_canequal.
parent bd35385d
No related branches found
No related tags found
No related merge requests found
......@@ -364,31 +364,10 @@ trait Row extends Serializable {
false
}
/**
* Returns true if we can check equality for these 2 rows.
* Equality check between external row and internal row is not allowed.
* Here we do this check to prevent call `equals` on external row with internal row.
*/
protected def canEqual(other: Row) = {
// Note that `Row` is not only the interface of external row but also the parent
// of `InternalRow`, so we have to ensure `other` is not a internal row here to prevent
// call `equals` on external row with internal row.
// `InternalRow` overrides canEqual, and these two canEquals together makes sure that
// equality check between external Row and InternalRow will always fail.
// In the future, InternalRow should not extend Row. In that case, we can remove these
// canEqual methods.
!other.isInstanceOf[InternalRow]
}
override def equals(o: Any): Boolean = {
if (!o.isInstanceOf[Row]) return false
val other = o.asInstanceOf[Row]
if (!canEqual(other)) {
throw new UnsupportedOperationException(
"cannot check equality between external and internal rows")
}
if (other eq null) return false
if (length != other.length) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment