diff --git a/datafusion/common/src/dfschema.rs b/datafusion/common/src/dfschema.rs index a33973790c60c..85b97aac037d6 100644 --- a/datafusion/common/src/dfschema.rs +++ b/datafusion/common/src/dfschema.rs @@ -915,11 +915,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 9fb241f49db33..147d4040c8c7c 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 93f197ec9438b..8f20da183a933 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 221faa3019ab3..5d90aaedb943d 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, diff --git a/testing b/testing index 6d64695090dcc..bb8b92eb0ba7d 160000 --- a/testing +++ b/testing @@ -1 +1 @@ -Subproject commit 6d64695090dccfccd4ad81fce99ae2ab2a4e7796 +Subproject commit bb8b92eb0ba7d9d1ae2348f454d97dd361d36ade