alamb commented on code in PR #4606:
URL: https://github.com/apache/arrow-datafusion/pull/4606#discussion_r1047699138
##########
datafusion/core/src/catalog/information_schema.rs:
##########
@@ -220,74 +217,113 @@ impl InformationSchemaProvider {
}
}
}
-
- let mem_table: MemTable = builder.into();
-
- Arc::new(mem_table)
}
/// Construct the `information_schema.df_settings` virtual table
- fn make_df_settings(&self) -> Arc<dyn TableProvider> {
- let mut builder = InformationSchemaDfSettingsBuilder::new();
-
+ fn make_df_settings(&self, builder: &mut
InformationSchemaDfSettingsBuilder) {
for (name, setting) in self.config_options.read().options() {
builder.add_setting(name, setting.to_string());
}
-
- let mem_table: MemTable = builder.into();
-
- Arc::new(mem_table)
}
}
impl SchemaProvider for InformationSchemaProvider {
- fn as_any(&self) -> &(dyn any::Any + 'static) {
+ fn as_any(&self) -> &(dyn Any + 'static) {
self
}
fn table_names(&self) -> Vec<String> {
- vec![TABLES.to_string(), VIEWS.to_string(), COLUMNS.to_string()]
+ vec![
+ TABLES.to_string(),
+ VIEWS.to_string(),
+ COLUMNS.to_string(),
+ DF_SETTINGS.to_string(),
+ ]
}
fn table(&self, name: &str) -> Option<Arc<dyn TableProvider>> {
- if name.eq_ignore_ascii_case("tables") {
- Some(self.make_tables())
+ let config = self.config.clone();
+ let table: Arc<dyn PartitionStream> = if
name.eq_ignore_ascii_case("tables") {
+ Arc::new(InformationSchemaTables::new(config))
} else if name.eq_ignore_ascii_case("columns") {
- Some(self.make_columns())
+ Arc::new(InformationSchemaColumns::new(config))
} else if name.eq_ignore_ascii_case("views") {
- Some(self.make_views())
+ Arc::new(InformationSchemaViews::new(config))
} else if name.eq_ignore_ascii_case("df_settings") {
- Some(self.make_df_settings())
+ Arc::new(InformationSchemaDfSettings::new(config))
} else {
- None
- }
+ return None;
+ };
+
+ Some(Arc::new(
+ StreamingTable::try_new(table.schema().clone(),
vec![table]).unwrap(),
+ ))
}
fn table_exist(&self, name: &str) -> bool {
matches!(name.to_ascii_lowercase().as_str(), TABLES | VIEWS | COLUMNS)
}
}
+struct InformationSchemaTables {
+ schema: SchemaRef,
+ config: InformationSchemaConfig,
+}
+
+impl InformationSchemaTables {
+ fn new(config: InformationSchemaConfig) -> Self {
+ let schema = Arc::new(Schema::new(vec![
+ Field::new("table_catalog", DataType::Utf8, false),
+ Field::new("table_schema", DataType::Utf8, false),
+ Field::new("table_name", DataType::Utf8, false),
+ Field::new("table_type", DataType::Utf8, false),
+ ]));
+
+ Self { schema, config }
+ }
+
+ fn builder(&self) -> InformationSchemaTablesBuilder {
+ InformationSchemaTablesBuilder {
+ catalog_names: StringBuilder::new(),
+ schema_names: StringBuilder::new(),
+ table_names: StringBuilder::new(),
+ table_types: StringBuilder::new(),
+ schema: self.schema.clone(),
+ }
+ }
+}
+
+impl PartitionStream for InformationSchemaTables {
Review Comment:
but more verbose than creating a `MemTable`, right?
##########
datafusion/core/src/catalog/information_schema.rs:
##########
@@ -117,15 +121,19 @@ impl CatalogProvider for CatalogWithInformationSchema {
/// providers, they will appear the next time the `information_schema`
/// table is queried.
struct InformationSchemaProvider {
+ config: InformationSchemaConfig,
+}
+
+#[derive(Clone)]
+struct InformationSchemaConfig {
catalog_list: Arc<dyn CatalogList>,
config_options: Arc<RwLock<ConfigOptions>>,
}
-impl InformationSchemaProvider {
+impl InformationSchemaConfig {
/// Construct the `information_schema.tables` virtual table
- fn make_tables(&self) -> Arc<dyn TableProvider> {
+ fn make_tables(&self, builder: &mut InformationSchemaTablesBuilder) {
Review Comment:
maybe we can refactor them in a follow on PR
##########
datafusion/core/src/datasource/streaming.rs:
##########
@@ -0,0 +1,93 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! A simplified [`TableProvider`] for streaming partitioned datasets
Review Comment:
Is the idea that this is the counterpart for `MemTable` but with deferred
execution?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]