Skip to content

Commit

Permalink
API: Add API changes for table statistics tracking (apache#5021)
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi authored Aug 30, 2022
1 parent 97c85aa commit cc7e6d9
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .palantir/revapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ acceptedBreaks:
- code: "java.method.addedToInterface"
new: "method org.apache.iceberg.ReplacePartitions org.apache.iceberg.ReplacePartitions::validateNoConflictingDeletes()"
justification: "Accept all changes prior to introducing API compatibility checks"
- code: "java.method.addedToInterface"
new: "method org.apache.iceberg.UpdateStatistics org.apache.iceberg.Table::updateStatistics()"
justification: "new API method"
- code: "java.method.addedToInterface"
new: "method org.apache.iceberg.UpdateStatistics org.apache.iceberg.Transaction::updateStatistics()"
justification: "new API method"
- code: "java.method.addedToInterface"
new: "method org.apache.iceberg.expressions.Expression org.apache.iceberg.Scan<ThisT,\
\ T extends org.apache.iceberg.ScanTask, G extends org.apache.iceberg.ScanTaskGroup<T\
Expand Down
11 changes: 11 additions & 0 deletions api/src/main/java/org/apache/iceberg/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,17 @@ default AppendFiles newFastAppend() {
*/
DeleteFiles newDelete();

/**
* Create a new {@link UpdateStatistics update table statistics API} to add or remove statistics
* files in this table.
*
* @return a new {@link UpdateStatistics}
*/
default UpdateStatistics updateStatistics() {
throw new UnsupportedOperationException(
"Updating statistics is not supported by " + getClass().getName());
}

/**
* Create a new {@link ExpireSnapshots expire API} to manage snapshots in this table and commit.
*
Expand Down
11 changes: 11 additions & 0 deletions api/src/main/java/org/apache/iceberg/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ default AppendFiles newFastAppend() {
*/
DeleteFiles newDelete();

/**
* Create a new {@link UpdateStatistics update table statistics API} to add or remove statistics
* files in this table.
*
* @return a new {@link UpdateStatistics}
*/
default UpdateStatistics updateStatistics() {
throw new UnsupportedOperationException(
"Updating statistics is not supported by " + getClass().getName());
}

/**
* Create a new {@link ExpireSnapshots expire API} to manage snapshots in this table.
*
Expand Down
37 changes: 37 additions & 0 deletions api/src/main/java/org/apache/iceberg/UpdateStatistics.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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;

/** API for updating statistics files in a table. */
public interface UpdateStatistics extends PendingUpdate<Snapshot> {
/**
* Set the table's statistics file for given snapshot, replacing the previous statistics file for
* the snapshot if any exists.
*
* @return this for method chaining
*/
UpdateStatistics setStatistics(long snapshotId, StatisticsFile statisticsFile);

/**
* Remove the table's statistics file for given snapshot.
*
* @return this for method chaining
*/
UpdateStatistics removeStatistics(long snapshotId);
}
5 changes: 5 additions & 0 deletions core/src/main/java/org/apache/iceberg/BaseMetadataTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ public DeleteFiles newDelete() {
throw new UnsupportedOperationException("Cannot delete from a metadata table");
}

@Override
public UpdateStatistics updateStatistics() {
throw new UnsupportedOperationException("Cannot update statistics of a metadata table");
}

@Override
public ExpireSnapshots expireSnapshots() {
throw new UnsupportedOperationException("Cannot expire snapshots from a metadata table");
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/org/apache/iceberg/BaseTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,11 @@ public DeleteFiles newDelete() {
return BaseTransaction.this.newDelete();
}

@Override
public UpdateStatistics updateStatistics() {
return BaseTransaction.this.updateStatistics();
}

@Override
public ExpireSnapshots expireSnapshots() {
return BaseTransaction.this.expireSnapshots();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ public DeleteFiles newDelete() {
return wrapped.newDelete();
}

@Override
public UpdateStatistics updateStatistics() {
return wrapped.updateStatistics();
}

@Override
public ExpireSnapshots expireSnapshots() {
return wrapped.expireSnapshots();
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/org/apache/iceberg/SerializableTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ public DeleteFiles newDelete() {
throw new UnsupportedOperationException(errorMsg("newDelete"));
}

@Override
public UpdateStatistics updateStatistics() {
throw new UnsupportedOperationException(errorMsg("updateStatistics"));
}

@Override
public ExpireSnapshots expireSnapshots() {
throw new UnsupportedOperationException(errorMsg("expireSnapshots"));
Expand Down

0 comments on commit cc7e6d9

Please sign in to comment.