Skip to content

Commit

Permalink
problem with schema evolution
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinjqliu committed Jan 22, 2024
1 parent 94d288a commit c09e7e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pyiceberg/table/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,9 @@ def _(update: AddSchemaUpdate, base_metadata: TableMetadata, context: _TableMeta
if update.last_column_id < base_metadata.last_column_id:
raise ValueError(f"Invalid last column id {update.last_column_id}, must be >= {base_metadata.last_column_id}")

# PROBLEM: `update.schema_`'s `schema_id` starts with 0 but should be 1
# fresh_schema = assign_fresh_schema_ids(update.schema_)

context.add_update(update)
return base_metadata.model_copy(
update={
Expand Down
7 changes: 6 additions & 1 deletion tests/catalog/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ def test_commit_table(catalog: InMemoryCatalog) -> None:
NestedField(4, "add", LongType()),
)

assert given_table.metadata.current_schema_id == 0
assert len(given_table.metadata.schemas) == 1
assert given_table.metadata.schemas[0] == TEST_TABLE_SCHEMA
assert given_table.metadata.last_column_id == TEST_TABLE_SCHEMA.highest_field_id

# When
response = given_table.catalog._commit_table( # pylint: disable=W0212
CommitTableRequest(
Expand All @@ -384,7 +389,7 @@ def test_commit_table(catalog: InMemoryCatalog) -> None:

# Then
assert response.metadata.table_uuid == given_table.metadata.table_uuid
# assert len(response.metadata.schemas) == 1
assert len(response.metadata.schemas) == 1
# assert response.metadata.schemas[0] == new_schema


Expand Down

0 comments on commit c09e7e9

Please sign in to comment.