Skip to content

Commit

Permalink
[#436] fix(catalog-lakehouse): create dummy reportMetrics interface t…
Browse files Browse the repository at this point in the history
…o remove warning message when spark writing data using IcebergRestCatalog (#449)

### What changes were proposed in this pull request?
add `reportMetrics` interfaces

### Why are the changes needed?
remove warning message when spark writing&reading data using
IcebergRestCatalog

Fix: #436 

### Does this PR introduce _any_ user-facing change?
add new Iceberg REST interface

### How was this patch tested?
1. UT
2. real env
  • Loading branch information
FANNG1 authored Sep 26, 2023
1 parent d739155 commit df3261a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.rest.RESTUtil;
import org.apache.iceberg.rest.requests.CreateTableRequest;
import org.apache.iceberg.rest.requests.ReportMetricsRequest;
import org.apache.iceberg.rest.requests.UpdateTableRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -127,4 +128,14 @@ public Response tableExists(
return IcebergRestUtils.notExists();
}
}

@POST
@Path("{table}/metrics")
@Produces(MediaType.APPLICATION_JSON)
public Response reportTableMetrics(
@PathParam("namespace") String namespace,
@PathParam("table") String table,
ReportMetricsRequest request) {
return IcebergRestUtils.noContent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class IcebergRestTestUtil {
public static final String TEST_NAMESPACE_NAME = "graviton-test";
public static final String TABLE_PATH = NAMESPACE_PATH + "/" + TEST_NAMESPACE_NAME + "/tables";
public static final String RENAME_TABLE_PATH = V_1 + "/tables/rename";
public static final String REPORT_METRICS_POSTFIX = "metrics";

public static final boolean DEBUG_SERVER_LOG_ENABLED = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public Builder getTableClientBuilder(Optional<String> name) {
return getIcebergClientBuilder(path, Optional.empty());
}

public Builder getReportMetricsClientBuilder(String name) {
String path =
Joiner.on("/")
.skipNulls()
.join(IcebergRestTestUtil.TABLE_PATH, name, IcebergRestTestUtil.REPORT_METRICS_POSTFIX);
return getIcebergClientBuilder(path, Optional.empty());
}

public Builder getNamespaceClientBuilder() {
return getNamespaceClientBuilder(Optional.empty(), Optional.empty());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@
import org.apache.iceberg.TableMetadata;
import org.apache.iceberg.catalog.Namespace;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.metrics.CommitReport;
import org.apache.iceberg.metrics.ImmutableCommitMetricsResult;
import org.apache.iceberg.metrics.ImmutableCommitReport;
import org.apache.iceberg.rest.requests.CreateTableRequest;
import org.apache.iceberg.rest.requests.RenameTableRequest;
import org.apache.iceberg.rest.requests.ReportMetricsRequest;
import org.apache.iceberg.rest.requests.UpdateTableRequest;
import org.apache.iceberg.rest.responses.ListTablesResponse;
import org.apache.iceberg.rest.responses.LoadTableResponse;
Expand Down Expand Up @@ -284,4 +288,27 @@ void testRenameTable(boolean withPrefix) {
verifyCreateTableSucc("rename_foo3");
verifyRenameTableFail("rename_foo2", "rename_foo3", 409);
}

@Test
void testReportTableMetrics() {

verifyCreateNamespaceSucc(IcebergRestTestUtil.TEST_NAMESPACE_NAME);
verifyCreateTableSucc("metrics_foo1");

ImmutableCommitMetricsResult commitMetrics = ImmutableCommitMetricsResult.builder().build();
CommitReport commitReport =
ImmutableCommitReport.builder()
.tableName("metrics_foo1")
.snapshotId(-1)
.sequenceNumber(-1)
.operation("append")
.commitMetrics(commitMetrics)
.build();
ReportMetricsRequest request = ReportMetricsRequest.of(commitReport);
Response response =
getReportMetricsClientBuilder("metrics_foo1")
.post(Entity.entity(request, MediaType.APPLICATION_JSON_TYPE));

Assertions.assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
}

0 comments on commit df3261a

Please sign in to comment.