Skip to content

Commit 414c826

Browse files
authored
follow up: extract logical plan, rename the plan name (#1354)
1 parent 7a35c8f commit 414c826

File tree

16 files changed

+60
-60
lines changed

16 files changed

+60
-60
lines changed

ballista/rust/client/src/context.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use datafusion::dataframe::DataFrame;
3030
use datafusion::datasource::TableProvider;
3131
use datafusion::error::{DataFusionError, Result};
3232
use datafusion::execution::dataframe_impl::DataFrameImpl;
33-
use datafusion::logical_plan::{CreateExternalTable, LogicalPlan, TableScanPlan};
33+
use datafusion::logical_plan::{CreateExternalTable, LogicalPlan, TableScan};
3434
use datafusion::prelude::{AvroReadOptions, CsvReadOptions};
3535
use datafusion::sql::parser::FileType;
3636

@@ -212,7 +212,7 @@ impl BallistaContext {
212212
options: CsvReadOptions<'_>,
213213
) -> Result<()> {
214214
match self.read_csv(path, options).await?.to_logical_plan() {
215-
LogicalPlan::TableScan(TableScanPlan { source, .. }) => {
215+
LogicalPlan::TableScan(TableScan { source, .. }) => {
216216
self.register_table(name, source)
217217
}
218218
_ => Err(DataFusionError::Internal("Expected tables scan".to_owned())),
@@ -221,7 +221,7 @@ impl BallistaContext {
221221

222222
pub async fn register_parquet(&self, name: &str, path: &str) -> Result<()> {
223223
match self.read_parquet(path).await?.to_logical_plan() {
224-
LogicalPlan::TableScan(TableScanPlan { source, .. }) => {
224+
LogicalPlan::TableScan(TableScan { source, .. }) => {
225225
self.register_table(name, source)
226226
}
227227
_ => Err(DataFusionError::Internal("Expected tables scan".to_owned())),
@@ -235,7 +235,7 @@ impl BallistaContext {
235235
options: AvroReadOptions<'_>,
236236
) -> Result<()> {
237237
match self.read_avro(path, options).await?.to_logical_plan() {
238-
LogicalPlan::TableScan(TableScanPlan { source, .. }) => {
238+
LogicalPlan::TableScan(TableScan { source, .. }) => {
239239
self.register_table(name, source)
240240
}
241241
_ => Err(DataFusionError::Internal("Expected tables scan".to_owned())),

ballista/rust/core/src/serde/logical_plan/to_proto.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use datafusion::logical_plan::{
3737
exprlist_to_fields,
3838
window_frames::{WindowFrame, WindowFrameBound, WindowFrameUnits},
3939
Column, CreateExternalTable, CrossJoin, Expr, JoinConstraint, JoinType, Limit,
40-
LogicalPlan, Repartition, TableScanPlan, Values,
40+
LogicalPlan, Repartition, TableScan, Values,
4141
};
4242
use datafusion::physical_plan::aggregates::AggregateFunction;
4343
use datafusion::physical_plan::functions::BuiltinScalarFunction;
@@ -699,7 +699,7 @@ impl TryInto<protobuf::LogicalPlanNode> for &LogicalPlan {
699699
)),
700700
})
701701
}
702-
LogicalPlan::TableScan(TableScanPlan {
702+
LogicalPlan::TableScan(TableScan {
703703
table_name,
704704
source,
705705
filters,

datafusion/src/execution/context.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ use crate::physical_optimizer::coalesce_batches::CoalesceBatches;
7777
use crate::physical_optimizer::merge_exec::AddCoalescePartitionsExec;
7878
use crate::physical_optimizer::repartition::Repartition;
7979

80-
use crate::logical_plan::plan::ExplainPlan;
80+
use crate::logical_plan::plan::Explain;
8181
use crate::optimizer::single_distinct_to_groupby::SingleDistinctToGroupBy;
8282
use crate::physical_plan::planner::DefaultPhysicalPlanner;
8383
use crate::physical_plan::udf::ScalarUDF;
@@ -664,7 +664,7 @@ impl ExecutionContext {
664664
stringified_plans.push(optimized_plan.to_stringified(plan_type));
665665
})?;
666666

667-
Ok(LogicalPlan::Explain(ExplainPlan {
667+
Ok(LogicalPlan::Explain(Explain {
668668
verbose: e.verbose,
669669
plan: Arc::new(plan),
670670
stringified_plans,
@@ -1178,7 +1178,7 @@ impl FunctionRegistry for ExecutionContextState {
11781178
mod tests {
11791179
use super::*;
11801180
use crate::logical_plan::plan::Projection;
1181-
use crate::logical_plan::TableScanPlan;
1181+
use crate::logical_plan::TableScan;
11821182
use crate::logical_plan::{binary_expr, lit, Operator};
11831183
use crate::physical_plan::functions::{make_scalar_function, Volatility};
11841184
use crate::physical_plan::{collect, collect_partitioned};
@@ -1417,7 +1417,7 @@ mod tests {
14171417
let optimized_plan = ctx.optimize(&logical_plan)?;
14181418
match &optimized_plan {
14191419
LogicalPlan::Projection(Projection { input, .. }) => match &**input {
1420-
LogicalPlan::TableScan(TableScanPlan {
1420+
LogicalPlan::TableScan(TableScan {
14211421
source,
14221422
projected_schema,
14231423
..
@@ -1490,7 +1490,7 @@ mod tests {
14901490
let optimized_plan = ctx.optimize(&plan)?;
14911491
match &optimized_plan {
14921492
LogicalPlan::Projection(Projection { input, .. }) => match &**input {
1493-
LogicalPlan::TableScan(TableScanPlan {
1493+
LogicalPlan::TableScan(TableScan {
14941494
source,
14951495
projected_schema,
14961496
..

datafusion/src/logical_plan/builder.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use crate::datasource::{
2626
};
2727
use crate::error::{DataFusionError, Result};
2828
use crate::logical_plan::plan::{
29-
Aggregate, AnalyzePlan, EmptyRelation, ExplainPlan, Filter, Join, Projection, Sort,
30-
TableScanPlan, ToStringifiedPlan, Union, Window,
29+
Aggregate, Analyze, EmptyRelation, Explain, Filter, Join, Projection, Sort,
30+
TableScan, ToStringifiedPlan, Union, Window,
3131
};
3232
use crate::prelude::*;
3333
use crate::scalar::ScalarValue;
@@ -395,7 +395,7 @@ impl LogicalPlanBuilder {
395395
DFSchema::try_from_qualified_schema(&table_name, &schema)
396396
})?;
397397

398-
let table_scan = LogicalPlan::TableScan(TableScanPlan {
398+
let table_scan = LogicalPlan::TableScan(TableScan {
399399
table_name,
400400
source: provider,
401401
projected_schema: Arc::new(projected_schema),
@@ -699,7 +699,7 @@ impl LogicalPlanBuilder {
699699
let schema = schema.to_dfschema_ref()?;
700700

701701
if analyze {
702-
Ok(Self::from(LogicalPlan::Analyze(AnalyzePlan {
702+
Ok(Self::from(LogicalPlan::Analyze(Analyze {
703703
verbose,
704704
input: Arc::new(self.plan.clone()),
705705
schema,
@@ -708,7 +708,7 @@ impl LogicalPlanBuilder {
708708
let stringified_plans =
709709
vec![self.plan.to_stringified(PlanType::InitialLogicalPlan)];
710710

711-
Ok(Self::from(LogicalPlan::Explain(ExplainPlan {
711+
Ok(Self::from(LogicalPlan::Explain(Explain {
712712
verbose,
713713
plan: Arc::new(self.plan.clone()),
714714
stringified_plans,

datafusion/src/logical_plan/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub use operators::Operator;
5353
pub use plan::{
5454
CreateExternalTable, CreateMemoryTable, CrossJoin, DropTable, EmptyRelation,
5555
JoinConstraint, JoinType, Limit, LogicalPlan, Partitioning, PlanType, PlanVisitor,
56-
Repartition, TableScanPlan, Union, Values,
56+
Repartition, TableScan, Union, Values,
5757
};
5858
pub(crate) use plan::{StringifiedPlan, ToStringifiedPlan};
5959
pub use registry::FunctionRegistry;

datafusion/src/logical_plan/plan.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub struct Window {
100100

101101
/// Produces rows from a table provider by reference or from the context
102102
#[derive(Clone)]
103-
pub struct TableScanPlan {
103+
pub struct TableScan {
104104
/// The name of the table
105105
pub table_name: String,
106106
/// The source of the table
@@ -184,7 +184,7 @@ pub struct DropTable {
184184
/// Produces a relation with string representations of
185185
/// various parts of the plan
186186
#[derive(Clone)]
187-
pub struct ExplainPlan {
187+
pub struct Explain {
188188
/// Should extra (detailed, intermediate plans) be included?
189189
pub verbose: bool,
190190
/// The logical plan that is being EXPLAIN'd
@@ -198,7 +198,7 @@ pub struct ExplainPlan {
198198
/// Runs the actual plan, and then prints the physical plan with
199199
/// with execution metrics.
200200
#[derive(Clone)]
201-
pub struct AnalyzePlan {
201+
pub struct Analyze {
202202
/// Should extra detail be included?
203203
pub verbose: bool,
204204
/// The logical plan that is being EXPLAIN ANALYZE'd
@@ -209,7 +209,7 @@ pub struct AnalyzePlan {
209209

210210
/// Extension operator defined outside of DataFusion
211211
#[derive(Clone)]
212-
pub struct ExtensionPlan {
212+
pub struct Extension {
213213
/// The runtime extension operator
214214
pub node: Arc<dyn UserDefinedLogicalNode + Send + Sync>,
215215
}
@@ -322,7 +322,7 @@ pub enum LogicalPlan {
322322
/// Union multiple inputs
323323
Union(Union),
324324
/// Produces rows from a table provider by reference or from the context
325-
TableScan(TableScanPlan),
325+
TableScan(TableScan),
326326
/// Produces no rows: An empty relation with an empty schema
327327
EmptyRelation(EmptyRelation),
328328
/// Produces the first `n` tuples from its input and discards the rest.
@@ -339,12 +339,12 @@ pub enum LogicalPlan {
339339
Values(Values),
340340
/// Produces a relation with string representations of
341341
/// various parts of the plan
342-
Explain(ExplainPlan),
342+
Explain(Explain),
343343
/// Runs the actual plan, and then prints the physical plan with
344344
/// with execution metrics.
345-
Analyze(AnalyzePlan),
345+
Analyze(Analyze),
346346
/// Extension operator defined outside of DataFusion
347-
Extension(ExtensionPlan),
347+
Extension(Extension),
348348
}
349349

350350
impl LogicalPlan {
@@ -353,7 +353,7 @@ impl LogicalPlan {
353353
match self {
354354
LogicalPlan::EmptyRelation(EmptyRelation { schema, .. }) => schema,
355355
LogicalPlan::Values(Values { schema, .. }) => schema,
356-
LogicalPlan::TableScan(TableScanPlan {
356+
LogicalPlan::TableScan(TableScan {
357357
projected_schema, ..
358358
}) => projected_schema,
359359
LogicalPlan::Projection(Projection { schema, .. }) => schema,
@@ -382,7 +382,7 @@ impl LogicalPlan {
382382
/// Get a vector of references to all schemas in every node of the logical plan
383383
pub fn all_schemas(&self) -> Vec<&DFSchemaRef> {
384384
match self {
385-
LogicalPlan::TableScan(TableScanPlan {
385+
LogicalPlan::TableScan(TableScan {
386386
projected_schema, ..
387387
}) => vec![projected_schema],
388388
LogicalPlan::Values(Values { schema, .. }) => vec![schema],
@@ -413,8 +413,8 @@ impl LogicalPlan {
413413
vec![schema]
414414
}
415415
LogicalPlan::Extension(extension) => vec![extension.node.schema()],
416-
LogicalPlan::Explain(ExplainPlan { schema, .. })
417-
| LogicalPlan::Analyze(AnalyzePlan { schema, .. })
416+
LogicalPlan::Explain(Explain { schema, .. })
417+
| LogicalPlan::Analyze(Analyze { schema, .. })
418418
| LogicalPlan::EmptyRelation(EmptyRelation { schema, .. })
419419
| LogicalPlan::CreateExternalTable(CreateExternalTable { schema, .. }) => {
420420
vec![schema]
@@ -865,7 +865,7 @@ impl LogicalPlan {
865865
write!(f, "Values: {}{}", str_values.join(", "), elipse)
866866
}
867867

868-
LogicalPlan::TableScan(TableScanPlan {
868+
LogicalPlan::TableScan(TableScan {
869869
ref table_name,
870870
ref projection,
871871
ref filters,

datafusion/src/optimizer/filter_push_down.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::datasource::datasource::TableProviderFilterPushDown;
1818
use crate::execution::context::ExecutionProps;
1919
use crate::logical_plan::plan::{Aggregate, Filter, Join, Projection};
2020
use crate::logical_plan::{
21-
and, replace_col, Column, CrossJoin, Limit, LogicalPlan, TableScanPlan,
21+
and, replace_col, Column, CrossJoin, Limit, LogicalPlan, TableScan,
2222
};
2323
use crate::logical_plan::{DFSchema, Expr};
2424
use crate::optimizer::optimizer::OptimizerRule;
@@ -454,7 +454,7 @@ fn optimize(plan: &LogicalPlan, mut state: State) -> Result<LogicalPlan> {
454454

455455
optimize_join(state, plan, left, right)
456456
}
457-
LogicalPlan::TableScan(TableScanPlan {
457+
LogicalPlan::TableScan(TableScan {
458458
source,
459459
projected_schema,
460460
filters,
@@ -490,7 +490,7 @@ fn optimize(plan: &LogicalPlan, mut state: State) -> Result<LogicalPlan> {
490490
issue_filters(
491491
state,
492492
used_columns,
493-
&LogicalPlan::TableScan(TableScanPlan {
493+
&LogicalPlan::TableScan(TableScan {
494494
source: source.clone(),
495495
projection: projection.clone(),
496496
projected_schema: projected_schema.clone(),
@@ -1177,7 +1177,7 @@ mod tests {
11771177
) -> Result<LogicalPlan> {
11781178
let test_provider = PushDownProvider { filter_support };
11791179

1180-
let table_scan = LogicalPlan::TableScan(TableScanPlan {
1180+
let table_scan = LogicalPlan::TableScan(TableScan {
11811181
table_name: "test".to_string(),
11821182
filters: vec![],
11831183
projected_schema: Arc::new(DFSchema::try_from(

datafusion/src/optimizer/limit_push_down.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use super::utils;
2121
use crate::error::Result;
2222
use crate::execution::context::ExecutionProps;
2323
use crate::logical_plan::plan::Projection;
24-
use crate::logical_plan::{Limit, TableScanPlan};
24+
use crate::logical_plan::{Limit, TableScan};
2525
use crate::logical_plan::{LogicalPlan, Union};
2626
use crate::optimizer::optimizer::OptimizerRule;
2727
use std::sync::Arc;
@@ -58,7 +58,7 @@ fn limit_push_down(
5858
}))
5959
}
6060
(
61-
LogicalPlan::TableScan(TableScanPlan {
61+
LogicalPlan::TableScan(TableScan {
6262
table_name,
6363
source,
6464
projection,
@@ -67,7 +67,7 @@ fn limit_push_down(
6767
projected_schema,
6868
}),
6969
Some(upper_limit),
70-
) => Ok(LogicalPlan::TableScan(TableScanPlan {
70+
) => Ok(LogicalPlan::TableScan(TableScan {
7171
table_name: table_name.clone(),
7272
source: source.clone(),
7373
projection: projection.clone(),

datafusion/src/optimizer/projection_push_down.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use crate::error::{DataFusionError, Result};
2222
use crate::execution::context::ExecutionProps;
2323
use crate::logical_plan::plan::{
24-
Aggregate, AnalyzePlan, Join, Projection, TableScanPlan, Window,
24+
Aggregate, Analyze, Join, Projection, TableScan, Window,
2525
};
2626
use crate::logical_plan::{
2727
build_join_schema, Column, DFField, DFSchema, DFSchemaRef, LogicalPlan,
@@ -330,7 +330,7 @@ fn optimize_plan(
330330
}
331331
// scans:
332332
// * remove un-used columns from the scan projection
333-
LogicalPlan::TableScan(TableScanPlan {
333+
LogicalPlan::TableScan(TableScan {
334334
table_name,
335335
source,
336336
filters,
@@ -344,7 +344,7 @@ fn optimize_plan(
344344
has_projection,
345345
)?;
346346
// return the table scan with projection
347-
Ok(LogicalPlan::TableScan(TableScanPlan {
347+
Ok(LogicalPlan::TableScan(TableScan {
348348
table_name: table_name.clone(),
349349
source: source.clone(),
350350
projection: Some(projection),
@@ -366,7 +366,7 @@ fn optimize_plan(
366366
.map(|f| f.qualified_column())
367367
.collect::<HashSet<Column>>();
368368

369-
Ok(LogicalPlan::Analyze(AnalyzePlan {
369+
Ok(LogicalPlan::Analyze(Analyze {
370370
input: Arc::new(optimize_plan(
371371
optimizer,
372372
&a.input,

datafusion/src/optimizer/utils.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use arrow::record_batch::RecordBatch;
2424
use super::optimizer::OptimizerRule;
2525
use crate::execution::context::{ExecutionContextState, ExecutionProps};
2626
use crate::logical_plan::plan::{
27-
Aggregate, AnalyzePlan, ExtensionPlan, Filter, Join, Projection, Sort, Window,
27+
Aggregate, Analyze, Extension, Filter, Join, Projection, Sort, Window,
2828
};
2929
use crate::logical_plan::{
3030
build_join_schema, Column, CreateMemoryTable, DFSchema, DFSchemaRef, Expr,
@@ -236,7 +236,7 @@ pub fn from_plan(
236236
name: name.clone(),
237237
}))
238238
}
239-
LogicalPlan::Extension(e) => Ok(LogicalPlan::Extension(ExtensionPlan {
239+
LogicalPlan::Extension(e) => Ok(LogicalPlan::Extension(Extension {
240240
node: e.node.from_template(expr, inputs),
241241
})),
242242
LogicalPlan::Union(Union { schema, alias, .. }) => {
@@ -249,7 +249,7 @@ pub fn from_plan(
249249
LogicalPlan::Analyze(a) => {
250250
assert!(expr.is_empty());
251251
assert_eq!(inputs.len(), 1);
252-
Ok(LogicalPlan::Analyze(AnalyzePlan {
252+
Ok(LogicalPlan::Analyze(Analyze {
253253
verbose: a.verbose,
254254
schema: a.schema.clone(),
255255
input: Arc::new(inputs[0].clone()),

0 commit comments

Comments
 (0)