Skip to content
12 changes: 10 additions & 2 deletions datafusion/common/src/tree_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ use crate::Result;
/// These macros are used to determine continuation during transforming traversals.
macro_rules! handle_transform_recursion {
($F_DOWN:expr, $F_CHILD:expr, $F_UP:expr) => {{
#[allow(clippy::redundant_closure_call)]
$F_DOWN?
.transform_children(|n| n.map_children($F_CHILD))?
.transform_parent(|n| $F_UP(n))
.transform_parent($F_UP)
}};
}

Expand Down Expand Up @@ -535,6 +534,15 @@ impl<T> Transformed<T> {
TreeNodeRecursion::Jump | TreeNodeRecursion::Stop => Ok(self),
}
}

/// Discards the data of this [`Transformed`] object transforming it into Transformed<()>
pub fn discard_data(self) -> Transformed<()> {
Transformed {
data: (),
transformed: self.transformed,
tnr: self.tnr,
}
}
}

/// Transformation helper to process a sequence of iterable tree nodes that are siblings.
Expand Down
4 changes: 2 additions & 2 deletions datafusion/core/src/execution/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use datafusion_common::{
alias::AliasGenerator,
config::{ConfigExtension, TableOptions},
exec_err, not_impl_err, plan_datafusion_err, plan_err,
tree_node::{TreeNode, TreeNodeRecursion, TreeNodeVisitor},
tree_node::{TreeNodeRecursion, TreeNodeVisitor},
SchemaReference, TableReference,
};
use datafusion_execution::registry::SerializerRegistry;
Expand Down Expand Up @@ -2298,7 +2298,7 @@ impl SQLOptions {
/// Return an error if the [`LogicalPlan`] has any nodes that are
/// incompatible with this [`SQLOptions`].
pub fn verify_plan(&self, plan: &LogicalPlan) -> Result<()> {
plan.visit(&mut BadPlanVisitor::new(self))?;
plan.visit_with_subqueries(&mut BadPlanVisitor::new(self))?;
Ok(())
}
}
Expand Down
18 changes: 18 additions & 0 deletions datafusion/expr/src/logical_plan/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@ impl DdlStatement {
}
}

/// Return a mutable reference to the input `LogicalPlan`, if any
pub fn input_mut(&mut self) -> Option<&mut Arc<LogicalPlan>> {
match self {
DdlStatement::CreateMemoryTable(CreateMemoryTable { input, .. }) => {
Some(input)
}
DdlStatement::CreateExternalTable(_) => None,
DdlStatement::CreateView(CreateView { input, .. }) => Some(input),
DdlStatement::CreateCatalogSchema(_) => None,
DdlStatement::CreateCatalog(_) => None,
DdlStatement::DropTable(_) => None,
DdlStatement::DropView(_) => None,
DdlStatement::DropCatalogSchema(_) => None,
DdlStatement::CreateFunction(_) => None,
DdlStatement::DropFunction(_) => None,
}
}

/// Return a `format`able structure with the a human readable
/// description of this LogicalPlan node per node, not including
/// children.
Expand Down
1 change: 1 addition & 0 deletions datafusion/expr/src/logical_plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub mod display;
pub mod dml;
mod extension;
mod plan;
mod rewrite;
mod statement;

pub use builder::{
Expand Down
Loading