-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Rest Catalog: Add RESTful AppendFiles data operation #9292
Draft
geruh
wants to merge
2
commits into
apache:main
Choose a base branch
from
geruh:rest-append-files
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.
Draft
Changes from all commits
Commits
Show all changes
2 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 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 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 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 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 |
---|---|---|
|
@@ -35,7 +35,6 @@ | |
import java.util.function.BiFunction; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
import org.apache.iceberg.BaseTable; | ||
import org.apache.iceberg.CatalogProperties; | ||
import org.apache.iceberg.CatalogUtil; | ||
import org.apache.iceberg.EnvironmentContext; | ||
|
@@ -112,6 +111,7 @@ public class RESTSessionCatalog extends BaseViewSessionCatalog | |
private static final Logger LOG = LoggerFactory.getLogger(RESTSessionCatalog.class); | ||
private static final String DEFAULT_FILE_IO_IMPL = "org.apache.iceberg.io.ResolvingFileIO"; | ||
private static final String REST_METRICS_REPORTING_ENABLED = "rest-metrics-reporting-enabled"; | ||
private static final String REST_DATA_COMMIT_ENABLED = "rest-data-commit-enabled"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A few places we probably need to update the naming. |
||
private static final String REST_SNAPSHOT_LOADING_MODE = "snapshot-loading-mode"; | ||
private static final List<String> TOKEN_PREFERENCE_ORDER = | ||
ImmutableList.of( | ||
|
@@ -135,6 +135,7 @@ public class RESTSessionCatalog extends BaseViewSessionCatalog | |
private FileIO io = null; | ||
private MetricsReporter reporter = null; | ||
private boolean reportingViaRestEnabled; | ||
private boolean dataCommitViaRestEnabled; | ||
private CloseableGroup closeables = null; | ||
|
||
// a lazy thread pool for token refresh | ||
|
@@ -219,7 +220,8 @@ public void initialize(String name, Map<String, String> unresolved) { | |
AuthSession.fromAccessToken( | ||
client, tokenRefreshExecutor(), token, expiresAtMillis(mergedProps), catalogAuth); | ||
} | ||
|
||
this.dataCommitViaRestEnabled = | ||
PropertyUtil.propertyAsBoolean(mergedProps, REST_DATA_COMMIT_ENABLED, false); | ||
this.io = newFileIO(SessionContext.createEmpty(), mergedProps); | ||
|
||
this.fileIOCloser = newFileIOCloser(); | ||
|
@@ -391,12 +393,15 @@ public Table loadTable(SessionContext context, TableIdentifier identifier) { | |
tableMetadata); | ||
|
||
trackFileIO(ops); | ||
|
||
BaseTable table = | ||
new BaseTable( | ||
Table table = | ||
new RESTTable( | ||
ops, | ||
fullTableName(finalIdentifier), | ||
metricsReporter(paths.metrics(finalIdentifier), session::headers)); | ||
metricsReporter(paths.metrics(finalIdentifier), session::headers), | ||
this.client, | ||
paths.table(finalIdentifier), | ||
session::headers, | ||
dataCommitViaRestEnabled); | ||
if (metadataType != null) { | ||
return MetadataTableUtils.createMetadataTableInstance(table, metadataType); | ||
} | ||
|
@@ -464,9 +469,14 @@ public Table registerTable( | |
response.tableMetadata()); | ||
|
||
trackFileIO(ops); | ||
|
||
return new BaseTable( | ||
ops, fullTableName(ident), metricsReporter(paths.metrics(ident), session::headers)); | ||
return new RESTTable( | ||
ops, | ||
fullTableName(ident), | ||
metricsReporter(paths.metrics(ident), session::headers), | ||
client, | ||
paths.table(ident), | ||
session::headers, | ||
dataCommitViaRestEnabled); | ||
} | ||
|
||
@Override | ||
|
@@ -683,9 +693,14 @@ public Table create() { | |
response.tableMetadata()); | ||
|
||
trackFileIO(ops); | ||
|
||
return new BaseTable( | ||
ops, fullTableName(ident), metricsReporter(paths.metrics(ident), session::headers)); | ||
return new RESTTable( | ||
ops, | ||
fullTableName(ident), | ||
metricsReporter(paths.metrics(ident), session::headers), | ||
client, | ||
paths.table(ident), | ||
session::headers, | ||
dataCommitViaRestEnabled); | ||
} | ||
|
||
@Override | ||
|
This file contains 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,59 @@ | ||
/* | ||
* | ||
* * 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; | ||
|
||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
import org.apache.iceberg.AppendFiles; | ||
import org.apache.iceberg.BaseTable; | ||
import org.apache.iceberg.TableOperations; | ||
import org.apache.iceberg.metrics.MetricsReporter; | ||
import org.apache.iceberg.rest.operations.RestAppendFiles; | ||
|
||
public class RESTTable extends BaseTable { | ||
private final RESTClient client; | ||
private final String path; | ||
private final Supplier<Map<String, String>> headers; | ||
private final boolean dataCommitViaRestEnabled; | ||
|
||
public RESTTable( | ||
TableOperations ops, | ||
String name, | ||
MetricsReporter reporter, | ||
RESTClient client, | ||
String path, | ||
Supplier<Map<String, String>> headers, | ||
boolean dataCommitViaRestEnabled) { | ||
super(ops, name, reporter); | ||
this.client = client; | ||
this.headers = headers; | ||
this.path = path; | ||
this.dataCommitViaRestEnabled = dataCommitViaRestEnabled; | ||
} | ||
|
||
@Override | ||
public AppendFiles newAppend() { | ||
if (dataCommitViaRestEnabled) { | ||
return new RestAppendFiles(client, path, headers, operations()); | ||
} | ||
return super.newAppend(); | ||
} | ||
} |
Oops, something went wrong.
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.
We might want to rename this to
AppendManifestsUpdate
AppendContentFileUpdate
as appending files would be more of aDataFile
type object.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.
Actually, I think it makes more sense to pass DataFile entries through this interface since that will actually handle both cases. There are issues with passing manifests because they will need to be rewritten in certain cases. ContentFileParser already supports a json representation, so I think we should pass the data file records through this interface directly (as opposed to just pointing to files).
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.
+1. I think using manifest was more for scalability considerations because there might be many data files. But that might be an over-optimization, and start with passing data file entries is a better starting point.
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.
For the naming, should this be more like
AddContentFileUpdate
instead ofAppendContentFileUpdate
in this case? @danielcweeks given this can be used to add both data and delete files which are both content files, and "append delete files" does not sound like the right terminology.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 think we need to initially disallow delete files from being added because there are more concerns around achieving correct semantics. We could split this into
AppendDataFileUpdate
and if we later decide to support deletes, addAppendDeleteFileUpdate
.