Skip to main content

UnnestOptions

Struct UnnestOptions 

Source
pub struct UnnestOptions {
    pub null_handling: NullHandling,
    pub recursions: Vec<RecursionUnnestOption>,
}
Expand description

Options for unnesting a column that contains a list type, replicating values in the other, non nested rows.

Conceptually this operation is like joining each row with all the values in the list column.

The behavior with NULL and empty input lists is controlled by NullHandling. See its variants for full details.

§Examples

§Unnest(c1), null_handling: NullHandling::Drop

     ┌─────────┐ ┌─────┐                ┌─────────┐ ┌─────┐
     │ {1, 2}  │ │  A  │   Unnest       │    1    │ │  A  │
     ├─────────┤ ├─────┤                ├─────────┤ ├─────┤
     │  null   │ │  B  │                │    2    │ │  A  │
     ├─────────┤ ├─────┤ ────────────▶  ├─────────┤ ├─────┤
     │   {}    │ │  D  │                │    3    │ │  E  │
     ├─────────┤ ├─────┤                └─────────┘ └─────┘
     │   {3}   │ │  E  │                    c1        c2
     └─────────┘ └─────┘
       c1         c2

§Unnest(c1), null_handling: NullHandling::Preserve

     ┌─────────┐ ┌─────┐                ┌─────────┐ ┌─────┐
     │ {1, 2}  │ │  A  │   Unnest       │    1    │ │  A  │
     ├─────────┤ ├─────┤                ├─────────┤ ├─────┤
     │  null   │ │  B  │                │    2    │ │  A  │
     ├─────────┤ ├─────┤ ────────────▶  ├─────────┤ ├─────┤
     │   {}    │ │  D  │                │  null   │ │  B  │
     ├─────────┤ ├─────┤                ├─────────┤ ├─────┤
     │   {3}   │ │  E  │                │    3    │ │  E  │
     └─────────┘ └─────┘                └─────────┘ └─────┘
       c1         c2                        c1        c2

§Unnest(c1), null_handling: NullHandling::PreserveAndExpandEmpty

     ┌─────────┐ ┌─────┐                ┌─────────┐ ┌─────┐
     │ {1, 2}  │ │  A  │   Unnest       │    1    │ │  A  │
     ├─────────┤ ├─────┤                ├─────────┤ ├─────┤
     │  null   │ │  B  │                │    2    │ │  A  │
     ├─────────┤ ├─────┤ ────────────▶  ├─────────┤ ├─────┤
     │   {}    │ │  D  │                │  null   │ │  B  │
     ├─────────┤ ├─────┤                ├─────────┤ ├─────┤
     │   {3}   │ │  E  │                │  null   │ │  D  │
     └─────────┘ └─────┘                ├─────────┤ ├─────┤
       c1         c2                    │    3    │ │  E  │
                                        └─────────┘ └─────┘
                                            c1        c2

recursions instruct how a column should be unnested (e.g unnesting a column multiple time, with depth = 1 and depth = 2). Any unnested column not being mentioned inside this options is inferred to be unnested with depth = 1

Fields§

§null_handling: NullHandling

How to handle NULL and empty list values in the input column. Defaults to NullHandling::Preserve.

§recursions: Vec<RecursionUnnestOption>

If specific columns need to be unnested multiple times (e.g at different depth), declare them here. Any unnested columns not being mentioned inside this option will be unnested with depth = 1

Implementations§

Source§

impl UnnestOptions

Source

pub fn new() -> Self

Create a new UnnestOptions with default values

Source

pub fn with_null_handling(self, null_handling: NullHandling) -> Self

Set the NullHandling mode used when unnesting NULL or empty input lists.

Source

pub fn with_preserve_nulls(self, preserve_nulls: bool) -> Self

Backward-compatible setter that maps the previous boolean preserve_nulls flag onto NullHandling.

true maps to NullHandling::Preserve; false maps to NullHandling::Drop. To opt into the new empty-list-preserving mode, call Self::with_null_handling directly with NullHandling::PreserveAndExpandEmpty.

Source

pub fn preserve_nulls(&self) -> bool

Returns true if NULL input rows produce a single output row containing NULL.

Source

pub fn expand_empty_as_null(&self) -> bool

Returns true if empty input lists should produce a single output row containing NULL.

Source

pub fn with_recursions(self, recursion: RecursionUnnestOption) -> Self

Set the recursions for the unnest operation

Trait Implementations§

Source§

impl Clone for UnnestOptions

Source§

fn clone(&self) -> UnnestOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UnnestOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for UnnestOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for UnnestOptions

Source§

impl Hash for UnnestOptions

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for UnnestOptions

Source§

fn eq(&self, other: &UnnestOptions) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for UnnestOptions

Source§

fn partial_cmp(&self, other: &UnnestOptions) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for UnnestOptions

Auto Trait Implementations§

Blanket Implementations§

Source§

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.