datafusion_expr::logical_plan

Trait UserDefinedLogicalNodeCore

Source
pub trait UserDefinedLogicalNodeCore:
    Debug
    + Eq
    + PartialOrd
    + Hash
    + Sized
    + Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &str;
    fn inputs(&self) -> Vec<&LogicalPlan>;
    fn schema(&self) -> &DFSchemaRef;
    fn expressions(&self) -> Vec<Expr>;
    fn fmt_for_explain(&self, f: &mut Formatter<'_>) -> Result;
    fn with_exprs_and_inputs(
        &self,
        exprs: Vec<Expr>,
        inputs: Vec<LogicalPlan>,
    ) -> Result<Self>;

    // Provided methods
    fn prevent_predicate_push_down_columns(&self) -> HashSet<String> { ... }
    fn from_template(&self, exprs: &[Expr], inputs: &[LogicalPlan]) -> Self { ... }
    fn necessary_children_exprs(
        &self,
        _output_columns: &[usize],
    ) -> Option<Vec<Vec<usize>>> { ... }
    fn supports_limit_pushdown(&self) -> bool { ... }
}
Expand description

This trait facilitates implementation of the UserDefinedLogicalNode.

See the example in user_defined_plan.rs file for an example of how to use this extension API.

Required Methods§

Source

fn name(&self) -> &str

Return the plan’s name.

Source

fn inputs(&self) -> Vec<&LogicalPlan>

Return the logical plan’s inputs.

Source

fn schema(&self) -> &DFSchemaRef

Return the output schema of this logical plan node.

Source

fn expressions(&self) -> Vec<Expr>

Returns all expressions in the current logical plan node. This should not include expressions of any inputs (aka non-recursively). These expressions are used for optimizer passes and rewrites.

Source

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

Write a single line, human readable string to f for use in explain plan.

For example: TopK: k=10

Source

fn with_exprs_and_inputs( &self, exprs: Vec<Expr>, inputs: Vec<LogicalPlan>, ) -> Result<Self>

Create a new UserDefinedLogicalNode with the specified children and expressions. This function is used during optimization when the plan is being rewritten and a new instance of the UserDefinedLogicalNode must be created.

Note that exprs and inputs are in the same order as the result of self.inputs and self.exprs.

So, `self.with_exprs_and_inputs(exprs, ..).expressions() == exprs

Provided Methods§

Source

fn prevent_predicate_push_down_columns(&self) -> HashSet<String>

A list of output columns (e.g. the names of columns in self.schema()) for which predicates can not be pushed below this node without changing the output.

By default, this returns all columns and thus prevents any predicates from being pushed below this node.

Source

fn from_template(&self, exprs: &[Expr], inputs: &[LogicalPlan]) -> Self

👎Deprecated since 39.0.0: use with_exprs_and_inputs instead
Source

fn necessary_children_exprs( &self, _output_columns: &[usize], ) -> Option<Vec<Vec<usize>>>

Returns the necessary input columns for this node required to compute the columns in the output schema

This is used for projection push-down when DataFusion has determined that only a subset of the output columns of this node are needed by its parents. This API is used to tell DataFusion which, if any, of the input columns are no longer needed.

Return None, the default, if this information can not be determined. Returns Some(_) with the column indices for each child of this node that are needed to compute output_columns

Source

fn supports_limit_pushdown(&self) -> bool

Returns true if a limit can be safely pushed down through this UserDefinedLogicalNode node.

If this method returns true, and the query plan contains a limit at the output of this node, DataFusion will push the limit to the input of this node.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§