Skip to content

Conversation

@haizhou-zhao
Copy link
Contributor

@haizhou-zhao haizhou-zhao commented Oct 15, 2025

Purpose of the change:
Added 2 new unit test:

  1. verifying that schemaID is consistent in the newly added view version, even when the added view versions are added concurrently.
  2. verify idempotency for 2 concurrent identical update view

* Assuming that view ID is incrementing integers, so the last assigned view version ID is always
* the max ID that has been assigned.
*/
class AssertLastAssignedViewVersionID implements UpdateRequirement {
Copy link
Contributor

Choose a reason for hiding this comment

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

here's some historical context on why I didn't add it back then when introducing views: #8147 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack. Discussed offline

}
}

class AssertCurrentViewVersionID implements UpdateRequirement {
Copy link
Contributor

Choose a reason for hiding this comment

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

here's some historical context on why I didn't add it back then when views were introduced: #8147 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this comes down to whether we have a good enough argument for making a "replace view" fail

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, as mentioned offline, we don't want to fail replace view in these cases

@haizhou-zhao haizhou-zhao force-pushed the view_conflict branch 2 times, most recently from 32c9297 to a43c277 Compare November 11, 2025 05:36
@haizhou-zhao haizhou-zhao changed the title Core: view version update requirements Core: add a unit test for view version to schema consistency Nov 11, 2025
@github-actions
Copy link

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Dec 12, 2025
@nastra nastra added not-stale and removed stale labels Dec 12, 2025
.dialect("trino")
.build())
.build());
assertThat(updatedView.schemas().get(updatedView.version(1).schemaId()).sameSchema(SCHEMA));
Copy link
Contributor

Choose a reason for hiding this comment

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

the assertion isn't doing anything. Also to be consistent with other checks in this class, can you please update it to assertThat(updatedView.schemas().get(updatedView.version(1).schemaId()).asStruct()) .isEqualTo(SCHEMA.asStruct());

updatedView
.schemas()
.get(updatedView.version(2).schemaId())
.sameSchema(SCHEMA_WITH_EXTRA_COL));
Copy link
Contributor

Choose a reason for hiding this comment

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

please update this check and other checks as well


// idempotency: verify the latest version matches either of the
// desired schema and sql string, no matter the type of catalog
assertThat(updatedView.schema().sameSchema(SCHEMA_WITH_EXTRA_COL));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assertThat(updatedView.schema().sameSchema(SCHEMA_WITH_EXTRA_COL));
assertThat(updatedView.schema().asStruct()).isEqualTo(SCHEMA_WITH_EXTRA_COL.asStruct());

}

@Test
public void concurrentUpdateViewSchema() {
Copy link
Contributor

Choose a reason for hiding this comment

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

for other reviewers: this test makes sense to me and also verifies what was fixed by #14434. Removing the fix from #14434 makes this test fail, so it's good to have this test here

assertThat(
((SQLViewRepresentation) updatedView.currentVersion().representations().get(0)).sql())
.isEqualTo("select id, data, extra from ns.tbl");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

we might also want to check the history() and the versions() here

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants