{"id":16346400,"url":"https://github.com/milesgranger/pytpch","last_synced_at":"2025-11-08T09:30:31.896Z","repository":{"id":224385464,"uuid":"763127169","full_name":"milesgranger/pytpch","owner":"milesgranger","description":"Python bindings to TPC-H data generation","archived":false,"fork":false,"pushed_at":"2024-02-25T21:06:32.000Z","size":24,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-24T04:47:41.054Z","etag":null,"topics":["benchmarking","tpc-h","tpc-h-benchmark","tpch"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/milesgranger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-25T16:22:56.000Z","updated_at":"2024-04-24T04:47:41.055Z","dependencies_parsed_at":"2024-10-11T00:35:18.439Z","dependency_job_id":"c5045599-d4c6-412a-9a50-79759afb8546","html_url":"https://github.com/milesgranger/pytpch","commit_stats":null,"previous_names":["milesgranger/pytpch"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milesgranger%2Fpytpch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milesgranger%2Fpytpch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milesgranger%2Fpytpch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milesgranger%2Fpytpch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/milesgranger","download_url":"https://codeload.github.com/milesgranger/pytpch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239550272,"owners_count":19657541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmarking","tpc-h","tpc-h-benchmark","tpch"],"created_at":"2024-10-11T00:35:15.959Z","updated_at":"2025-11-08T09:30:31.829Z","avatar_url":"https://github.com/milesgranger.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Ergonomically create [TPC-H](https://www.tpc.org/tpch/) data thru Python as Arrow tables.\n\n\n**NOTE**:\n    This was a weekend project, it is a WIP. For now only x86_64 linux wheels are available on PyPI\n\n```python\n\nimport pytpch\nimport pyarrow as pa\n\n# Generate TPC-H data at scale 1 (~1GB)\ntables: dict[str, pa.Table] = pytpch.dbgen(sf=1)\n\n# Generate a single table at scale 1\ntables: dict[str, pa.Table] = pytpch.dbgen(sf=1, table=pytpch.Table.Nation)\n\n# Generate a single chunk out of n chunks of a single table\n# this is wildly helpful when generating larger scale factors as you can make\n# subsets of the data and store them or join them after some sort of parallelism.\ntables: dict[str, pa.Table] = pytpch.dbgen(sf=1, n_steps=10, step=1, table=pytpch.Table.Nation)\n\n\n# NOTE! As mentioned in the docs for this function, it is NOT thread-safe.\n#       If you want to generate data in parallel, you must do so in other processes for now\n#       by using things like `multiprocessing` or `concurrent.futures.ProcessPoolExecutor`.\n#       This is a TODO, as the original C code uses copious amounts of global and static function\n#       variables to maintain state, and while the state is reset between function calls from refactoring\n#       in milesgranger/libdbgen, these shared global states are not removed so thus not thread-safe.\n#\n# Example of generating data in parallel:\nfrom concurrent.futures import ProcessPoolExecutor\n\nn_steps = 10  # 10 total chunks\n\ndef gen_step(step):\n    return pytpch.dbgen(sf=10, n_steps=n_steps, nth_step=step)\n\nwith ProcessPoolExecutor() as executor:\n    jobs: list[dict[str, pa.Table]] = list(executor.map(gen_step, range(n_steps)))\n  \n\n# Default reference queries provided (1-22) as:\nprint(pytpch.QUERY_1)\n```\n\n---\n\n### Tell me more...\n\nPython bindings (thru Rust, b/c why not) to [libdbgen](https://github.com/milesgranger/libdbgen) \nwhich is a fork of [databricks/tpch-dbgen](https://github.com/databricks/tpch-dbgen) for generating \n[TPC-H data](https://www.tpc.org/tpch/).\n\ntpch-dbgen is originally a CLI to generate CSV files for TPC-H data. I wanted to make it into an ergonomic\nPython API for use in other projects. \n\nTODOS (roughly in order of priority):\n  - [ ] Support for more than Linux x86_64 (mostly just adapting C lib and updating CI)\n  - [ ] Remove verbose stdout\n  - [ ] Write directly to Arrow, removing CSV writing (w/ nanoarrow probably)\n  - [ ] Make thread safe (remove global and static function variables in C lib, and remove changing of CWD)\n  - [ ] Separate out the Rust stuff into it's own crate.\n\n### Build from source...\n\nRoughly:\n\n- `git clone --recursive git@github.com:milesgranger/pytpch.git`\n- `python -m pip install maturin`\n- `maturin build --release`\n\nThat'll only work if you're on x86_64 linux for now, you can try adapting `build.rs` but good luck with that. For now.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilesgranger%2Fpytpch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmilesgranger%2Fpytpch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilesgranger%2Fpytpch/lists"}