Skip to content

Conversation

@nastra
Copy link
Contributor

@nastra nastra commented Jul 25, 2023

This PR extracts the MetadataUpdate / UpdateRequirement changes from #7913

@github-actions github-actions bot added the core label Jul 25, 2023
@nastra nastra force-pushed the view-requirements-and-updates branch from b53ed12 to f088e47 Compare July 26, 2023 07:21
@nastra nastra changed the title Core: Add Updates / Requirements for Views Core: Add metadata updates for Views Jul 26, 2023
@nastra nastra force-pushed the view-requirements-and-updates branch from f088e47 to b57c827 Compare July 27, 2023 11:44
private static final String LOCATION = "location";

// AddViewVersion
private static final String VIEW_VERSION = "view-version";
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you update the REST spec as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was planning on updating the REST spec as part of #7913 because it requires a bunch of other View-specific stuff and it seems easier to update everything in one go

return this;
}

public Builder schemas(Iterable<Schema> newSchemas) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this do differently than addAllSchemas? Do we need a method that adds multiple schemas?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the difference between setSchemas() and addAllSchemas() is that setSchemas() will replace whatever this.schemas was set to with newSchemas, whereas addAllSchemas() will just add items to this.schemas.

I think we're ok for now to only keep setXyz() and addXyz() without addAllXyz

@nastra nastra force-pushed the view-requirements-and-updates branch 2 times, most recently from 8490c02 to b7dc238 Compare August 18, 2023 10:11
@nastra nastra force-pushed the view-requirements-and-updates branch from b7dc238 to fb378f5 Compare August 18, 2023 10:40
@nastra nastra requested a review from rdblue September 3, 2023 12:39

public Builder setCurrentVersion(ViewVersion version) {
Schema schema = indexSchemas(schemas).get(version.schemaId());
int newSchemaId = addSchemaInternal(schema);
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem correct to me.

The ViewVersion references a schema by ID. This method assumes that schema has been added to the builder already (or was already added to the view in a previous commit) because it expects the schema to be present in the ID to schema map produced by indexSchemas. But this then adds the schema and possibly reassigns the schema ID, which will be a noop because the schema is already known.

I think the solution is to pass the schema into this method. Then this would add the schema via addSchemaInternal (possibly reassigning its ID), add the view version that references the schema ID returned by addSchemaInternal, and then call setCurrentVersionId with the view version ID returned by addVersionInternal.

@rdblue
Copy link
Contributor

rdblue commented Sep 3, 2023

@nastra, to avoid more review rounds, I went ahead and fixed the remaining issues in this PR as I was doing a deep dive. See nastra#135 with the changes. You may need to fix a test or two, but I got the ViewMetadata tests passing.

@nastra nastra force-pushed the view-requirements-and-updates branch from 9018318 to a5a8ad0 Compare September 4, 2023 05:29
@nastra
Copy link
Contributor Author

nastra commented Sep 4, 2023

@nastra, to avoid more review rounds, I went ahead and fixed the remaining issues in this PR as I was doing a deep dive. See nastra#135 with the changes. You may need to fix a test or two, but I got the ViewMetadata tests passing.

Thanks @rdblue, I've updated a few small things as well and pushed them.

@nastra nastra requested a review from rdblue September 4, 2023 05:30
@rdblue rdblue merged commit 6bb5a1a into apache:master Sep 4, 2023
@rdblue
Copy link
Contributor

rdblue commented Sep 4, 2023

Merged. Thanks, @nastra!

@nastra nastra deleted the view-requirements-and-updates branch September 4, 2023 16:11
@nastra nastra self-assigned this Nov 25, 2024
zhongyujiang pushed a commit to zhongyujiang/iceberg that referenced this pull request Apr 16, 2025
…ta (apache#8147)

* Core: Add metadata updates for Views / use own Builder for ViewMetadata
* Move validations into Builder to be more lenient when ViewMetadata is read through Parser

There are currently only two ways to create an instance of
`ViewMetadata`:
* through the Builder
* through the Parser

Almost all validations should be happening in the Builder, while we
would like to be more lenient when view metadata is being read (e.g.
from disk) via the parser.

Reading view metadata through the parser, it is acceptable that things
like schemas/versions/history might be empty or that the current version
id points to a version that doesn't exist. In such a case we'd rather
want to lazily fail when accessing the view's current version rather
than when the view metadata is being read by the parser.

Co-authored-by: Ryan Blue <blue@apache.org>

(cherry picked from commit 6bb5a1a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants