pub struct ListComprehension<X: Extension = NoExt> {
pub element: Box<Expr<X>>,
pub vars: ThinVec<Ident>,
pub source: ComprehensionSource<X>,
pub filter: Option<Box<Expr<X>>>,
pub meta: Meta,
}Expand description
A DuckDB list comprehension [element for var in source (if filter)?].
Python-style syntax DuckDB desugars to list_transform/list_filter: it maps
element over each var drawn from source, keeping only those matching the
optional filter. The canonical node keeps the source spelling so a
comprehension round-trips; DuckDB binds it only inside COLUMNS(…) when source
is a column star, but that is a bind-time rule past this parse-level shape. Boxed
inside ArrayExpr::Comprehension to keep the array node within its size budget.
Fields§
§element: Box<Expr<X>>The output expression evaluated for each iteration.
vars: ThinVec<Ident>Loop variables: one name (for x in …) or two (for x, i in … — value plus
1-based index). DuckDB’s binder rejects three or more (lambda max 2); the
parser admits a non-empty list so the multi-var form is representable.
source: ComprehensionSource<X>Input source for this syntax.
filter: Option<Box<Expr<X>>>Optional filter for this syntax.
meta: MetaSource location and node identity.
Trait Implementations§
Source§impl<X: Clone + Extension> Clone for ListComprehension<X>
impl<X: Clone + Extension> Clone for ListComprehension<X>
Source§fn clone(&self) -> ListComprehension<X>
fn clone(&self) -> ListComprehension<X>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more