From ed24d937d2fa2262307cca7a43f9b08e1ba76ab7 Mon Sep 17 00:00:00 2001 From: Kyle Bendickson Date: Thu, 26 May 2022 19:29:12 -0700 Subject: [PATCH] Core: Use UnboundSortOrder, UnboundPartitionSpec in CreateTableRequest (#4880) --- .../main/java/org/apache/iceberg/SortOrder.java | 2 +- .../iceberg/rest/requests/CreateTableRequest.java | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/org/apache/iceberg/SortOrder.java b/api/src/main/java/org/apache/iceberg/SortOrder.java index 09c45c65e337..91b6177ecec7 100644 --- a/api/src/main/java/org/apache/iceberg/SortOrder.java +++ b/api/src/main/java/org/apache/iceberg/SortOrder.java @@ -135,7 +135,7 @@ private List lazyFieldList() { return fieldList; } - UnboundSortOrder toUnbound() { + public UnboundSortOrder toUnbound() { UnboundSortOrder.Builder builder = UnboundSortOrder.builder().withOrderId(orderId); for (SortField field : fields) { diff --git a/core/src/main/java/org/apache/iceberg/rest/requests/CreateTableRequest.java b/core/src/main/java/org/apache/iceberg/rest/requests/CreateTableRequest.java index c9b13224d4e4..1b227b11c507 100644 --- a/core/src/main/java/org/apache/iceberg/rest/requests/CreateTableRequest.java +++ b/core/src/main/java/org/apache/iceberg/rest/requests/CreateTableRequest.java @@ -24,6 +24,8 @@ import org.apache.iceberg.PartitionSpec; import org.apache.iceberg.Schema; import org.apache.iceberg.SortOrder; +import org.apache.iceberg.UnboundPartitionSpec; +import org.apache.iceberg.UnboundSortOrder; import org.apache.iceberg.relocated.com.google.common.base.MoreObjects; import org.apache.iceberg.relocated.com.google.common.base.Preconditions; import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; @@ -38,8 +40,8 @@ public class CreateTableRequest implements RESTRequest { private String name; private String location; private Schema schema; - private PartitionSpec spec; - private SortOrder order; + private UnboundPartitionSpec spec; + private UnboundSortOrder order; private Map properties; private Boolean stageCreate; @@ -52,8 +54,8 @@ private CreateTableRequest(String name, String location, Schema schema, Partitio this.name = name; this.location = location; this.schema = schema; - this.spec = spec; - this.order = order; + this.spec = spec != null ? spec.toUnbound() : null; + this.order = order != null ? order.toUnbound() : null; this.properties = properties; this.stageCreate = stageCreate; validate(); @@ -79,11 +81,11 @@ public Schema schema() { } public PartitionSpec spec() { - return spec; + return spec != null ? spec.bind(schema) : null; } public SortOrder writeOrder() { - return order; + return order != null ? order.bind(schema) : null; } public Map properties() {