rdblue commented on code in PR #5627:
URL: https://github.com/apache/iceberg/pull/5627#discussion_r954174104


##########
python/pyiceberg/table/metadata.py:
##########
@@ -327,24 +333,45 @@ def check_sort_orders(cls, values: Dict[str, Any]):
     based on the spec. Implementations must throw an exception if a table’s
     version is higher than the supported version."""
 
-    table_uuid: UUID = Field(alias="table-uuid", default_factory=uuid.uuid4)
-    """A UUID that identifies the table, generated when the table is created.
-    Implementations must throw an exception if a table’s UUID does not match
-    the expected UUID after refreshing metadata."""
-
     last_sequence_number: int = Field(alias="last-sequence-number", 
default=INITIAL_SEQUENCE_NUMBER)
     """The table’s highest assigned sequence number, a monotonically
     increasing long that tracks the order of snapshots in a table."""
 
 
-class TableMetadata:
+TableMetadata = Union[TableMetadataV1, TableMetadataV2]
+
+
+def new_table_metadata(
+    schema: Schema, partition_spec: PartitionSpec, sort_order: SortOrder, 
location: str, properties: Properties = EMPTY_DICT
+) -> TableMetadata:
+    fresh_schema = assign_fresh_schema_ids(schema)
+    fresh_partition_spec = assign_fresh_partition_spec_ids(partition_spec, 
fresh_schema)
+    fresh_sort_order = assign_fresh_sort_order_ids(sort_order, schema, 
fresh_schema)
+
+    return TableMetadataV2(
+        location=location,
+        schemas=[fresh_schema],
+        current_schema_id=fresh_schema.schema_id,
+        partition_specs=[fresh_partition_spec],
+        default_spec_id=fresh_partition_spec.spec_id,
+        sort_orders=[fresh_sort_order],
+        default_sort_order_id=fresh_sort_order.order_id,
+        properties=properties,
+        last_column_id=fresh_schema.highest_field_id,
+        last_partition_id=max(field.field_id for field in 
fresh_partition_spec.fields)

Review Comment:
   Can we make this a method on the partition spec rather than doing it inline 
here?



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

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


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

Reply via email to