Repository navigation
Read partitioned parquet directories as single tables - #142
Conversation
A subdirectory of parquet files (e.g. Hive-partitioned yr=2023/p00001.parquet) is now one table named after the directory, instead of one table per part file. All files in a directory must share columns, types and partition keys, otherwise make-tables exits with an error recommending the data be reorganised. Partition keys become TEXT columns. DuckDB sees each dataset through a temporary view so source databases are not modified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Tested locally on fake data. Able to sift through a mixed format (Some .parquet and some directory with different levels of partition). Also on a single file format or a fixed partition format. |
Differing column names or partition keys remain a hard error. Differing column types are now a single warning per column, using the first file's type, and the comparison ignores case so int32 equals Int32. Pandas nullable types such as Int32 now map to the SQL type of their numpy dtype. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Checked and working on the real data on the GAE server. |
parquet_dir is read back from orm.yaml as text, so create_db_engine and find_parquet_tables now declare Path | str. Drops the mypy-style type: ignore in the test, which ty does not honour. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
tim-band
left a comment
There was a problem hiding this comment.
This is great, thanks!
Just one question and one possible docstring update.
Actually, one more; Black is failing on github actions. Fix this by running And commit whatever it does if you are happy with it. |
|
@tim-band Changes made and pre-commit formatting sorted, for your re-review! |
|
Thank you Dylan for your PR! |
Fixes #141
What changed
datafaker/parquet2orm.py: newfind_parquet_tablesdecides what a table is.--parquet-dirhas no loose files and onlykey=valuesubfolders, it is itself one table.make-tableslogs a clear error naming the differing file and recommending each table be moved into its own directory, then exits 1.yr) becomeTEXTcolumns with no "Could not determine type" warning.datafaker/db_utils.py: each dataset is exposed to DuckDB as aTEMP VIEWnamed after the directory (read_parquet([...], hive_partitioning=true, union_by_name=true)), so file-backed source databases are not modified.file_search_pathnow lists only directories with loose files.Why
Previously every part file became its own table keyed by basename, so identical part names (
p00001.parquet) in different tables silently overwrote each other.Reviewer notes
sub/a.parquet,sub/b.parquet) are now one tablesub, not two tables.parquet-dirread back fromorm.yamlis a string, so it is now converted toPath.TEXTinorm.yamleven when DuckDB reads all-numeric keys as integers.tests/test_parquet2orm.py. Locally on Python 3.14 some existing async tests fail with "no current event loop" onmaintoo; with a test-only event-loop shim the whole suite passes (202).tests/test_rst.pycould not run locally.🤖 Generated with Claude Code