Skip to content

API for more ergonomic construction of RecordBatchOptions #2728

@alamb

Description

@alamb

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
When creating a RecordBatchOptions object it would be nice to use a standard Rust patterns of either

A builder interface :

let options = RecordBatchOptions::new()
  .with_rows_count(Some(row_count))

Or Default::default() for pub structs:

let options = RecordBatchOptions{
      row_count:Some(row_count),
      ..Default::default()
    };

However, there is no builder interface provided and RecordBatchOptions is marked as non-exhaustive so you get this error

error[E0639]: cannot create non-exhaustive struct using struct expression
   --> /home/isidentical/projects/arrow-datafusion/datafusion/core/src/physical_plan/coalesce_batches.rs:295:19
    |
295 |       let options = RecordBatchOptions {
    |  ___________________^
296 | |         row_count: Some(row_count),
297 | |         ..Default::default()
298 | |     };
    | |_____^

For more information about this error, try `rustc --explain E0639`.

This means you have to use mut like:

  let mut options = RecordBatchOptions::default();
  options.row_count = Some(row_count);

Describe the solution you'd like
Add a builder interface for RecordBatchOptions

Additional context

See comments from @isidentical apache/datafusion#3439 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrowChanges to the arrow crateenhancementAny new improvement worthy of a entry in the changeloggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions