Skip to content

Core: Use mocks in TrackedFile tests#17133

Open
rdblue wants to merge 2 commits into
apache:mainfrom
rdblue:update-tracked-file-tests
Open

Core: Use mocks in TrackedFile tests#17133
rdblue wants to merge 2 commits into
apache:mainfrom
rdblue:update-tracked-file-tests

Conversation

@rdblue

@rdblue rdblue commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This updates TestTrackedFileStruct to use mock objects for plumbing tests rather than creating instances of TrackingStruct and PartitionData.

@rdblue rdblue requested a review from amogh-jahagirdar July 7, 2026 20:19
@github-actions github-actions Bot added the core label Jul 7, 2026

/** Mutable {@link StructLike} implementation of {@link TrackedFile}. */
class TrackedFileStruct extends SupportsIndexProjection implements TrackedFile, Serializable {
private static final Types.StructType EMPTY_STRUCT_TYPE = Types.StructType.of();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This struct is still used in the BASE_TYPE just below.

Comment thread core/src/main/java/org/apache/iceberg/TrackedFileStruct.java
Comment thread core/src/main/java/org/apache/iceberg/TrackedFileStruct.java Outdated
Comment thread core/src/test/java/org/apache/iceberg/TestTrackedFileStruct.java
// mutable fields are deep-copied, not shared with the original
assertThat(copy.tracking()).isNotSameAs(file.tracking());
assertThat(copy.partition()).isNotSameAs(file.partition());
assertThat(copy.deletionVector()).isNotSameAs(file.deletionVector());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it make sense to introduce mocks for the below nested fields too? Tracking and partition doesn't seem any special from this aspect.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The issue with this is that we do not currently have copy methods for them. I think that we should follow up to do this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DeletionVector and ManifestInfo both have their copy() function. See here and here.

keyMetadata is a byte array not a class, we won't be able to do so for this, but for the other 2 members we could.

@rdblue rdblue force-pushed the update-tracked-file-tests branch from 0f2d8c1 to 83d6309 Compare July 8, 2026 18:41

@stevenzwu stevenzwu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just one nit comment

assertThat(copy.partition()).isSameAs(PARTITION_COPY);

// mutable fields are deep-copied, not shared with the original
assertThat(copy.tracking()).isNotSameAs(file.tracking());

@stevenzwu stevenzwu Jul 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: it might make more sense to keep the two isSameAs assertions here to check they are deep copied and not shared with the original object, as the comment above described.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants