You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/03/25 22:18:10 UTC

[GitHub] [iceberg] jackye1995 commented on a change in pull request #2354: Core: add row key to format v2

jackye1995 commented on a change in pull request #2354:
URL: https://github.com/apache/iceberg/pull/2354#discussion_r601875062



##########
File path: core/src/main/java/org/apache/iceberg/TableMetadata.java
##########
@@ -877,6 +986,26 @@ private static SortOrder freshSortOrder(int orderId, Schema schema, SortOrder so
     return builder.build();
   }
 
+  private static RowKey freshRowKey(int keyId, Schema schema, RowKey rowKey) {
+    RowKey.Builder builder = RowKey.builderFor(schema).withKeyId(keyId);
+
+    for (RowKeyField field : rowKey.fields()) {
+      // look up the name of the source field in the old schema to get the new schema's id
+      String columnName = rowKey.schema().findColumnName(field.sourceId());
+      Preconditions.checkNotNull(columnName,
+          "Cannot find column in the row key's schema. id: %s, schema: %s",
+          field.sourceId(), rowKey.schema());
+
+      // reassign all row keys with fresh column IDs.
+      Types.NestedField column = schema.findField(columnName);
+      Preconditions.checkNotNull(column,
+          "Cannot find column in the fresh schema. name: %s, schema: %s", columnName, schema);
+      builder.addField(column.fieldId());

Review comment:
       good point, updated




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org