pub struct PlanBuilder(/* private fields */);declarative-plans only.Expand description
A Plan under construction. See the module docs.
Implementations§
Source§impl PlanBuilder
impl PlanBuilder
Sourcepub fn scan_parquet(
files: impl IntoIterator<Item = impl Into<ScanFile>>,
file_constant_columns: &[&str],
schema: impl Into<SchemaRef>,
) -> DeltaResult<Self>
pub fn scan_parquet( files: impl IntoIterator<Item = impl Into<ScanFile>>, file_constant_columns: &[&str], schema: impl Into<SchemaRef>, ) -> DeltaResult<Self>
A Parquet scan source over files producing rows matching schema.
file_constant_columns names the per-file-constant output columns (see ScanParquet);
pass &[] when there are none. An empty files yields the absent relation.
Produces an error when any file’s constant count differs from file_constant_columns’s
length, or a file_constant_columns entry is absent from schema.
Sourcepub fn scan_json(
files: impl IntoIterator<Item = impl Into<ScanFile>>,
file_constant_columns: &[&str],
schema: impl Into<SchemaRef>,
) -> DeltaResult<Self>
pub fn scan_json( files: impl IntoIterator<Item = impl Into<ScanFile>>, file_constant_columns: &[&str], schema: impl Into<SchemaRef>, ) -> DeltaResult<Self>
A newline-delimited JSON scan source over files producing rows matching schema. See
ScanJson. Exhibits same behaviour as Self::scan_parquet.
Sourcepub fn values(
schema: impl Into<SchemaRef>,
rows: Vec<Vec<Scalar>>,
) -> DeltaResult<Self>
pub fn values( schema: impl Into<SchemaRef>, rows: Vec<Vec<Scalar>>, ) -> DeltaResult<Self>
Inline literal rows. See Values for the row encoding. Empty rows yields the absent
relation.
Produces an error when any row’s width differs from schema’s top-level field count.
§Example
let schema = Arc::new(StructType::try_new([StructField::not_null("id", DataType::INTEGER)])?);
let plan = PlanBuilder::values(schema, vec![vec![1.into()], vec![2.into()]])?.build()?;Sourcepub fn filter(self, predicate: impl Into<PredicateRef>) -> DeltaResult<Self>
pub fn filter(self, predicate: impl Into<PredicateRef>) -> DeltaResult<Self>
Keep rows where predicate holds. Output schema is unchanged. See Filter.
Produces an error when predicate references a column absent from the input schema.
§Example
let schema = Arc::new(StructType::try_new([StructField::not_null("id", DataType::INTEGER)])?);
let plan = PlanBuilder::values(schema, vec![vec![1.into()], vec![2.into()]])?
.filter(col!("id").is_not_null())?
.build()?;Sourcepub fn project(
self,
expr: impl Into<ExpressionRef>,
schema: impl Into<SchemaRef>,
) -> DeltaResult<Self>
pub fn project( self, expr: impl Into<ExpressionRef>, schema: impl Into<SchemaRef>, ) -> DeltaResult<Self>
Project self through expr into rows of the caller-declared schema. expr must be a
struct constructor / patch matching schema. See Project.
Produces an error when expr references a column absent from the input schema. References
inside a StructPatch are validated by ProjectionStructPatchBuilder when the patch is
§Example
let input = Arc::new(StructType::try_new([
StructField::not_null("id", DataType::INTEGER),
StructField::nullable("name", DataType::STRING),
])?);
let out = Arc::new(StructType::try_new([StructField::not_null("id", DataType::INTEGER)])?);
// Keep only `id`.
let plan = PlanBuilder::values(input, vec![vec![1.into(), "a".into()]])?
.project(Expression::struct_from([col!("id")]), out)?
.build()?;Sourcepub fn project_patch(
self,
patch: impl FnOnce(ProjectionStructPatchBuilder<'_>) -> ProjectionStructPatchBuilder<'_>,
) -> DeltaResult<Self>
pub fn project_patch( self, patch: impl FnOnce(ProjectionStructPatchBuilder<'_>) -> ProjectionStructPatchBuilder<'_>, ) -> DeltaResult<Self>
Project self by editing its columns. edit receives a ProjectionStructPatchBuilder
rooted at self’s schema and records field edits (replace/drop/append); the lowered patch
and the resulting output schema feed the Project node together. See Project.
Produces an error when the patch fails to build – e.g. a replaced or dropped field is absent from the input schema, or a nested path does not resolve.
Sourcepub fn load(self, load: Load) -> DeltaResult<Self>
pub fn load(self, load: Load) -> DeltaResult<Self>
Read data files named by self’s rows. Output schema is load.schema. See Load.
Produces an error when a file_meta/deletion-vector column is absent from the input schema,
or a file_constant_columns entry is absent from the input (its broadcast source) or from
load.schema (the output).
Sourcepub fn aggregate(
self,
aggregate: impl TryInto<Aggregate, Error = Error>,
) -> DeltaResult<Self>
pub fn aggregate( self, aggregate: impl TryInto<Aggregate, Error = Error>, ) -> DeltaResult<Self>
Aggregate self into aggregate (build one with Aggregate::group_by). The output
schema is the group keys followed by the aggregate columns. See Aggregate.
Over an absent input the result is group-arity dependent: a grouped aggregate yields
zero groups and so is absent; a global aggregate (no group keys) still yields one row,
so it aggregates an empty Values input and lets the engine produce that row.
Produces an error when building aggregate fails: a group key or an aggregate’s operand
column is absent from its input schema, or two output columns would share a name.
Sourcepub fn aggregate_by(
self,
keys: impl CollectInto<Vec<ColumnName>>,
aggs: impl FnOnce(AggregateBuilder) -> AggregateBuilder,
) -> DeltaResult<Self>
pub fn aggregate_by( self, keys: impl CollectInto<Vec<ColumnName>>, aggs: impl FnOnce(AggregateBuilder) -> AggregateBuilder, ) -> DeltaResult<Self>
Aggregate self, grouped by keys. aggs receives an AggregateBuilder rooted at
self’s schema and adds the aggregate columns (see AggregateBuilder::max, …). Mirrors
Self::aggregate but spares the caller from naming the input schema, just as
Self::project_patch does for Self::project. See Aggregate.
Produces an error under the same conditions as Self::aggregate.
§Example
let schema = Arc::new(StructType::try_new([
StructField::not_null("id", DataType::INTEGER),
StructField::nullable("version", DataType::LONG),
])?);
// Latest `version` per `id`.
let plan = PlanBuilder::values(schema, vec![vec![1.into(), 7i64.into()]])?
.aggregate_by([column_name!("id")], |a| a.max(column_name!("version")))?
.build()?;Sourcepub fn semi_join(
self,
build: PlanBuilder,
probe_keys: impl IntoIterator<Item = ColumnName>,
build_keys: impl IntoIterator<Item = ColumnName>,
) -> DeltaResult<Self>
pub fn semi_join( self, build: PlanBuilder, probe_keys: impl IntoIterator<Item = ColumnName>, build_keys: impl IntoIterator<Item = ColumnName>, ) -> DeltaResult<Self>
Semi join: emit the self (probe) rows that have a match in build on the join keys.
Output schema mirrors self. Inputs are recorded as [probe, build]. See SemiJoin.
Keys are columns (e.g. column_name!), matched pairwise.
Produces an error when the probe and build key counts differ, or a probe/build key is absent from its input schema.
§Example
let schema = Arc::new(StructType::try_new([StructField::not_null("id", DataType::INTEGER)])?);
let probe = PlanBuilder::values(Arc::clone(&schema), vec![vec![1.into()], vec![2.into()]])?;
let allow = PlanBuilder::values(schema, vec![vec![2.into()]])?;
// Probe rows whose `id` appears in `allow`.
let plan = probe.semi_join(allow, [column_name!("id")], [column_name!("id")])?.build()?;Sourcepub fn anti_join(
self,
build: PlanBuilder,
probe_keys: impl IntoIterator<Item = ColumnName>,
build_keys: impl IntoIterator<Item = ColumnName>,
) -> DeltaResult<Self>
pub fn anti_join( self, build: PlanBuilder, probe_keys: impl IntoIterator<Item = ColumnName>, build_keys: impl IntoIterator<Item = ColumnName>, ) -> DeltaResult<Self>
Anti join: emit the self (probe) rows that have no match in build on the join keys.
An inverted SemiJoin; otherwise as Self::semi_join.
Sourcepub fn union_all(
inputs: impl IntoIterator<Item = PlanBuilder>,
) -> DeltaResult<Self>
pub fn union_all( inputs: impl IntoIterator<Item = PlanBuilder>, ) -> DeltaResult<Self>
Unordered bag union of inputs into a UnionAll. All inputs must share the same schema;
absent inputs are dropped, and a lone present input is forwarded unchanged.
Produces an error when inputs is empty, or two inputs have differing schemas.
§Example
let schema = Arc::new(StructType::try_new([StructField::not_null("id", DataType::INTEGER)])?);
let a = PlanBuilder::values(Arc::clone(&schema), vec![vec![1.into()]])?;
let b = PlanBuilder::values(schema, vec![vec![2.into()]])?;
let plan = PlanBuilder::union_all([a, b])?.build()?;Sourcepub fn build(&self) -> DeltaResult<Plan>
pub fn build(&self) -> DeltaResult<Plan>
Sourcepub fn build_opt(&self) -> DeltaResult<Option<Plan>>
pub fn build_opt(&self) -> DeltaResult<Option<Plan>>
Like Self::build, but yields None for an absent relation instead of an empty plan.
Trait Implementations§
Source§impl Clone for PlanBuilder
impl Clone for PlanBuilder
Source§fn clone(&self) -> PlanBuilder
fn clone(&self) -> PlanBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for PlanBuilder
impl !UnwindSafe for PlanBuilder
impl Freeze for PlanBuilder
impl Send for PlanBuilder
impl Sync for PlanBuilder
impl Unpin for PlanBuilder
impl UnsafeUnpin for PlanBuilder
Blanket Implementations§
Source§impl<T> AsAny for T
impl<T> AsAny for T
Source§fn any_ref(&self) -> &(dyn Any + Sync + Send + 'static)
fn any_ref(&self) -> &(dyn Any + Sync + Send + 'static)
dyn Any reference to the object: Read moreSource§fn as_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ
fn as_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ
Arc<dyn Any> reference to the object: Read moreSource§fn into_any(self: Box<T>) -> Box<dyn Any + Sync + Send>
fn into_any(self: Box<T>) -> Box<dyn Any + Sync + Send>
Box<dyn Any>: Read moreSource§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
std::any::type_name, since Any does not provide it and
Any::type_id is useless as a debugging aid (its Debug is just a mess of hex digits).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<T> FoldWithOption for T
impl<T> FoldWithOption for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<KernelType, ArrowType> TryIntoArrow<ArrowType> for KernelTypewhere
ArrowType: TryFromKernel<KernelType>,
impl<KernelType, ArrowType> TryIntoArrow<ArrowType> for KernelTypewhere
ArrowType: TryFromKernel<KernelType>,
Source§fn try_into_arrow(self) -> Result<ArrowType, ArrowError>
fn try_into_arrow(self) -> Result<ArrowType, ArrowError>
arrow-conversion and (crate features arrow-conversion or declarative-plans or default-engine-base) only.Source§impl<KernelType, ArrowType> TryIntoKernel<KernelType> for ArrowTypewhere
KernelType: TryFromArrow<ArrowType>,
impl<KernelType, ArrowType> TryIntoKernel<KernelType> for ArrowTypewhere
KernelType: TryFromArrow<ArrowType>,
Source§fn try_into_kernel(self) -> Result<KernelType, ArrowError>
fn try_into_kernel(self) -> Result<KernelType, ArrowError>
arrow-conversion and (crate features arrow-conversion or declarative-plans or default-engine-base) only.