diff --git a/datafusion/catalog/src/information_schema.rs b/datafusion/catalog/src/information_schema.rs
index 057d1a819882..83b6d64ef47b 100644
--- a/datafusion/catalog/src/information_schema.rs
+++ b/datafusion/catalog/src/information_schema.rs
@@ -103,12 +103,14 @@ impl InformationSchemaConfig {
// schema name may not exist in the catalog, so we need to check
if let Some(schema) = catalog.schema(&schema_name) {
for table_name in schema.table_names() {
- if let Some(table) = schema.table(&table_name).await? {
+ if let Some(table_type) =
+ schema.table_type(&table_name).await?
+ {
builder.add_table(
&catalog_name,
&schema_name,
&table_name,
- table.table_type(),
+ table_type,
);
}
}
@@ -1359,3 +1361,92 @@ impl PartitionStream for InformationSchemaParameters {
))
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::CatalogProvider;
+
+ #[tokio::test]
+ async fn make_tables_uses_table_type() {
+ let config = InformationSchemaConfig {
+ catalog_list: Arc::new(Fixture),
+ };
+ let mut builder = InformationSchemaTablesBuilder {
+ catalog_names: StringBuilder::new(),
+ schema_names: StringBuilder::new(),
+ table_names: StringBuilder::new(),
+ table_types: StringBuilder::new(),
+ schema: Arc::new(Schema::empty()),
+ };
+
+ assert!(config.make_tables(&mut builder).await.is_ok());
+
+ assert_eq!("BASE TABLE", builder.table_types.finish().value(0));
+ }
+
+ #[derive(Debug)]
+ struct Fixture;
+
+ #[async_trait]
+ impl SchemaProvider for Fixture {
+ // InformationSchemaConfig::make_tables should use this.
+ async fn table_type(&self, _: &str) -> Result