in core/src/main/java/org/apache/calcite/avatica/Meta.java [1153:1208]
private static boolean equalRows(Iterable<Object> rows, Iterable<Object> otherRows) {
if (null == rows) {
if (null != otherRows) {
return false;
}
} else {
Iterator<Object> iter1 = rows.iterator();
Iterator<Object> iter2 = otherRows.iterator();
while (iter1.hasNext() && iter2.hasNext()) {
Object obj1 = iter1.next();
Object obj2 = iter2.next();
// Can't just call equals on an array
if (obj1 instanceof Object[]) {
if (obj2 instanceof Object[]) {
// Compare array and array
if (!Arrays.equals((Object[]) obj1, (Object[]) obj2)) {
return false;
}
} else if (obj2 instanceof List) {
// compare array and list
@SuppressWarnings("unchecked")
List<Object> obj2List = (List<Object>) obj2;
if (!Arrays.equals((Object[]) obj1, obj2List.toArray())) {
return false;
}
} else {
// compare array and something that isn't an array will always fail
return false;
}
} else if (obj1 instanceof List) {
if (obj2 instanceof Object[]) {
// Compare list and array
@SuppressWarnings("unchecked")
List<Object> obj1List = (List<Object>) obj1;
if (!Arrays.equals(obj1List.toArray(), (Object[]) obj2)) {
return false;
}
} else if (!obj1.equals(obj2)) {
// compare list and something else, let it fall to equals()
return false;
}
} else if (!obj1.equals(obj2)) {
// Not an array, leave it to equals()
return false;
}
}
// More elements in one of the iterables
if (iter1.hasNext() || iter2.hasNext()) {
return false;
}
}
return true;
}