-
Notifications
You must be signed in to change notification settings - Fork 3k
Core: add a unit test for view version to schema consistency #14334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
5b65b0b to
597f159
Compare
core/src/main/java/org/apache/iceberg/view/BaseViewOperations.java
Outdated
Show resolved
Hide resolved
| * 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 { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
32c9297 to
a43c277
Compare
a43c277 to
56cc926
Compare
|
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. |
| .dialect("trino") | ||
| .build()) | ||
| .build()); | ||
| assertThat(updatedView.schemas().get(updatedView.version(1).schemaId()).sameSchema(SCHEMA)); |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assertThat(updatedView.schema().sameSchema(SCHEMA_WITH_EXTRA_COL)); | |
| assertThat(updatedView.schema().asStruct()).isEqualTo(SCHEMA_WITH_EXTRA_COL.asStruct()); |
| } | ||
|
|
||
| @Test | ||
| public void concurrentUpdateViewSchema() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assertThat( | ||
| ((SQLViewRepresentation) updatedView.currentVersion().representations().get(0)).sql()) | ||
| .isEqualTo("select id, data, extra from ns.tbl"); | ||
| } |
There was a problem hiding this comment.
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
Purpose of the change:
Added 2 new unit test: