← Back to Pull requests

Add TPC-H nation and region key-width options #432

Open
kjmph opened this pull request with 130 lines diff across 6 files
View on GitHub
kjmph kjmph commented on Oct 13, 2026 15:00 UTC
Author

Expose independent i32/i64 options through the data generator and Presto setup script, preserving i64 defaults. Record the choices in dataset metadata and reject unsupported overrides before replacing existing data.

Add focused coverage for argument forwarding, inferred DDL, and validation.

Diff: 130 lines (+124 / -6) across 6 files Reviewer: paul-aiyedun Review duration: 74209m
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.46) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 130 lines diff across 6 files
0.46
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.89 · 5 substantive comment(s)
0.89
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
88%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.292
Real PR Conversation Timeline
15 items
copy-pr-bot[bot] copy-pr-bot[bot] commented on Oct 13, 2026 15:00 UTC
Bot

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

paul-aiyedun paul-aiyedun commented on code on Oct 13, 2026 17:46 UTC
Code Review
presto/README.md:1
@@ -167,6 +167,14 @@ Set up the tables with the scripts in `presto/scripts` (run each with `--help` f
 - `setup_benchmark_tables.sh` sets up tables on data that already exists, either locally under `PRESTO_DATA_DIR` (`-d`) or in S3 (`-r`, see [Remote Data Sources](#remote-data-sources-aws-s3)). It starts a CPU Presto instance, creates the tables, runs ANALYZE, and stops the instance.
 - `setup_benchmark_data_and_tables.sh` first generates the data under `PRESTO_DATA_DIR`, then runs `setup_benchmark_tables.sh` on it.
 
+For TPC-H with tpchgen, both `setup_benchmark_data_and_tables.sh` and `benchmark_data_tools/generate_data_files.py`
+generate nation and region keys as `i32` by default. Use `--nationkey-type i64` and/or `--regionkey-type i64`
+to select wider keys independently. The nation option applies to
+`c_nationkey`, `s_nationkey`, and `n_nationkey`; the region option applies to `n_regionkey` and
+`r_regionkey`. Nation and region IDs stay within 0–24 and 0–4, respectively, at every scale factor.
+Generated table schemas infer `INTEGER` for `i32` keys and `BIGINT` for `i64` keys from the Parquet files.
+The selected types are recorded in `metadata.json`. These overrides require the TPC-H tpchgen path.

Can this be covered by the CLI help text instead? This seems too specific for the README.

paul-aiyedun paul-aiyedun commented on code on Oct 13, 2026 18:01 UTC
Code Review
benchmark_data_tools/generate_data_files.py:1
@@ -623,6 +646,18 @@ def build_default_codec_defs():
         default=None,
         help="Path to a JSON file specifying per-table/per-column encoding, compression, and dictionary settings.",
     )
+    parser.add_argument(
+        "--nationkey-type",
+        choices=["i32", "i64"],
+        default=None,
+        help="TPC-H tpchgen type for c_nationkey, s_nationkey, and n_nationkey (default: i32).",
+    )
+    parser.add_argument(
+        "--regionkey-type",
+        choices=["i32", "i64"],
+        default=None,
+        help="TPC-H tpchgen type for n_regionkey and r_regionkey (default: i32).",
+    )

Is there a reason for making this configurable i.e. can we always use i32?

paul-aiyedun paul-aiyedun commented on code on Oct 13, 2026 18:03 UTC
Code Review
benchmark_data_tools/generate_data_files.py:1
@@ -59,6 +61,10 @@ def generate_partition(
         str(_PARQUET_VERSION),
         "--row-group-bytes",
         str(approx_row_group_bytes),
+        "--nationkey-type",
+        nationkey_type,
+        "--regionkey-type",
+        regionkey_type,

Please update related schemas in the presto/testing/common/schemas/tpch directory (using the generate_test_files.sh script).

paul-aiyedun paul-aiyedun commented on code on Oct 13, 2026 18:25 UTC
Code Review
benchmark_data_tools/generate_data_files.py:1
@@ -257,6 +278,8 @@ def write_metadata(args, codec_defs=None, generator_version=None):
         "max_rows_per_file": args.max_rows_per_file,
         "approx_row_group_bytes": args.approx_row_group_bytes,
     }
+    if using_tpchgen:
+        metadata["nationkey_type"], metadata["regionkey_type"] = validate_key_types(args)

Can we have the metadata describe the generated schema in a more generic way i.e. capture column types (and possibly other metadata) for all columns (grouped by table), rather than adding specific fields for these columns?

kjmph kjmph commented on code on Oct 14, 2026 13:17 UTC
Code Review
benchmark_data_tools/generate_data_files.py:1
@@ -623,6 +646,18 @@ def build_default_codec_defs():
         default=None,
         help="Path to a JSON file specifying per-table/per-column encoding, compression, and dictionary settings.",
     )
+    parser.add_argument(
+        "--nationkey-type",
+        choices=["i32", "i64"],
+        default=None,
+        help="TPC-H tpchgen type for c_nationkey, s_nationkey, and n_nationkey (default: i32).",
+    )
+    parser.add_argument(
+        "--regionkey-type",
+        choices=["i32", "i64"],
+        default=None,
+        help="TPC-H tpchgen type for n_regionkey and r_regionkey (default: i32).",
+    )

I didn't want to close off the tpchgen-cli default of i64, and technically, while Parquet will represent smaller integer values with i32 (and thus won't reduce file size anymore), when hydrated to Arrow, an i8 would reduce the amount of bytes designated to keys. So, for large scale factors, there could be a slightly more optimal value. Don't really have the inclination to prod this right now, yet could be a future thing. However, yes, if you want to hard code i32, that's fine with me.

kjmph kjmph commented on code on Oct 14, 2026 13:20 UTC
Code Review
benchmark_data_tools/generate_data_files.py:1
@@ -59,6 +61,10 @@ def generate_partition(
         str(_PARQUET_VERSION),
         "--row-group-bytes",
         str(approx_row_group_bytes),
+        "--nationkey-type",
+        nationkey_type,
+        "--regionkey-type",
+        regionkey_type,

Right, I can, just a note that those aren't consulted if the data is created via setup_benchmark_tables.sh path, we generate the DDL from the Parquet files, not using this DDL. However, I can fix in this PR, since it switches the default.

kjmph kjmph commented on code on Oct 14, 2026 13:51 UTC
Code Review
benchmark_data_tools/generate_data_files.py:1
@@ -257,6 +278,8 @@ def write_metadata(args, codec_defs=None, generator_version=None):
         "max_rows_per_file": args.max_rows_per_file,
         "approx_row_group_bytes": args.approx_row_group_bytes,
     }
+    if using_tpchgen:
+        metadata["nationkey_type"], metadata["regionkey_type"] = validate_key_types(args)

See e88b2d6

kjmph kjmph commented on code on Oct 14, 2026 13:51 UTC
Code Review
presto/README.md:1
@@ -167,6 +167,14 @@ Set up the tables with the scripts in `presto/scripts` (run each with `--help` f
 - `setup_benchmark_tables.sh` sets up tables on data that already exists, either locally under `PRESTO_DATA_DIR` (`-d`) or in S3 (`-r`, see [Remote Data Sources](#remote-data-sources-aws-s3)). It starts a CPU Presto instance, creates the tables, runs ANALYZE, and stops the instance.
 - `setup_benchmark_data_and_tables.sh` first generates the data under `PRESTO_DATA_DIR`, then runs `setup_benchmark_tables.sh` on it.
 
+For TPC-H with tpchgen, both `setup_benchmark_data_and_tables.sh` and `benchmark_data_tools/generate_data_files.py`
+generate nation and region keys as `i32` by default. Use `--nationkey-type i64` and/or `--regionkey-type i64`
+to select wider keys independently. The nation option applies to
+`c_nationkey`, `s_nationkey`, and `n_nationkey`; the region option applies to `n_regionkey` and
+`r_regionkey`. Nation and region IDs stay within 0–24 and 0–4, respectively, at every scale factor.
+Generated table schemas infer `INTEGER` for `i32` keys and `BIGINT` for `i64` keys from the Parquet files.
+The selected types are recorded in `metadata.json`. These overrides require the TPC-H tpchgen path.

See e88b2d6

kjmph kjmph commented on code on Oct 14, 2026 13:52 UTC
Code Review
benchmark_data_tools/generate_data_files.py:1
@@ -623,6 +646,18 @@ def build_default_codec_defs():
         default=None,
         help="Path to a JSON file specifying per-table/per-column encoding, compression, and dictionary settings.",
     )
+    parser.add_argument(
+        "--nationkey-type",
+        choices=["i32", "i64"],
+        default=None,
+        help="TPC-H tpchgen type for c_nationkey, s_nationkey, and n_nationkey (default: i32).",
+    )
+    parser.add_argument(
+        "--regionkey-type",
+        choices=["i32", "i64"],
+        default=None,
+        help="TPC-H tpchgen type for n_regionkey and r_regionkey (default: i32).",
+    )

Switched default without the optionality in e88b2d6

kjmph kjmph commented on code on Oct 14, 2026 13:52 UTC
Code Review
benchmark_data_tools/generate_data_files.py:1
@@ -59,6 +61,10 @@ def generate_partition(
         str(_PARQUET_VERSION),
         "--row-group-bytes",
         str(approx_row_group_bytes),
+        "--nationkey-type",
+        nationkey_type,
+        "--regionkey-type",
+        regionkey_type,

Updated in e88b2d6

paul-aiyedun paul-aiyedun commented on code on Oct 15, 2026 20:51 UTC
Code Review
benchmark_data_tools/generate_data_files.py:1
@@ -257,6 +278,8 @@ def write_metadata(args, codec_defs=None, generator_version=None):
         "max_rows_per_file": args.max_rows_per_file,
         "approx_row_group_bytes": args.approx_row_group_bytes,
     }
+    if using_tpchgen:

Is there a reason for limiting this to just tpcgen-cli?

paul-aiyedun paul-aiyedun commented on code on Oct 15, 2026 20:57 UTC
Code Review
benchmark_data_tools/tests/key_types_test.py:1

Is this test suite still needed, given the recently added table_schemas_test test suite?

karthikeyann karthikeyann commented on Dec 03, 2026 19:04 UTC
Contributor

/ok to test e88b2d6c472f9ccbc17b015b0035f0b614dbcf61

Reviewers
Assignees
kjmph kjmph
Labels
risk: low confidence: 88.6% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 46.5% (MEDIUM) · Higher = larger blast radius
46.5%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 88.6% · Lower = rushed or shallow review
88.6%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 5.3% · Safe to merge
5.3%