From 11fab99a9f17460dcd046c6781458bc64e66d70d Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Mon, 19 Sep 2022 14:02:23 +0200 Subject: [PATCH] Expose table statistics in Table API This adds support in `Table` for the table statistics. --- .palantir/revapi.yml | 3 +++ api/src/main/java/org/apache/iceberg/Table.java | 7 +++++++ .../main/java/org/apache/iceberg/BaseMetadataTable.java | 6 ++++++ core/src/main/java/org/apache/iceberg/BaseTable.java | 5 +++++ core/src/main/java/org/apache/iceberg/BaseTransaction.java | 5 +++++ .../main/java/org/apache/iceberg/SerializableTable.java | 5 +++++ 6 files changed, 31 insertions(+) diff --git a/.palantir/revapi.yml b/.palantir/revapi.yml index 9d8b5c5077c3..426f7d2ab582 100644 --- a/.palantir/revapi.yml +++ b/.palantir/revapi.yml @@ -9,6 +9,9 @@ acceptedBreaks: - code: "java.method.addedToInterface" new: "method java.lang.String org.apache.iceberg.expressions.Reference::name()" justification: "All subclasses implement name" + - code: "java.method.addedToInterface" + new: "method java.util.List org.apache.iceberg.Table::statisticsFiles()" + justification: "new API method" - code: "java.method.removed" old: "method org.apache.iceberg.OverwriteFiles org.apache.iceberg.OverwriteFiles::validateNoConflictingAppends(org.apache.iceberg.expressions.Expression)" justification: "Deprecations for 1.0 release" diff --git a/api/src/main/java/org/apache/iceberg/Table.java b/api/src/main/java/org/apache/iceberg/Table.java index 3f753a3bd208..e17702f36665 100644 --- a/api/src/main/java/org/apache/iceberg/Table.java +++ b/api/src/main/java/org/apache/iceberg/Table.java @@ -308,6 +308,13 @@ default UpdateStatistics updateStatistics() { /** Returns a {@link LocationProvider} to provide locations for new data files. */ LocationProvider locationProvider(); + /** + * Returns the current statistics files for the table + * + * @return the current statistics files for the table + */ + List statisticsFiles(); + /** * Returns the current refs for the table * diff --git a/core/src/main/java/org/apache/iceberg/BaseMetadataTable.java b/core/src/main/java/org/apache/iceberg/BaseMetadataTable.java index 31890843f238..d14878d5bb20 100644 --- a/core/src/main/java/org/apache/iceberg/BaseMetadataTable.java +++ b/core/src/main/java/org/apache/iceberg/BaseMetadataTable.java @@ -24,6 +24,7 @@ import org.apache.iceberg.encryption.EncryptionManager; import org.apache.iceberg.io.FileIO; import org.apache.iceberg.io.LocationProvider; +import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList; import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; import org.apache.iceberg.transforms.Transforms; @@ -161,6 +162,11 @@ public List history() { return table().history(); } + @Override + public List statisticsFiles() { + return ImmutableList.of(); + } + @Override public Map refs() { return table().refs(); diff --git a/core/src/main/java/org/apache/iceberg/BaseTable.java b/core/src/main/java/org/apache/iceberg/BaseTable.java index 550dc39a18b7..b812522d7857 100644 --- a/core/src/main/java/org/apache/iceberg/BaseTable.java +++ b/core/src/main/java/org/apache/iceberg/BaseTable.java @@ -239,6 +239,11 @@ public LocationProvider locationProvider() { return operations().locationProvider(); } + @Override + public List statisticsFiles() { + return ops.current().statisticsFiles(); + } + @Override public Map refs() { return ops.current().refs(); diff --git a/core/src/main/java/org/apache/iceberg/BaseTransaction.java b/core/src/main/java/org/apache/iceberg/BaseTransaction.java index d5e82cff73cd..c647b3e331ca 100644 --- a/core/src/main/java/org/apache/iceberg/BaseTransaction.java +++ b/core/src/main/java/org/apache/iceberg/BaseTransaction.java @@ -747,6 +747,11 @@ public LocationProvider locationProvider() { return transactionOps.locationProvider(); } + @Override + public List statisticsFiles() { + return current.statisticsFiles(); + } + @Override public Map refs() { return current.refs(); diff --git a/core/src/main/java/org/apache/iceberg/SerializableTable.java b/core/src/main/java/org/apache/iceberg/SerializableTable.java index 8f8f27a76165..9b441113e7ab 100644 --- a/core/src/main/java/org/apache/iceberg/SerializableTable.java +++ b/core/src/main/java/org/apache/iceberg/SerializableTable.java @@ -237,6 +237,11 @@ public LocationProvider locationProvider() { return locationProvider; } + @Override + public List statisticsFiles() { + return lazyTable().statisticsFiles(); + } + @Override public Map refs() { return refs;