Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions ice/src/main/java/com/altinity/ice/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,10 @@ void describe(
@CommandLine.Option(
names = {"--json"},
description = "Output JSON instead of YAML")
boolean json,
@CommandLine.Option(
names = {"--include-metrics"},
description = "Include table metrics in the output")
boolean includeMetrics)
boolean json)
throws IOException {
try (RESTCatalog catalog = loadCatalog(this.configFile)) {
Describe.run(catalog, target, json, includeMetrics);
Describe.run(catalog, target, json);
}
}

Expand Down
7 changes: 2 additions & 5 deletions ice/src/main/java/com/altinity/ice/internal/cmd/Describe.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public final class Describe {
private Describe() {}

// TODO: refactor: the use of StringBuilder below is absolutely criminal
public static void run(RESTCatalog catalog, String target, boolean json, boolean includeMetrics)
throws IOException {
public static void run(RESTCatalog catalog, String target, boolean json) throws IOException {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like TableMetadata, etc. records are defined but not actually used...

String targetNamespace = null;
String targetTable = null;
if (target != null && !target.isEmpty()) {
Expand Down Expand Up @@ -100,9 +99,7 @@ public static void run(RESTCatalog catalog, String target, boolean json, boolean
sb.append("\t\tlocation: " + snapshot.manifestListLocation() + "\n");
}

if (includeMetrics) {
printTableMetrics(table, sb);
}
printTableMetrics(table, sb);
}
}
String r = sb.toString().replace("\t", " ");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.altinity.ice.internal.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
import java.util.Map;

@JsonInclude(JsonInclude.Include.NON_NULL)
public record TableMetadata(String kind, Metadata metadata, TableData data) {
public TableMetadata {
if (kind == null) {
kind = "Table";
}
}

public record Metadata(String id) {}

public record TableData(
String schema_raw,
String partition_spec_raw,
String sort_order_raw,
Map<String, String> properties,
String location,
SnapshotInfo current_snapshot,
List<MetricsInfo> metrics) {}

public record SnapshotInfo(
long sequence_number,
long id,
Long parent_id,
long timestamp,
String timestamp_iso,
String timestamp_iso_local,
String operation,
Map<String, String> summary,
String location) {}

public record MetricsInfo(String file, long record_count, List<ColumnMetrics> columns) {}

public record ColumnMetrics(
String name, Long value_count, Long null_count, String lower_bound, String upper_bound) {}
}