Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
tshauck committed Mar 22, 2024
1 parent 86588e4 commit e57006e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions datafusion/sql/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use std::str::FromStr;
use std::sync::Arc;

use datafusion_common::parsers::CompressionTypeVariant;
use datafusion_common::tree_node::{ConcreteTreeNode, TreeNode};
use datafusion_common::DataFusionError;
use datafusion_expr::LogicalPlan;
use sqlparser::{
Expand Down Expand Up @@ -235,13 +236,10 @@ impl fmt::Display for CreateExternalTable {
}


pub trait UserDefinedStatement: Debug + Display {
pub trait UserDefinedStatement: Debug + Display + TreeNode {
fn to_logical_plan(&self) -> Result<LogicalPlan, DataFusionError>;

fn visit(&self, visitor: &mut RelationVisitor) -> ControlFlow<sqlparser::ast::Visitor>;
}

// Implement Debug, Clone, and PartialEq for ExtensionStatement manually if needed.
#[derive(Debug, Clone)]
pub struct ExtensionStatement {
pub statement: Arc<dyn UserDefinedStatement>,
Expand All @@ -255,6 +253,12 @@ impl ExtensionStatement {
pub fn to_logical_plan(&self) -> Result<LogicalPlan, DataFusionError> {
self.statement.to_logical_plan()
}

pub fn visit<V>(&self, visitor: &mut V) -> ControlFlow<V::Break>
where
V: sqlparser::ast::Visitor {
self.statement.visit(visitor)
}
}

impl Display for ExtensionStatement {
Expand Down

0 comments on commit e57006e

Please sign in to comment.