diff --git a/datafusion/common/src/dfschema.rs b/datafusion/common/src/dfschema.rs index dd7365c45782..c715fad1122f 100644 --- a/datafusion/common/src/dfschema.rs +++ b/datafusion/common/src/dfschema.rs @@ -909,11 +909,6 @@ impl DFField { self.field = f.into(); self } - - pub fn with_qualifier(mut self, qualifier: impl Into) -> Self { - self.qualifier = Some(qualifier.into()); - self - } } impl From for DFField { diff --git a/datafusion/core/src/datasource/cte.rs b/datafusion/core/src/datasource/cte_worktable.rs similarity index 80% rename from datafusion/core/src/datasource/cte.rs rename to datafusion/core/src/datasource/cte_worktable.rs index 9fb241f49db3..147d4040c8c7 100644 --- a/datafusion/core/src/datasource/cte.rs +++ b/datafusion/core/src/datasource/cte_worktable.rs @@ -35,14 +35,19 @@ use datafusion_common::DataFusionError; use crate::datasource::{TableProvider, TableType}; use crate::execution::context::SessionState; -/// TODO: add docs +/// The temporary working table where the previous iteration of a recursive query is stored +/// Naming is based on PostgreSQL's implementation. +/// See here for more details: www.postgresql.org/docs/11/queries-with.html#id-1.5.6.12.5.4 pub struct CteWorkTable { name: String, + /// This schema must be shared across both the static and recursive terms of a recursive query table_schema: SchemaRef, } impl CteWorkTable { - /// TODO: add doc + /// construct a new CteWorkTable with the given name and schema + /// This schema must match the schema of the recursive term of the query + /// Since the scan method will contain an physical plan that assumes this schema pub fn new(name: &str, table_schema: SchemaRef) -> Self { Self { name: name.to_owned(), diff --git a/datafusion/core/src/datasource/mod.rs b/datafusion/core/src/datasource/mod.rs index 93f197ec9438..8f20da183a93 100644 --- a/datafusion/core/src/datasource/mod.rs +++ b/datafusion/core/src/datasource/mod.rs @@ -20,7 +20,7 @@ //! [`ListingTable`]: crate::datasource::listing::ListingTable pub mod avro_to_arrow; -pub mod cte; +pub mod cte_worktable; pub mod default_table_source; pub mod empty; pub mod file_format; diff --git a/datafusion/core/src/execution/context/mod.rs b/datafusion/core/src/execution/context/mod.rs index 30033aefccd5..9b623d7a51ec 100644 --- a/datafusion/core/src/execution/context/mod.rs +++ b/datafusion/core/src/execution/context/mod.rs @@ -26,7 +26,7 @@ mod parquet; use crate::{ catalog::{CatalogList, MemoryCatalogList}, datasource::{ - cte::CteWorkTable, + cte_worktable::CteWorkTable, function::{TableFunction, TableFunctionImpl}, listing::{ListingOptions, ListingTable}, provider::TableProviderFactory, @@ -1900,6 +1900,9 @@ impl<'a> ContextProvider for SessionContextProvider<'a> { Ok(provider_as_source(provider)) } + /// Create a new CTE work table for a recursive CTE logical plan + /// This table will be used in conjunction with a Worktable physical plan + /// to read and write each iteration of a recursive CTE fn create_cte_work_table( &self, name: &str,