-
Notifications
You must be signed in to change notification settings - Fork 2.9k
REST: Implement register view for REST catalog #14870
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
Open
ajantha-bhat
wants to merge
4
commits into
apache:main
Choose a base branch
from
ajantha-bhat:view-rest
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+591
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
core/src/main/java/org/apache/iceberg/rest/requests/RegisterViewRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.iceberg.rest.requests; | ||
|
|
||
| import org.apache.iceberg.rest.RESTRequest; | ||
| import org.immutables.value.Value; | ||
|
|
||
| @Value.Immutable | ||
| public interface RegisterViewRequest extends RESTRequest { | ||
|
|
||
| String name(); | ||
|
|
||
| String metadataLocation(); | ||
|
|
||
| @Override | ||
| default void validate() { | ||
| // nothing to validate as it's not possible to create an invalid instance | ||
| } | ||
| } |
69 changes: 69 additions & 0 deletions
69
core/src/main/java/org/apache/iceberg/rest/requests/RegisterViewRequestParser.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.iceberg.rest.requests; | ||
|
|
||
| import com.fasterxml.jackson.core.JsonGenerator; | ||
| import com.fasterxml.jackson.databind.JsonNode; | ||
| import java.io.IOException; | ||
| import org.apache.iceberg.relocated.com.google.common.base.Preconditions; | ||
| import org.apache.iceberg.util.JsonUtil; | ||
|
|
||
| public class RegisterViewRequestParser { | ||
|
|
||
| private static final String NAME = "name"; | ||
| private static final String METADATA_LOCATION = "metadata-location"; | ||
|
|
||
| private RegisterViewRequestParser() {} | ||
|
|
||
| public static String toJson(RegisterViewRequest request) { | ||
| return toJson(request, false); | ||
| } | ||
|
|
||
| public static String toJson(RegisterViewRequest request, boolean pretty) { | ||
| return JsonUtil.generate(gen -> toJson(request, gen), pretty); | ||
| } | ||
|
|
||
| public static void toJson(RegisterViewRequest request, JsonGenerator gen) throws IOException { | ||
| Preconditions.checkArgument(null != request, "Invalid register view request: null"); | ||
|
|
||
| gen.writeStartObject(); | ||
|
|
||
| gen.writeStringField(NAME, request.name()); | ||
| gen.writeStringField(METADATA_LOCATION, request.metadataLocation()); | ||
|
|
||
| gen.writeEndObject(); | ||
| } | ||
|
|
||
| public static RegisterViewRequest fromJson(String json) { | ||
| return JsonUtil.parse(json, RegisterViewRequestParser::fromJson); | ||
| } | ||
|
|
||
| public static RegisterViewRequest fromJson(JsonNode json) { | ||
| Preconditions.checkArgument( | ||
| null != json, "Cannot parse register view request from null object"); | ||
|
|
||
| String name = JsonUtil.getString(NAME, json); | ||
| String metadataLocation = JsonUtil.getString(METADATA_LOCATION, json); | ||
|
|
||
| return ImmutableRegisterViewRequest.builder() | ||
| .name(name) | ||
| .metadataLocation(metadataLocation) | ||
| .build(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 have the same comment/question here as on the PR for other catalog types: if the default Catalog name is persisted in the view metadata than in case we register this view into another catalog, the default catalog won't change. Would this mean that it's a requirement for the engines to refer to the new catalog with the same name as the source catalog?
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 did ask about this optional defaultCatalog field long ago and got an #10410 (comment) that it was for Spark.
Updating the metadata (with new catalog name) will leads to new metadata file which is not exactly a register case. So, If the engines requires it they can update the view with the new catalog name (only for Spark I guess) by adding the new version.
@nastra can add more on this as he was handling this during view spec design.