Repository navigation
fix(inspect): resolve dropped partition source columns in specs_struct - #4356
Open
Ankitkj1999 wants to merge 1 commit into
Open
Ankitkj1999 wants to merge 1 commit into
Ankitkj1999 wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 droppedsource_id.Previously:
TableMetadata.specs_struct()only queriedself.schema().find_type(field.source_id), causingValueErrorinentries(),partitions(),files(),data_files(),delete_files(),all_files(),all_data_files(), andall_delete_files().InspectTable._generate_manifests_table()evaluatedspec.partition_type(self.tbl.schema()), which resolved dropped source columns asUnknownType()and rendered historicalpartition_summariesbounds as'null'.This change updates
TableMetadata.specs_struct()to fall back through historical schemas inreversed(self.schemas)(andUnknownType()only if absent from all schemas), and updatesInspectTable._generate_manifests_table()to reusespecs_struct([spec.spec_id]).Are these changes tested?
Yes:
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).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.inspecttables remain queryable and preserve manifest partition summary bounds after dropping an old partition source column.