rdsr commented on a change in pull request #3: Store multiple partition specs 
in table metadata.
URL: https://github.com/apache/incubator-iceberg/pull/3#discussion_r236099449
 
 

 ##########
 File path: core/src/main/java/com/netflix/iceberg/TableMetadata.java
 ##########
 @@ -239,15 +255,42 @@ public Snapshot currentSnapshot() {
 
   public TableMetadata updateTableLocation(String newLocation) {
     return new TableMetadata(ops, null, newLocation,
-        System.currentTimeMillis(), lastColumnId, schema, spec, properties, 
currentSnapshotId,
-        snapshots, snapshotLog);
+        System.currentTimeMillis(), lastColumnId, schema, defaultSpecId, 
specs, properties,
+        currentSnapshotId, snapshots, snapshotLog);
   }
 
   public TableMetadata updateSchema(Schema schema, int lastColumnId) {
+    PartitionSpec.checkCompatibility(spec(), schema);
+    return new TableMetadata(ops, null, location,
+        System.currentTimeMillis(), lastColumnId, schema, defaultSpecId, 
specs, properties,
+        currentSnapshotId, snapshots, snapshotLog);
+  }
+
+  public TableMetadata updatePartitionSpec(PartitionSpec spec) {
     PartitionSpec.checkCompatibility(spec, schema);
+
+    // if the spec already exists, use the same ID. otherwise, use 1 more than 
the highest ID.
+    int newDefaultSpecId = 0;
+    for (Map.Entry<Integer, PartitionSpec> entry : specs.entrySet()) {
+      if (spec.equals(entry.getValue())) {
+        newDefaultSpecId = entry.getKey();
+        break;
+      } else if (newDefaultSpecId <= entry.getKey()) {
+        newDefaultSpecId = entry.getKey() + 1;
+      }
+    }
+
+    Preconditions.checkArgument(defaultSpecId != newDefaultSpecId,
 
 Review comment:
   Why is this precondition checked here and not in the buildReplacement 
function?  [I was wondering if there was scope in lifting this piece of logic 
into a function]

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to