Repository navigation
Fix inspect file and partition tables for UUID columns - #4358
rahulsmahadev wants to merge 3 commits into
Conversation
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>
|
@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>
|
@ebyhr could you take a look when you have a chance? Thanks! |
|
@rambleraptor could you take a look when you have a chance? Thanks! |
rambleraptor
left a comment
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
This doesn't appear to work with lists or maps, so UUIDs inside of those will still crash.
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
This is striping valid information from geography / geometry types.
There was a problem hiding this comment.
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>
Rationale for this change
The file, entry and partition metadata tables raise on any table with a
uuidcolumn:readable_metricsholds the uuid bounds asarrow.uuidvalues inside a struct, and pyarrow cannot build an extension type nested in a struct from Python values, sopa.Table.from_pylistraises. This affectsentries(),files(),data_files(),delete_files(),all_files(),all_data_files(),all_delete_files(), andpartitions()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.pyfail withArrowNotImplementedError: extensionwithout the fix and pass with it, on pyarrow 25 and 18:test_inspect_files_and_entries_render_uuid_bounds: the bounds and thearrow.uuidoutput type for the file and entry tables.test_inspect_files_of_empty_table_with_uuid_column:files()andall_files()on a table without snapshots.test_inspect_files_and_entries_with_uuid_in_list_and_map:entries(),files()andall_files()for a table withlist<uuid>andmap<string, uuid>columns.test_inspect_partitions_and_files_render_uuid_partition:partitions(),files()andentries()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.