diff --git a/datafusion-examples/examples/sql_frontend.rs b/datafusion-examples/examples/sql_frontend.rs index d03b8a882dc2..839ee95eb181 100644 --- a/datafusion-examples/examples/sql_frontend.rs +++ b/datafusion-examples/examples/sql_frontend.rs @@ -136,10 +136,6 @@ struct MyContextProvider { } impl ContextProvider for MyContextProvider { - fn get_expr_planners(&self) -> Vec> { - vec![] - } - fn get_table_source(&self, name: TableReference) -> Result> { if name.table() == "person" { Ok(Arc::new(MyTableSource { diff --git a/datafusion/core/src/execution/session_state.rs b/datafusion/core/src/execution/session_state.rs index 92a51b0988e2..0620fd5ccd87 100644 --- a/datafusion/core/src/execution/session_state.rs +++ b/datafusion/core/src/execution/session_state.rs @@ -503,6 +503,7 @@ impl SessionState { let mut provider = SessionContextProvider { state: self, tables: HashMap::with_capacity(references.len()), + expr_planners: self.expr_planners(), }; for reference in references { @@ -567,6 +568,7 @@ impl SessionState { let provider = SessionContextProvider { state: self, tables: HashMap::new(), + expr_planners: self.expr_planners(), }; let query = SqlToRel::new_with_options(&provider, self.get_parser_options()); @@ -1590,11 +1592,12 @@ impl SessionStateDefaults { struct SessionContextProvider<'a> { state: &'a SessionState, tables: HashMap>, + expr_planners: Vec>, } impl<'a> ContextProvider for SessionContextProvider<'a> { - fn get_expr_planners(&self) -> Vec> { - self.state.expr_planners() + fn get_expr_planners(&self) -> &[Arc] { + &self.expr_planners } fn get_table_source( diff --git a/datafusion/core/tests/optimizer_integration.rs b/datafusion/core/tests/optimizer_integration.rs index 592178ab6be0..39f745cd3309 100644 --- a/datafusion/core/tests/optimizer_integration.rs +++ b/datafusion/core/tests/optimizer_integration.rs @@ -161,10 +161,6 @@ impl MyContextProvider { } impl ContextProvider for MyContextProvider { - fn get_expr_planners(&self) -> Vec> { - vec![] - } - fn get_table_source(&self, name: TableReference) -> Result> { let table_name = name.table(); if table_name.starts_with("test") { diff --git a/datafusion/expr/src/planner.rs b/datafusion/expr/src/planner.rs index 94c02f87b0ac..009f3512c588 100644 --- a/datafusion/expr/src/planner.rs +++ b/datafusion/expr/src/planner.rs @@ -61,7 +61,9 @@ pub trait ContextProvider { } /// Getter for expr planners - fn get_expr_planners(&self) -> Vec>; + fn get_expr_planners(&self) -> &[Arc] { + &[] + } /// Getter for a UDF description fn get_function_meta(&self, name: &str) -> Option>; diff --git a/datafusion/optimizer/tests/optimizer_integration.rs b/datafusion/optimizer/tests/optimizer_integration.rs index 1aad8d5edd67..c0863839dba1 100644 --- a/datafusion/optimizer/tests/optimizer_integration.rs +++ b/datafusion/optimizer/tests/optimizer_integration.rs @@ -372,10 +372,6 @@ impl MyContextProvider { } impl ContextProvider for MyContextProvider { - fn get_expr_planners(&self) -> Vec> { - vec![] - } - fn get_table_source(&self, name: TableReference) -> Result> { let table_name = name.table(); if table_name.starts_with("test") { diff --git a/datafusion/sql/examples/sql.rs b/datafusion/sql/examples/sql.rs index 44ca08d15abc..1b92a7e116b1 100644 --- a/datafusion/sql/examples/sql.rs +++ b/datafusion/sql/examples/sql.rs @@ -117,10 +117,6 @@ fn create_table_source(fields: Vec) -> Arc { } impl ContextProvider for MyContextProvider { - fn get_expr_planners(&self) -> Vec> { - vec![] - } - fn get_table_source(&self, name: TableReference) -> Result> { match self.tables.get(name.table()) { Some(table) => Ok(Arc::clone(table)), diff --git a/datafusion/sql/src/expr/mod.rs b/datafusion/sql/src/expr/mod.rs index 412b58e172c5..a975716300cb 100644 --- a/datafusion/sql/src/expr/mod.rs +++ b/datafusion/sql/src/expr/mod.rs @@ -979,12 +979,6 @@ mod tests { } impl ContextProvider for TestContextProvider { - fn get_expr_planners( - &self, - ) -> Vec> { - vec![] - } - fn get_table_source(&self, name: TableReference) -> Result> { match self.tables.get(name.table()) { Some(table) => Ok(Arc::clone(table)), diff --git a/datafusion/sql/tests/common/mod.rs b/datafusion/sql/tests/common/mod.rs index 413d75b7e034..b8d8bd12d28b 100644 --- a/datafusion/sql/tests/common/mod.rs +++ b/datafusion/sql/tests/common/mod.rs @@ -76,10 +76,6 @@ impl MockContextProvider { } impl ContextProvider for MockContextProvider { - fn get_expr_planners(&self) -> Vec> { - vec![] - } - fn get_table_source(&self, name: TableReference) -> Result> { let schema = match name.table() { "test" => Ok(Schema::new(vec![