Skip to content

Use unsigned row counts and source row numbers for TPC-DS - #394

Draft
kevinjqliu wants to merge 5 commits into
clflushopt:mainfrom
kevinjqliu:kevinjqliu/codex-extract-thread-changes
Draft

Use unsigned row counts and source row numbers for TPC-DS#394
kevinjqliu wants to merge 5 commits into
clflushopt:mainfrom
kevinjqliu:kevinjqliu/codex-extract-thread-changes

Conversation

@kevinjqliu

@kevinjqliu kevinjqliu commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Part of #355

change get_row_count to return a u64 (rather than i64)

Description

This PR changes TPC-DS row counts and source row ordinals from signed integers to u64 where they are inherently non-negative.

Changes include:

  • Return u64 from TPC-DS scaling APIs: get_row_count, get_id_count, and get_row_count_for_date.
  • Use u64 for row-generator source row numbers, skip counts, Arrow source row ranges, and Parquet generation ranges.
  • Update business-key and SCD row-number helpers to accept u64.
  • Remove now-unnecessary progress conversion/clamping from signed to unsigned counts.
  • Keep explicit checked conversions at signed boundaries.

Reviewer notes

  • scaling.rs is the source of the row-count type change.
  • row_generator.rs, abstract_row_generator.rs, and random/stream.rs carry the source-row/skip-count type change through generator plumbing.
  • tpcdsgen/src/row/tables/*_row_generator.rs changes are mostly mechanical: source row_number parameters become u64, with local i64::try_from(...) only where generated row fields or signed helper APIs still require i64.
  • tpcdsgen-arrow/src/tables/*.rs changes are also mechanical: Arrow skip/range APIs now take u64.
  • plan.rs, parquet.rs, and generate.rs carry unsigned source-row ranges through CLI generation and Parquet planning.

This stops short of changing generated row fields, join-key APIs, date surrogate keys, and random-key APIs to u64 because those paths still model signed TPC-DS key values, date keys, and -1 sentinel behavior. Migrating those would be a separate schema/key-domain change rather than part of the row-count/source-row cleanup.

@kevinjqliu
kevinjqliu marked this pull request as draft July 27, 2026 00:21
Comment on lines -33 to -41
// Row counts are always non negative, so this conversion never fails.
// Clamp rather than panic if that ever changes: a wrong progress total
// should not abort generation.
debug_assert!(
row_count >= 0,
"negative row count for {}: {row_count}",
table.get_name()
);
let row_count = u64::try_from(row_count).unwrap_or(0);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

can remove this now that we're using u64

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this and next 24 files are the same change (25 files total, 3 lines changed each)

/// Generate a row and its child rows (generateRowAndChildRows)
/// Generate a row and its child rows (generateRowAndChildRows).
///
/// `row_number` is 1-based.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

calling out that row number is 1 based


pub fn compute_scd_key(table: Table, row_number: i64) -> SlowlyChangingDimensionKey {
pub fn compute_scd_key(table: Table, row_number: u64) -> SlowlyChangingDimensionKey {
assert!(row_number > 0, "row number must be 1-based");

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

calling this out, row number should be 1 based here.

compute_scd_key now takes u64, and the row_number - 1 branches require row_number > 0 to avoid underflow.
The row_number - 2 branch is also safe under this precondition because it only runs for row_number % 6 == 0, so the smallest positive value there is 6.

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.

1 participant