From 97d4e903ebd525359749e2c6d9d159b9a786bcf2 Mon Sep 17 00:00:00 2001 From: Noah Date: Sat, 5 Dec 2026 11:51:01 -0500 Subject: [PATCH] fix: list tables without their metadata tables `table_names()` listed `t$snapshots`, `t$manifests` and `t$history` for every table. `SHOW TABLES` showed them as base tables, and `information_schema` looked each one up, loading every table from the catalog four times. Spark, Trino and Flink list only tables and resolve metadata tables by name, which still works here. --- crates/datafusion/src/catalog/schema.rs | 12 ++++-------- crates/datafusion/tests/catalog_provider.rs | 3 --- .../testdata/slts/df_test/show_tables.slt | 9 --------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/crates/datafusion/src/catalog/schema.rs b/crates/datafusion/src/catalog/schema.rs index 40492e6c..5efd4b9a 100644 --- a/crates/datafusion/src/catalog/schema.rs +++ b/crates/datafusion/src/catalog/schema.rs @@ -113,17 +113,13 @@ impl IcebergSchemaProvider { #[async_trait] impl SchemaProvider for IcebergSchemaProvider { + /// Lists the tables but not their metadata tables, as Spark, Trino and Flink + /// do: `t$snapshots` resolves by name. Listing them would make + /// `information_schema` load each table again for every metadata table. fn table_names(&self) -> Vec { self.tables .iter() - .flat_map(|entry| { - let table_name = entry.key().clone(); - [table_name.clone()].into_iter().chain( - MetadataTableType::all_types().map(move |metadata_table_name| { - format!("{}${}", table_name, metadata_table_name.as_str()) - }), - ) - }) + .map(|entry| entry.key().clone()) .collect() } diff --git a/crates/datafusion/tests/catalog_provider.rs b/crates/datafusion/tests/catalog_provider.rs index 90f69678..58e6bbb6 100644 --- a/crates/datafusion/tests/catalog_provider.rs +++ b/crates/datafusion/tests/catalog_provider.rs @@ -134,9 +134,6 @@ async fn test_provider_list_table_names() -> Result<(), Box> { insta::assert_debug_snapshot!(&result, @r#" [ "my_table", - "my_table$snapshots", - "my_table$manifests", - "my_table$history", ] "#); diff --git a/crates/sqllogictest/testdata/slts/df_test/show_tables.slt b/crates/sqllogictest/testdata/slts/df_test/show_tables.slt index 29cc3cd7..25711ad0 100644 --- a/crates/sqllogictest/testdata/slts/df_test/show_tables.slt +++ b/crates/sqllogictest/testdata/slts/df_test/show_tables.slt @@ -26,17 +26,8 @@ datafusion information_schema schemata VIEW datafusion information_schema tables VIEW datafusion information_schema views VIEW default default test_binary_table BASE TABLE -default default test_binary_table$history BASE TABLE -default default test_binary_table$manifests BASE TABLE -default default test_binary_table$snapshots BASE TABLE default default test_encrypted_round_trip BASE TABLE -default default test_encrypted_round_trip$history BASE TABLE -default default test_encrypted_round_trip$manifests BASE TABLE -default default test_encrypted_round_trip$snapshots BASE TABLE default default test_partitioned_table BASE TABLE -default default test_partitioned_table$history BASE TABLE -default default test_partitioned_table$manifests BASE TABLE -default default test_partitioned_table$snapshots BASE TABLE default information_schema columns VIEW default information_schema df_settings VIEW default information_schema parameters VIEW