pub struct UnnestOptions {
pub preserve_nulls: bool,
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.
If preserve_nulls
is false, nulls and empty lists
from the input column are not carried through to the output. This
is the default behavior for other systems such as ClickHouse and
DuckDB
If preserve_nulls
is true (the default), nulls from the input
column are carried through to the output.
§Examples
§Unnest(c1)
, preserve_nulls: false
┌─────────┐ ┌─────┐ ┌─────────┐ ┌─────┐
│ {1, 2} │ │ A │ Unnest │ 1 │ │ A │
├─────────┤ ├─────┤ ├─────────┤ ├─────┤
│ null │ │ B │ │ 2 │ │ A │
├─────────┤ ├─────┤ ────────────▶ ├─────────┤ ├─────┤
│ {} │ │ D │ │ 3 │ │ E │
├─────────┤ ├─────┤ └─────────┘ └─────┘
│ {3} │ │ E │ c1 c2
└─────────┘ └─────┘
c1 c2
§Unnest(c1)
, preserve_nulls: true
┌─────────┐ ┌─────┐ ┌─────────┐ ┌─────┐
│ {1, 2} │ │ A │ Unnest │ 1 │ │ A │
├─────────┤ ├─────┤ ├─────────┤ ├─────┤
│ null │ │ B │ │ 2 │ │ A │
├─────────┤ ├─────┤ ────────────▶ ├─────────┤ ├─────┤
│ {} │ │ D │ │ null │ │ B │
├─────────┤ ├─────┤ ├─────────┤ ├─────┤
│ {3} │ │ E │ │ 3 │ │ E │
└─────────┘ └─────┘ └─────────┘ └─────┘
c1 c2 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§
§preserve_nulls: bool
Should nulls in the input be preserved? Defaults to true
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_preserve_nulls(self, preserve_nulls: bool) -> Self
pub fn with_preserve_nulls(self, preserve_nulls: bool) -> Self
Set the behavior with nulls in the input as described on
Self
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 · 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
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 Eq 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 UnwindSafe for UnnestOptions
Blanket Implementations§
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.