datafusion.plan

This module supports physical and logical plans in DataFusion.

Classes

ExecutionPlan

Represent nodes in the DataFusion Physical Plan.

LogicalPlan

Logical Plan.

Module Contents

class datafusion.plan.ExecutionPlan(plan: datafusion._internal.ExecutionPlan)

Represent nodes in the DataFusion Physical Plan.

This constructor should not be called by the end user.

__repr__() str

Print a string representation of the physical plan.

children() List[ExecutionPlan]

Get a list of children `ExecutionPlan`s that act as inputs to this plan.

The returned list will be empty for leaf nodes such as scans, will contain a single value for unary nodes, or two values for binary nodes (such as joins).

display() str

Print the physical plan.

display_indent() str

Print an indented form of the physical plan.

static from_proto(ctx: datafusion.context.SessionContext, data: bytes) ExecutionPlan

Create an ExecutionPlan from protobuf bytes.

Tables created in memory from record batches are currently not supported.

to_proto() bytes

Convert an ExecutionPlan into protobuf bytes.

Tables created in memory from record batches are currently not supported.

_raw_plan
property partition_count: int

Returns the number of partitions in the physical plan.

class datafusion.plan.LogicalPlan(plan: datafusion._internal.LogicalPlan)

Logical Plan.

A LogicalPlan is a node in a tree of relational operators (such as Projection or Filter).

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

`LogicalPlan`s can be created by the SQL query planner, the DataFrame API, or programmatically (for example custom query languages).

This constructor should not be called by the end user.

__repr__() str

Generate a printable representation of the plan.

display() str

Print the logical plan.

display_graphviz() str

Print the graph visualization of the logical plan.

Returns a format`able structure that produces lines meant for graphical display using the `DOT language. This format can be visualized using software from [graphviz](https://graphviz.org/)

display_indent() str

Print an indented form of the logical plan.

display_indent_schema() str

Print an indented form of the schema for the logical plan.

static from_proto(ctx: datafusion.context.SessionContext, data: bytes) LogicalPlan

Create a LogicalPlan from protobuf bytes.

Tables created in memory from record batches are currently not supported.

inputs() List[LogicalPlan]

Returns the list of inputs to the logical plan.

to_proto() bytes

Convert a LogicalPlan to protobuf bytes.

Tables created in memory from record batches are currently not supported.

to_variant() Any

Convert the logical plan into its specific variant.

_raw_plan