Struct deltalake::arrow::json::reader::ReaderBuilder

source ·
pub struct ReaderBuilder { /* private fields */ }
Expand description

A builder for Reader and Decoder

Implementations§

source§

impl ReaderBuilder

source

pub fn new(schema: Arc<Schema>) -> ReaderBuilder

Create a new ReaderBuilder with the provided SchemaRef

This could be obtained using infer_json_schema if not known

Any columns not present in schema will be ignored, unless strict_mode is set to true. In this case, an error is returned when a column is missing from schema.

source

pub fn new_with_field(field: impl Into<Arc<Field>>) -> ReaderBuilder

Create a new ReaderBuilder that will parse JSON values of field.data_type()

Unlike ReaderBuilder::new this does not require the root of the JSON data to be an object, i.e. {..}, allowing for parsing of any valid JSON value(s)

// Root of JSON schema is a numeric type
let data = "1\n2\n3\n";
let field = Arc::new(Field::new("int", DataType::Int32, true));
let mut reader = ReaderBuilder::new_with_field(field.clone()).build(data.as_bytes()).unwrap();
let b = reader.next().unwrap().unwrap();
let values = b.column(0).as_primitive::<Int32Type>().values();
assert_eq!(values, &[1, 2, 3]);

// Root of JSON schema is a list type
let data = "[1, 2, 3, 4, 5, 6, 7]\n[1, 2, 3]";
let field = Field::new_list("int", field.clone(), true);
let mut reader = ReaderBuilder::new_with_field(field).build(data.as_bytes()).unwrap();
let b = reader.next().unwrap().unwrap();
let list = b.column(0).as_list::<i32>();

assert_eq!(list.offsets().as_ref(), &[0, 7, 10]);
let list_values = list.values().as_primitive::<Int32Type>();
assert_eq!(list_values.values(), &[1, 2, 3, 4, 5, 6, 7, 1, 2, 3]);
source

pub fn with_batch_size(self, batch_size: usize) -> ReaderBuilder

Sets the batch size in rows to read

source

pub fn coerce_primitive(self, coerce_primitive: bool) -> ReaderBuilder

👎Deprecated: Use with_coerce_primitive

Sets if the decoder should coerce primitive values (bool and number) into string when the Schema’s column is Utf8 or LargeUtf8.

source

pub fn with_coerce_primitive(self, coerce_primitive: bool) -> ReaderBuilder

Sets if the decoder should coerce primitive values (bool and number) into string when the Schema’s column is Utf8 or LargeUtf8.

source

pub fn with_strict_mode(self, strict_mode: bool) -> ReaderBuilder

Sets if the decoder should return an error if it encounters a column not present in schema

source

pub fn build<R>(self, reader: R) -> Result<Reader<R>, ArrowError>
where R: BufRead,

Create a Reader with the provided BufRead

source

pub fn build_decoder(self) -> Result<Decoder, ArrowError>

Create a Decoder

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

source§

impl<T> Ungil for T
where T: Send,