Skip to content

fix(session): list_namespaces mirrors list_tables resolution#7144

Open
YuangGao wants to merge 1 commit into
Eventual-Inc:mainfrom
YuangGao:fix/list-namespaces-rule3-dispatch
Open

fix(session): list_namespaces mirrors list_tables resolution#7144
YuangGao wants to merge 1 commit into
Eventual-Inc:mainfrom
YuangGao:fix/list-namespaces-rule3-dispatch

Conversation

@YuangGao

@YuangGao YuangGao commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Changes Made

Session.list_namespaces ignored attached catalogs and raised when no current catalog was set. It now mirrors Session::list_tables (#7126):

  • Rule 3: <catalog>.<rest> patterns dispatch exclusively to that attached catalog
  • Otherwise: namespaces from the current catalog, qualified with the session alias so results round-trip through set_namespace / list_tables / read_table
  • No current catalog returns [] instead of raising ValueError

Adds Session::list_namespaces in Rust + PySession shim and switches the Python wrapper to delegate.

Related Issues

Closes #7134

@YuangGao YuangGao changed the title list_namespaces mirrors list_tables resolution fix(session): list_namespaces mirrors list_tables resolution Jun 19, 2026
@github-actions github-actions Bot added the fix label Jun 19, 2026
@YuangGao YuangGao marked this pull request as ready for review June 19, 2026 23:31
@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes Session.list_namespaces to mirror the catalog-resolution logic already implemented in Session.list_tables (#7126), adding a Rust-level Session::list_namespaces and a PySession shim so the Python wrapper can simply delegate.

  • Rule 3 dispatch: a <catalog>.<rest> pattern is routed exclusively to that attached catalog, results qualified with the catalog alias so they round-trip through set_namespace / list_tables / read_table.
  • Current-catalog fallback: with no catalog-qualified pattern the current catalog is queried; if no current catalog is set an empty list is returned instead of raising ValueError.
  • MemoryCatalog pattern support: the hard error on any non-None pattern is replaced with proper SQL LIKE filtering via the existing match_pattern helper.

Confidence Score: 5/5

Safe to merge — the change is a well-scoped addition with no modifications to existing write paths or table resolution logic.

The new list_namespaces logic is a direct structural copy of the already-tested list_tables dispatch, the MemoryCatalog change replaces an unconditional error with correct filtering, and five integration tests cover all documented scenarios including the round-trip property.

No files require special attention.

Important Files Changed

Filename Overview
src/daft-session/src/session.rs Adds list_namespaces that mirrors list_tables Rule 3 dispatch and current-catalog fallback; logic is correct and consistent.
src/daft-catalog/src/impls/memory.rs Replaces the hard error on any pattern with proper SQL LIKE filtering via match_pattern; logic is sound.
src/daft-session/src/python.rs Thin PyO3 shim for list_namespaces — correct, follows the same pattern as list_tables.
daft/session.py Python wrapper now delegates to the Rust list_namespaces instead of calling the catalog directly; removes the ValueError on missing current catalog.
daft/daft/init.pyi Adds type stub for the new PySession.list_namespaces method.
tests/test_session.py Adds five targeted tests covering the four dispatch scenarios plus the round-trip property with list_tables; good coverage.
tests/catalog/test_memory.py Adds a test for the new MemoryCatalog pattern-filtering behavior; correct assertions.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Session.list_namespaces(pattern)"] --> B{pattern has a dot\nAND head is\nattached catalog?}
    B -- Yes --> C["get_catalog(head)\n.list_namespaces(rest)"]
    C --> D["qualify results\nwith catalog alias"]
    D --> E["return [cat.ns, ...]"]
    B -- No --> F{current catalog\nset?}
    F -- No --> G["return []"]
    F -- Yes --> H["get_catalog(alias)\n.list_namespaces(pattern)"]
    H --> I["qualify results\nwith alias"]
    I --> E
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["Session.list_namespaces(pattern)"] --> B{pattern has a dot\nAND head is\nattached catalog?}
    B -- Yes --> C["get_catalog(head)\n.list_namespaces(rest)"]
    C --> D["qualify results\nwith catalog alias"]
    D --> E["return [cat.ns, ...]"]
    B -- No --> F{current catalog\nset?}
    F -- No --> G["return []"]
    F -- Yes --> H["get_catalog(alias)\n.list_namespaces(pattern)"]
    H --> I["qualify results\nwith alias"]
    I --> E
Loading

Reviews (1): Last reviewed commit: "list_namespaces mirrors list_tables reso..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session.list_namespaces gives misleading error on <catalog>.<rest> pattern

1 participant