Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation examples for StringViewBuilder::write_str #1

Merged

Conversation

alamb
Copy link

@alamb alamb commented Nov 22, 2024

Note this targets apache#6719 from @tlm365

This adds an example for using the write_str method that expects the builder to behave the same as

https://docs.rs/arrow/latest/arrow/array/builder/type.GenericStringBuilder.html#example-incrementally-writing-strings-with-stdfmtwrite

/// let array = builder.finish();
///
/// let expected = vec![Some("hello"), None, Some("world")];
/// let actual: Vec<_> = array.iter().collect();
/// assert_eq!(expected, actual);
/// ```
///
/// /// # Example incrementally writing strings with `std::fmt::Write`
Copy link
Author

Choose a reason for hiding this comment

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

This test currently fails like this

assertion `left == right` failed
  left: "foo"
 right: "foobarbaz"

Left:  foo
Right: foobarbaz
<Click to see difference>

thread 'main' panicked at arrow-array/src/builder/generic_bytes_view_builder.rs:22:1:
assertion `left == right` failed
  left: "foo"
 right: "foobarbaz"
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:662:5
   1: core::panicking::panic_fmt
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:74:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
   4: rust_out::main::_doctest_main_arrow_array_src_builder_generic_bytes_view_builder_rs_492_0
   5: rust_out::main
   6: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

(because each call to write! generates a new row)

@tlm365
Copy link
Owner

tlm365 commented Nov 22, 2024

LGTM, thanks you so much @alamb

@tlm365 tlm365 merged commit 92732ea into tlm365:cast_numeric_to_string_view Nov 22, 2024
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.

2 participants