Skip to content

Fix inspect file and partition tables for UUID columns - #4358

Open
rahulsmahadev wants to merge 3 commits into
apache:mainfrom
rahulsmahadev:rahul/inspect-uuid-columns
Open

rahulsmahadev wants to merge 3 commits into
apache:mainfrom
rahulsmahadev:rahul/inspect-uuid-columns

Conversation

@rahulsmahadev

@rahulsmahadev rahulsmahadev commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

The file, entry and partition metadata tables raise on any table with a uuid column:

schema = Schema(NestedField(1, "id", LongType()), NestedField(2, "u", UUIDType()))
tbl = catalog.create_table("default.t", schema=schema)
tbl.append(pa.table({"id": pa.array([1], pa.int64()), "u": pa.array([uuid.UUID(int=1).bytes], pa.uuid())}))
tbl.inspect.files()
# pyarrow.lib.ArrowNotImplementedError: extension

readable_metrics holds the uuid bounds as arrow.uuid values inside a struct, and pyarrow cannot build an extension type nested in a struct from Python values, so pa.Table.from_pylist raises. This affects entries(), files(), data_files(), delete_files(), all_files(), all_data_files(), all_delete_files(), and partitions() for a table partitioned by identity on a uuid column, even when the bounds are null.

This change builds these tables with the storage types (fixed_size_binary(16) for a uuid) and casts the result to the unchanged schema. UUID partition values are passed as their 16 bytes, which pyarrow 18 (the minimum supported version) needs. UUID row filters (#2372) are a separate issue and are not touched.

Are these changes tested?

Yes. Four new tests in tests/table/test_inspect.py fail with ArrowNotImplementedError: extension without the fix and pass with it, on pyarrow 25 and 18:

  • test_inspect_files_and_entries_render_uuid_bounds: the bounds and the arrow.uuid output type for the file and entry tables.
  • test_inspect_files_of_empty_table_with_uuid_column: files() and all_files() on a table without snapshots.
  • test_inspect_files_and_entries_with_uuid_in_list_and_map: entries(), files() and all_files() for a table with list<uuid> and map<string, uuid> columns.
  • test_inspect_partitions_and_files_render_uuid_partition: partitions(), files() and entries() for a table partitioned by identity on a uuid column.

Are there any user-facing changes?

Bug fix only: these metadata tables no longer raise on tables with a uuid column. The output schema is unchanged.

This pull request and its description were written by Isaac.

inspect.files(), entries() and partitions() raised ArrowNotImplementedError
on tables with a uuid column: pa.Table.from_pylist cannot build the
arrow.uuid type nested in readable_metrics or a partition struct. Build
these tables from the storage types and cast them to the schema, so the
output types are unchanged. UUID partition values are passed as their 16
bytes, which pyarrow 18 requires.

Co-authored-by: Isaac <no-reply@databricks.com>
@rahulsmahadev

Copy link
Copy Markdown
Contributor Author

@geruh @soumya-ghosh could you take a look when you have a chance? It fixes the file and partition metadata tables from #1626 for tables with uuid columns.

Pass the decoded lower and upper bounds through _storage_value, like the
partition values, so a uuid bound is built from its 16 bytes even when
from_bytes returns a uuid.UUID (proposed in apache#4370).

Co-authored-by: Isaac <no-reply@databricks.com>
@rahulsmahadev

Copy link
Copy Markdown
Contributor Author

@ebyhr could you take a look when you have a chance? Thanks!

@rahulsmahadev

Copy link
Copy Markdown
Contributor Author

@rambleraptor could you take a look when you have a chance? Thanks!

@rambleraptor rambleraptor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple edge cases we should think through. Thanks for doing this!

return _storage_value(from_bytes(field_type, bound)) if bound is not None else None


def _storage_type(data_type: pa.DataType) -> pa.DataType:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't appear to work with lists or maps, so UUIDs inside of those will still crash.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks. readable_metrics types the bounds of a top-level list or map column with the column's type, so list<uuid> and map<string, uuid> columns still failed. _storage_type now also replaces extension types inside lists and maps, and test_inspect_files_and_entries_with_uuid_in_list_and_map covers both. It fails without the change with ArrowNotImplementedError: extension.


if isinstance(data_type, pa.BaseExtensionType):
return data_type.storage_type
if pa.types.is_struct(data_type):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is striping valid information from geography / geometry types.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking. The rows are only built with the storage types: _from_pylist casts the result back to the full schema, so the geoarrow type keeps its metadata. I checked a geometry bound ({"crs": "srid:3857"}) and a geography bound ({"edges": "spherical", "crs": "srid:4269"}): the output schema equals the original and the WKB value is unchanged. With pa.Table.from_pylist, which main uses, both fail with ArrowNotImplementedError: extension when geoarrow-types is installed, so this also fixes these tables for geo columns. Happy to add a test for it if you'd like.

readable_metrics types the bounds of a top-level list or map column with the
column's type, so a list<uuid> or map<string, uuid> column still failed with
ArrowNotImplementedError: extension.

Co-authored-by: Isaac <no-reply@databricks.com>

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.

2 participants