Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
LogicalPlan in datafusion::logical_plan - Rust
[go: Go Back, main page]

Enum datafusion::logical_plan::LogicalPlan[][src]

pub enum LogicalPlan {
Show 15 variants Projection { expr: Vec<Expr>, input: Arc<LogicalPlan>, schema: DFSchemaRef, }, Filter { predicate: Expr, input: Arc<LogicalPlan>, }, Window { input: Arc<LogicalPlan>, window_expr: Vec<Expr>, schema: DFSchemaRef, }, Aggregate { input: Arc<LogicalPlan>, group_expr: Vec<Expr>, aggr_expr: Vec<Expr>, schema: DFSchemaRef, }, Sort { expr: Vec<Expr>, input: Arc<LogicalPlan>, }, Join { left: Arc<LogicalPlan>, right: Arc<LogicalPlan>, on: Vec<(Column, Column)>, join_type: JoinType, join_constraint: JoinConstraint, schema: DFSchemaRef, }, CrossJoin { left: Arc<LogicalPlan>, right: Arc<LogicalPlan>, schema: DFSchemaRef, }, Repartition { input: Arc<LogicalPlan>, partitioning_scheme: Partitioning, }, Union { inputs: Vec<LogicalPlan>, schema: DFSchemaRef, alias: Option<String>, }, TableScan { table_name: String, source: Arc<dyn TableProvider>, projection: Option<Vec<usize>>, projected_schema: DFSchemaRef, filters: Vec<Expr>, limit: Option<usize>, }, EmptyRelation { produce_one_row: bool, schema: DFSchemaRef, }, Limit { n: usize, input: Arc<LogicalPlan>, }, CreateExternalTable { schema: DFSchemaRef, name: String, location: String, file_type: FileType, has_header: bool, }, Explain { verbose: bool, plan: Arc<LogicalPlan>, stringified_plans: Vec<StringifiedPlan>, schema: DFSchemaRef, }, Extension { node: Arc<dyn UserDefinedLogicalNode + Send + Sync>, },
}
Expand description

A LogicalPlan represents the different types of relational operators (such as Projection, Filter, etc) and can be created by the SQL query planner and the DataFrame API.

A LogicalPlan represents transforming an input relation (table) to an output relation (table) with a (potentially) different schema. A plan represents a dataflow tree where data flows from leaves up to the root to produce the query result.

Variants

Projection

Evaluates an arbitrary list of expressions (essentially a SELECT with an expression list) on its input.

Fields of Projection

expr: Vec<Expr>

The list of expressions

input: Arc<LogicalPlan>

The incoming logical plan

schema: DFSchemaRef

The schema description of the output

Filter

Filters rows from its input that do not match an expression (essentially a WHERE clause with a predicate expression).

Semantically, <predicate> is evaluated for each row of the input; If the value of <predicate> is true, the input row is passed to the output. If the value of <predicate> is false, the row is discarded.

Fields of Filter

predicate: Expr

The predicate expression, which must have Boolean type.

input: Arc<LogicalPlan>

The incoming logical plan

Window

Window its input based on a set of window spec and window function (e.g. SUM or RANK)

Fields of Window

input: Arc<LogicalPlan>

The incoming logical plan

window_expr: Vec<Expr>

The window function expression

schema: DFSchemaRef

The schema description of the window output

Aggregate

Aggregates its input based on a set of grouping and aggregate expressions (e.g. SUM).

Fields of Aggregate

input: Arc<LogicalPlan>

The incoming logical plan

group_expr: Vec<Expr>

Grouping expressions

aggr_expr: Vec<Expr>

Aggregate expressions

schema: DFSchemaRef

The schema description of the aggregate output

Sort

Sorts its input according to a list of sort expressions.

Fields of Sort

expr: Vec<Expr>

The sort expressions

input: Arc<LogicalPlan>

The incoming logical plan

Join

Join two logical plans on one or more join columns

Fields of Join

left: Arc<LogicalPlan>

Left input

right: Arc<LogicalPlan>

Right input

on: Vec<(Column, Column)>

Equijoin clause expressed as pairs of (left, right) join columns

join_type: JoinType

Join type

join_constraint: JoinConstraint

Join constraint

schema: DFSchemaRef

The output schema, containing fields from the left and right inputs

CrossJoin

Apply Cross Join to two logical plans

Fields of CrossJoin

left: Arc<LogicalPlan>

Left input

right: Arc<LogicalPlan>

Right input

schema: DFSchemaRef

The output schema, containing fields from the left and right inputs

Repartition

Repartition the plan based on a partitioning scheme.

Fields of Repartition

input: Arc<LogicalPlan>

The incoming logical plan

partitioning_scheme: Partitioning

The partitioning scheme

Union

Union multiple inputs

Fields of Union

inputs: Vec<LogicalPlan>

Inputs to merge

schema: DFSchemaRef

Union schema. Should be the same for all inputs.

alias: Option<String>

Union output relation alias

TableScan

Produces rows from a table provider by reference or from the context

Fields of TableScan

table_name: String

The name of the table

source: Arc<dyn TableProvider>

The source of the table

projection: Option<Vec<usize>>

Optional column indices to use as a projection

projected_schema: DFSchemaRef

The schema description of the output

filters: Vec<Expr>

Optional expressions to be used as filters by the table provider

limit: Option<usize>

Optional limit to skip reading

EmptyRelation

Produces no rows: An empty relation with an empty schema

Fields of EmptyRelation

produce_one_row: bool

Whether to produce a placeholder row

schema: DFSchemaRef

The schema description of the output

Limit

Produces the first n tuples from its input and discards the rest.

Fields of Limit

n: usize

The limit

input: Arc<LogicalPlan>

The logical plan

CreateExternalTable

Creates an external table.

Fields of CreateExternalTable

schema: DFSchemaRef

The table schema

name: String

The table name

location: String

The physical location

file_type: FileType

The file type of physical file

has_header: bool

Whether the CSV file contains a header

Explain

Produces a relation with string representations of various parts of the plan

Fields of Explain

verbose: bool

Should extra (detailed, intermediate plans) be included?

plan: Arc<LogicalPlan>

The logical plan that is being EXPLAIN’d

stringified_plans: Vec<StringifiedPlan>

Represent the various stages plans have gone through

schema: DFSchemaRef

The output schema of the explain (2 columns of text)

Extension

Extension operator defined outside of DataFusion

Fields of Extension

node: Arc<dyn UserDefinedLogicalNode + Send + Sync>

The runtime extension operator

Implementations

Get a reference to the logical plan’s schema

Get a vector of references to all schemas in every node of the logical plan

Returns the (fixed) output schema for explain plans

returns all expressions (non-recursively) in the current logical plan node. This does not include expressions in any children

returns all inputs of this LogicalPlan node. Does not include inputs to inputs.

returns all Using join columns in a logical plan

returns all inputs in the logical plan. Returns Ok(true) if all nodes were visited, and Ok(false) if any call to pre_visit or post_visit returned Ok(false) and may have cut short the recursion

Return a formatable structure that produces a single line per node. For example:

Projection: #employee.id
   Filter: #employee.state Eq Utf8(\"CO\")\
      CsvScan: employee projection=Some([0, 3])
use arrow::datatypes::{Field, Schema, DataType};
use datafusion::logical_plan::{lit, col, LogicalPlanBuilder};
let schema = Schema::new(vec![
    Field::new("id", DataType::Int32, false),
]);
let plan = LogicalPlanBuilder::scan_empty(Some("foo_csv"), &schema, None).unwrap()
    .filter(col("id").eq(lit(5))).unwrap()
    .build().unwrap();

// Format using display_indent
let display_string = format!("{}", plan.display_indent());

assert_eq!("Filter: #foo_csv.id Eq Int32(5)\
             \n  TableScan: foo_csv projection=None",
            display_string);

Return a formatable structure that produces a single line per node that includes the output schema. For example:

Projection: #employee.id [id:Int32]\
   Filter: #employee.state Eq Utf8(\"CO\") [id:Int32, state:Utf8]\
     TableScan: employee projection=Some([0, 3]) [id:Int32, state:Utf8]";
use arrow::datatypes::{Field, Schema, DataType};
use datafusion::logical_plan::{lit, col, LogicalPlanBuilder};
let schema = Schema::new(vec![
    Field::new("id", DataType::Int32, false),
]);
let plan = LogicalPlanBuilder::scan_empty(Some("foo_csv"), &schema, None).unwrap()
    .filter(col("id").eq(lit(5))).unwrap()
    .build().unwrap();

// Format using display_indent_schema
let display_string = format!("{}", plan.display_indent_schema());

assert_eq!("Filter: #foo_csv.id Eq Int32(5) [id:Int32]\
            \n  TableScan: foo_csv projection=None [id:Int32]",
            display_string);

Return a formatable structure that produces lines meant for graphical display using the DOT language. This format can be visualized using software from graphviz

This currently produces two graphs – one with the basic structure, and one with additional details such as schema.

use arrow::datatypes::{Field, Schema, DataType};
use datafusion::logical_plan::{lit, col, LogicalPlanBuilder};
let schema = Schema::new(vec![
    Field::new("id", DataType::Int32, false),
]);
let plan = LogicalPlanBuilder::scan_empty(Some("foo.csv"), &schema, None).unwrap()
    .filter(col("id").eq(lit(5))).unwrap()
    .build().unwrap();

// Format using display_graphviz
let graphviz_string = format!("{}", plan.display_graphviz());

If graphviz string is saved to a file such as /tmp/example.dot, the following commands can be used to render it as a pdf:

  dot -Tpdf < /tmp/example.dot  > /tmp/example.pdf

Return a formatable structure with the a human readable description of this LogicalPlan node per node, not including children. For example:

Projection: #id
use arrow::datatypes::{Field, Schema, DataType};
use datafusion::logical_plan::{lit, col, LogicalPlanBuilder};
let schema = Schema::new(vec![
    Field::new("id", DataType::Int32, false),
]);
let plan = LogicalPlanBuilder::scan_empty(Some("foo.csv"), &schema, None).unwrap()
    .build().unwrap();

// Format using display
let display_string = format!("{}", plan.display());

assert_eq!("TableScan: foo.csv projection=None", display_string);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.