Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.avro.specific.SpecificData;
import org.apache.iceberg.avro.AvroSchemaVisitor;
import org.apache.iceberg.avro.UUIDConversion;
import org.apache.iceberg.relocated.com.google.common.base.Objects;
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.types.TypeUtil;
Expand Down Expand Up @@ -252,7 +253,7 @@ public Schema record(Schema record, List<String> names, List<Schema> types) {

newFields.add(copyField(field, type));

if (field.schema() != type) {
if (!Objects.equal(field.schema(), type)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was intentionally checking object identity because we want to rebuild if anything about the object changed, not just the fields that are used for equality. Part of the rationale is that we don't necessarily want to assume that equals is strict for types. But since we do have strict equality that checks all fields (including doc) I think this is fine.

hasChange = true;
}
}
Expand All @@ -274,15 +275,15 @@ public Schema union(Schema union, List<Schema> options) {

@Override
public Schema array(Schema array, Schema element) {
if (array.getElementType() != element) {
if (!Objects.equal(array.getElementType(), element)) {
return Schema.createArray(element);
}
return array;
}

@Override
public Schema map(Schema map, Schema value) {
if (map.getValueType() != value) {
if (!Objects.equal(map.getValueType(), value)) {
return Schema.createMap(value);
}
return map;
Expand Down Expand Up @@ -318,7 +319,7 @@ private boolean isIdentical(List<Schema> types, List<Schema> replacements) {

int length = types.size();
for (int i = 0; i < length; i += 1) {
if (types.get(i) != replacements.get(i)) {
if (!Objects.equal(types.get(i), replacements.get(i))) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.util.List;
import java.util.Set;
import org.apache.iceberg.relocated.com.google.common.base.Objects;
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.parquet.schema.GroupType;
Expand Down Expand Up @@ -102,7 +103,7 @@ public Type list(GroupType list, Type element) {
if (elementId != null && selectedIds.contains(elementId)) {
return list;
} else if (element != null) {
if (element != originalElement) {
if (!Objects.equal(element, originalElement)) {
Integer listId = getId(list);
// the element type was projected
Type listType = Types.list(list.getRepetition())
Expand All @@ -129,7 +130,7 @@ public Type map(GroupType map, Type key, Type value) {
return map;
} else if (value != null) {
Integer mapId = getId(map);
if (value != originalValue) {
if (!Objects.equal(value, originalValue)) {
Type mapType = Types.map(map.getRepetition())
.key(originalKey)
.value(value)
Expand Down