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 c2recursions 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: NullHandlingHow 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
impl UnnestOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new UnnestOptions with default values
Sourcepub fn with_null_handling(self, null_handling: NullHandling) -> Self
pub fn with_null_handling(self, null_handling: NullHandling) -> Self
Set the NullHandling mode used when unnesting NULL or empty
input lists.
Sourcepub fn with_preserve_nulls(self, preserve_nulls: bool) -> Self
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.
Sourcepub fn preserve_nulls(&self) -> bool
pub fn preserve_nulls(&self) -> bool
Returns true if NULL input rows produce a single output row
containing NULL.
Sourcepub fn expand_empty_as_null(&self) -> bool
pub fn expand_empty_as_null(&self) -> bool
Returns true if empty input lists should produce a single
output row containing NULL.
Sourcepub fn with_recursions(self, recursion: RecursionUnnestOption) -> Self
pub fn with_recursions(self, recursion: RecursionUnnestOption) -> Self
Set the recursions for the unnest operation
Trait Implementations§
Source§impl Clone for UnnestOptions
impl Clone for UnnestOptions
Source§fn clone(&self) -> UnnestOptions
fn clone(&self) -> UnnestOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UnnestOptions
impl Debug for UnnestOptions
Source§impl Default for UnnestOptions
impl Default for UnnestOptions
impl Eq for UnnestOptions
Source§impl Hash for UnnestOptions
impl Hash for UnnestOptions
Source§impl PartialEq for UnnestOptions
impl PartialEq for UnnestOptions
Source§impl PartialOrd for UnnestOptions
impl PartialOrd for UnnestOptions
impl StructuralPartialEq for UnnestOptions
Auto Trait Implementations§
impl Freeze for UnnestOptions
impl RefUnwindSafe for UnnestOptions
impl Send for UnnestOptions
impl Sync for UnnestOptions
impl Unpin for UnnestOptions
impl UnsafeUnpin for UnnestOptions
impl UnwindSafe for UnnestOptions
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.