-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
add the process of snapshots queryParam for RESTCatalogAdapter #8519
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
import org.apache.iceberg.BaseTransaction; | ||
import org.apache.iceberg.PartitionSpec; | ||
import org.apache.iceberg.Schema; | ||
import org.apache.iceberg.SnapshotRef; | ||
import org.apache.iceberg.SortOrder; | ||
import org.apache.iceberg.Table; | ||
import org.apache.iceberg.TableMetadata; | ||
|
@@ -253,12 +254,34 @@ public static void purgeTable(Catalog catalog, TableIdentifier ident) { | |
} | ||
} | ||
|
||
public static LoadTableResponse loadTable(Catalog catalog, TableIdentifier ident) { | ||
private static TableMetadata getTableMetaData( | ||
BaseTable baseTable, RESTSessionCatalog.SnapshotMode snapshotMode) { | ||
TableMetadata tableMetadata = baseTable.operations().current(); | ||
|
||
switch (snapshotMode) { | ||
case ALL: | ||
return tableMetadata; | ||
case REFS: | ||
{ | ||
TableMetadata refsMetaData = TableMetadata.buildFrom(tableMetadata).build(); | ||
Set<Long> referencedSnapshotIds = | ||
refsMetaData.refs().values().stream() | ||
.map(SnapshotRef::snapshotId) | ||
.collect(Collectors.toSet()); | ||
refsMetaData.removeSnapshotsIf(s -> !referencedSnapshotIds.contains(s.snapshotId())); | ||
return refsMetaData; | ||
} | ||
} | ||
return tableMetadata; | ||
} | ||
|
||
public static LoadTableResponse loadTable( | ||
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. I don't think we can just change a public method as that will break API compatibility: https://github.com/apache/iceberg/blob/master/CONTRIBUTING.md#semantic-versioning @sandflee what's the expectation on your end for this PR? Are you expecting a backing catalog (such as JDBC) to also return either a single snapshot vs all snapshots when the 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. I'm building a Iceberg RESTCatalog server with the ability of CatalogHandlers, and found CatalogHandlers#loadTable doesn't support snapshot queryParams, so I post this PR. 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. @nastra , is it necessary to process 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.
In that case wouldn't it be better to implement this functionality on the server rather than in 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. ok, I'll implement it on the server, thanks for your review @nastra |
||
Catalog catalog, TableIdentifier ident, RESTSessionCatalog.SnapshotMode snapshotMode) { | ||
Table table = catalog.loadTable(ident); | ||
|
||
if (table instanceof BaseTable) { | ||
return LoadTableResponse.builder() | ||
.withTableMetadata(((BaseTable) table).operations().current()) | ||
.withTableMetadata(getTableMetaData((BaseTable) table, snapshotMode)) | ||
.build(); | ||
} else if (table instanceof BaseMetadataTable) { | ||
// metadata tables are loaded on the client side, return NoSuchTableException for now | ||
|
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 don't want to break any existing APIs. See also https://github.com/apache/iceberg/blob/master/CONTRIBUTING.md#semantic-versioning