Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions datafusion/proto/proto/datafusion.proto
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ message LogicalPlanNode {
ViewTableScanNode view_scan = 24;
CustomTableScanNode custom_scan = 25;
PrepareNode prepare = 26;
DropViewNode drop_view = 27;
}
}

Expand Down Expand Up @@ -210,6 +211,12 @@ message CreateCatalogNode {
DfSchema schema = 3;
}

message DropViewNode {
OwnedTableReference name = 1;
bool if_exists = 2;
DfSchema schema = 3;
}

message CreateViewNode {
reserved 1; // was string name
OwnedTableReference name = 5;
Expand Down
140 changes: 140 additions & 0 deletions datafusion/proto/src/generated/pbjson.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion datafusion/proto/src/generated/prost.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 31 additions & 3 deletions datafusion/proto/src/logical_plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use datafusion_common::{
Result,
};
use datafusion_expr::logical_plan::DdlStatement;
use datafusion_expr::DropView;
use datafusion_expr::{
logical_plan::{
builder::project, Aggregate, CreateCatalog, CreateCatalogSchema,
Expand Down Expand Up @@ -769,6 +770,13 @@ impl AsLogicalPlan for LogicalPlanNode {
.prepare(prepare.name.clone(), data_types)?
.build()
}
LogicalPlanType::DropView(dropview) => Ok(datafusion_expr::LogicalPlan::Ddl(
datafusion_expr::DdlStatement::DropView(DropView {
name: from_owned_table_reference(dropview.name.as_ref(), "DropView")?,
if_exists: dropview.if_exists,
schema: Arc::new(convert_required!(dropview.schema)?),
}),
)),
}
}

Expand Down Expand Up @@ -1385,9 +1393,19 @@ impl AsLogicalPlan for LogicalPlanNode {
LogicalPlan::Ddl(DdlStatement::DropTable(_)) => Err(proto_error(
"LogicalPlan serde is not yet implemented for DropTable",
)),
LogicalPlan::Ddl(DdlStatement::DropView(_)) => Err(proto_error(
"LogicalPlan serde is not yet implemented for DropView",
)),
LogicalPlan::Ddl(DdlStatement::DropView(DropView {
name,
if_exists,
schema,
})) => Ok(protobuf::LogicalPlanNode {
logical_plan_type: Some(LogicalPlanType::DropView(
protobuf::DropViewNode {
name: Some(name.clone().into()),
if_exists: *if_exists,
schema: Some(schema.try_into()?),
},
)),
}),
LogicalPlan::Ddl(DdlStatement::DropCatalogSchema(_)) => Err(proto_error(
"LogicalPlan serde is not yet implemented for DropCatalogSchema",
)),
Expand Down Expand Up @@ -1658,13 +1676,23 @@ mod roundtrip_tests {
.await?;
ctx.sql("CREATE VIEW view_t1(a, b) AS SELECT a, b FROM t1")
.await?;

// SELECT
let plan = ctx
.sql("SELECT * FROM view_t1")
.await?
.into_optimized_plan()?;

let bytes = logical_plan_to_bytes(&plan)?;
let logical_round_trip = logical_plan_from_bytes(&bytes, &ctx)?;
assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}"));

// DROP
let plan = ctx.sql("DROP VIEW view_t1").await?.into_optimized_plan()?;
let bytes = logical_plan_to_bytes(&plan)?;
let logical_round_trip = logical_plan_from_bytes(&bytes, &ctx)?;
assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}"));

Ok(())
}

Expand Down