Skip to content

Consistent schema handling, zero-col projections, and shared traits for record batch builders#160

Merged
nvictus merged 2 commits intoabdenlab:mainfrom
nvictus:refactor-models
Mar 4, 2026
Merged

Consistent schema handling, zero-col projections, and shared traits for record batch builders#160
nvictus merged 2 commits intoabdenlab:mainfrom
nvictus:refactor-models

Conversation

@nvictus
Copy link
Copy Markdown
Member

@nvictus nvictus commented Mar 4, 2026

  • Introduced a batch module with RecordBatchBuilder and Push<T> traits, replacing 7 identical local trait definitions. All concrete builders implement these shared traits.

  • All 7 BatchBuilder structs now compute the Arrow schema once at construction and reuse it in finish() via RecordBatch::try_new(). Previously, finish() used try_from_iter() which inferred a new schema from the arrays, causing mismatches (nullability, dictionary metadata).

  • Zero-column batches now correctly preserve row counts via try_new_with_options().

nvictus added 2 commits March 4, 2026 13:14
Store the Arrow schema once at construction time (as SchemaRef) and use
RecordBatch::try_new() with the stored schema in finish(), instead of
RecordBatch::try_from_iter() which inferred a new schema from arrays.
This fixes schema mismatches where nullability or metadata could diverge
between the declared schema and the batch schema.

Also track row_count in each builder to support zero-column batches via
RecordBatch::try_new_with_options(), enabling row-counting use cases
like SELECT COUNT(*) when no columns are projected.

Applies to all 7 BatchBuilder implementations: sequence, alignment, bed,
gxf, variant, bbi/base, and bbi/zoom.
Extract the duplicated Push<T> trait definition and the common
schema()/finish() interface from all 7 BatchBuilder structs into a
shared `batch` module. Each concrete BatchBuilder now implements the
RecordBatchBuilder trait (for schema/finish) and crate::batch::Push<T>
(for record ingestion) instead of defining its own local copies.
@nvictus nvictus merged commit 21633b9 into abdenlab:main Mar 4, 2026
7 of 8 checks passed
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