From 3970b55e85604861a40aa2d63d2c4f2e55d043d6 Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Thu, 8 Jun 2023 07:33:04 -0700 Subject: [PATCH] add copy method to SortKey --- api/src/main/java/org/apache/iceberg/SortKey.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/src/main/java/org/apache/iceberg/SortKey.java b/api/src/main/java/org/apache/iceberg/SortKey.java index 386f7a101fb7..0a06ffa65a4c 100644 --- a/api/src/main/java/org/apache/iceberg/SortKey.java +++ b/api/src/main/java/org/apache/iceberg/SortKey.java @@ -33,6 +33,15 @@ public SortKey(Schema schema, SortOrder sortOrder) { super(schema, fieldTransform(sortOrder)); } + private SortKey(SortKey toCopy) { + // only need deep copy inside StructTransform + super(toCopy); + } + + public SortKey copy() { + return new SortKey(this); + } + private static List fieldTransform(SortOrder sortOrder) { return sortOrder.fields().stream() .map(sortField -> new FieldTransform(sortField.sourceId(), sortField.transform()))