Skip to content

fix: see tables other clients create or drop after the catalog is built - #166

Open
NoahKusaba wants to merge 2 commits into
apache:mainfrom
NoahKusaba:fix/lookup-tables-created-after-listing
Open

NoahKusaba wants to merge 2 commits into
apache:mainfrom
NoahKusaba:fix/lookup-tables-created-after-listing

Conversation

@NoahKusaba

@NoahKusaba NoahKusaba commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Part of #24: the follow-up promised in this comment. Namespaces have the same problem but can't be fixed this way; that's #165. This PR is also what #165's fixes build on: a namespace found later has no listed tables, so its tables must be found through the catalog.

Rationale for this change

A catalog built with IcebergCatalogProvider::catalog_builder lists each namespace's tables once, when it's built, and table() returned None for any name not in that list. In a long-lived session (a server, a notebook):

  • Tables other clients create after the build are never found.
  • A table another client drops stays listed, and every lookup of it fails with TableNotFound. information_schema.columns calls table() for every listed name, so one dropped table makes it fail for the whole catalog.
  • Recreating a table another client dropped fails with "Table … already exists", because register_table checked the same list.

What changes are included in this PR?

The catalog, not the list taken at build time, now decides whether a table exists:

  • table(): in a namespace built by listing the catalog, a name that isn't listed is loaded from the catalog too. Every lookup through the catalog returns None when the catalog reports TableNotFound or NamespaceNotFound. Fixed sets (with_fixed_tables, static catalogs) keep their membership.
  • register_table no longer checks the list; the catalog reports real duplicates itself.
  • deregister_table loads the table from the catalog instead of checking the list. This is needed with the table() change: DROP TABLE looks the table up with table(), then calls deregister_table and ignores its result, so a list check would have reported success for a table found only through the catalog, and dropped nothing.
  • Both reject names containing $, which table() reads as a metadata table (t$snapshots). The list checks used to stop some of these by accident. On main, CREATE TABLE c.ns."x$snapshots" with no table x creates a table that can never be read.

The catalog_builder docs and AGENTS.md describe the new behaviour.

Not changed:

  • table_names() (SHOW TABLES, information_schema.tables) is synchronous, so it still lists the tables found at build time plus DDL run through this provider.
  • Namespaces are still listed once (Namespaces created after the catalog is built, and nested namespaces, can't be used #165).
  • The Hive Metastore catalog reports a missing table as Unexpected, not TableNotFound, so there a dropped table still fails its lookup. REST, SQL, Glue, S3 Tables and the in-memory catalog report TableNotFound.

Are these changes tested?

Yes, in tests/table_lookup.rs, through SQL with a second client of the same catalog:

  • uses_a_table_another_client_created: read, insert, t$snapshots, CREATE TABLE (fails) and CREATE TABLE IF NOT EXISTS (no-op).
  • drops_a_table_another_client_created: the table is really gone for the other client afterwards.
  • forgets_a_table_another_client_dropped: information_schema.columns still works, SELECT and DROP TABLE report "not found", DROP TABLE IF EXISTS succeeds, and the table can be created again.
  • forgets_a_namespace_another_client_dropped: lookups in it report "not found" instead of NamespaceNotFound.
  • refuses_to_create_a_table_named_like_a_metadata_table, refuses_to_drop_a_metadata_table.

The first three, the namespace test and the CREATE test fail on main. Each of the fix's parts is caught when reverted on its own: not looking up unlisted names, deregister_table checking the list, not mapping NamespaceNotFound, and the $ check on drop.

Are there any user-facing changes?

Yes, behaviour only, with no API changes:

  • Tables other clients create are visible without rebuilding the catalog.
  • Looking up a table another client dropped returns "not found" instead of an error.
  • CREATE TABLE and DROP TABLE reject names containing $.

`IcebergCatalogProvider` lists each namespace's tables once, when it is
built, and `table()` returned `None` for any name not in that list. A
long-lived session (a server, a notebook) never saw tables created by
other engines until it was rebuilt, and a table another client dropped
stayed listed and failed every lookup with `TableNotFound`, which also
broke `information_schema.columns` for the whole catalog.

The catalog, not the build-time list, now decides whether a table
exists:

- `table()` in a namespace built by listing the catalog also loads names
  missing from the list. Every catalog-backed lookup, including fixed
  sets (`with_fixed_tables`), returns `None` when the catalog reports
  `TableNotFound` or `NamespaceNotFound`. Fixed sets keep their
  membership otherwise.
- `register_table` no longer refuses names on the list. It refused to
  recreate a table another client had dropped ("already exists"); the
  catalog reports real duplicates itself.
- `deregister_table` loads the table from the catalog instead of checking
  the list. `DROP TABLE` looks a table up with `table()` and then calls
  `deregister_table`, ignoring its result, so dropping a table found only
  through the catalog would have reported success and dropped nothing.

Both now reject names containing `$`, which `table()` reads as a metadata
table (`t$snapshots`). The list checks used to stop some of these by
accident; `CREATE TABLE "x$snapshots"` with no table `x` created a table
that could never be read.

The listing itself (`SHOW TABLES`, `information_schema.tables`) still
reflects the build plus DDL through this provider: `table_names` is
synchronous. Namespaces are still listed once.

The Hive Metastore catalog reports a missing table as `Unexpected`, so
there a dropped table still fails its lookup.
@NoahKusaba
NoahKusaba force-pushed the fix/lookup-tables-created-after-listing branch from d8bbbe9 to d8d8873 Compare December 4, 2026 13:51
`register_table` and `deregister_table` now reject `$` names through
one helper, `ensure_not_metadata_name`, with the same error.

Comments and docs follow the new behaviour: the `tables` field doc no
longer says the names were listed (fixed sets configure them) and says
what still relies on it; the note on duplicate names sits at
`create_table`; `catalog_builder`'s docs and `AGENTS.md` say that table
lookups, `CREATE TABLE` and `DROP TABLE` ask the catalog while
namespaces stay fixed (apache#165).
@NoahKusaba
NoahKusaba marked this pull request as ready for review December 4, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant