Skip to content

fix(inspect): resolve dropped partition source columns in specs_struct - #4356

Open
Ankitkj1999 wants to merge 1 commit into
apache:mainfrom
Ankitkj1999:fix/inspect-dropped-partition-column
Open

Ankitkj1999 wants to merge 1 commit into
apache:mainfrom
Ankitkj1999:fix/inspect-dropped-partition-column

Conversation

@Ankitkj1999

Copy link
Copy Markdown

Closes #4355

Rationale for this change

When a partition field is removed (update_spec().remove_field(...)) and its source column is later dropped (update_schema().delete_column(...)), historical partition specs and manifests still reference the dropped source_id.

Previously:

  • TableMetadata.specs_struct() only queried self.schema().find_type(field.source_id), causing ValueError in entries(), partitions(), files(), data_files(), delete_files(), all_files(), all_data_files(), and all_delete_files().
  • InspectTable._generate_manifests_table() evaluated spec.partition_type(self.tbl.schema()), which resolved dropped source columns as UnknownType() and rendered historical partition_summaries bounds as 'null'.

This change updates TableMetadata.specs_struct() to fall back through historical schemas in reversed(self.schemas) (and UnknownType() only if absent from all schemas), and updates InspectTable._generate_manifests_table() to reuse specs_struct([spec.spec_id]).

Are these changes tested?

Yes:

  • Added unit tests in tests/table/test_metadata.py (test_specs_struct_resolves_dropped_partition_source_from_historical_schemas, test_specs_struct_falls_back_to_unknown_when_source_missing_from_all_schemas).
  • Added integration/inspection tests in tests/table/test_inspect.py (test_inspect_after_dropping_old_partition_column, test_inspect_after_promoting_then_dropping_partition_column).

Are there any user-facing changes?

Bugfix: table.inspect tables remain queryable and preserve manifest partition summary bounds after dropping an old partition source column.

When a partition column is removed and subsequently dropped from the table schema, historical partition specs still reference the dropped source_id. specs_struct() previously only looked up field IDs in the current schema, causing inspect metadata tables to fail with ValueError and manifests partition summaries to lose bound values.

This updates specs_struct() to fall back to historical schemas when resolving source column types, and updates inspect manifest generation to look up partition types from specs_struct().

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

table.inspect metadata tables fail (or lose manifest bounds) after dropping an old partition column

1 participant