Skip to content

add a toggle to filter empty schemas and db#9712

Open
Light2Dark wants to merge 2 commits into
mainfrom
sham/hide-empty-schemas-db
Open

add a toggle to filter empty schemas and db#9712
Light2Dark wants to merge 2 commits into
mainfrom
sham/hide-empty-schemas-db

Conversation

@Light2Dark
Copy link
Copy Markdown
Collaborator

@Light2Dark Light2Dark commented May 28, 2026

📝 Summary

Closes #6807.

This toggles empty db and schemas. By default all are shown, this config is stored in local storage.

Screen.Recording.2026-05-28.at.5.35.47.PM.mov

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jun 2, 2026 3:19am

Request Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Architecture diagram
sequenceDiagram
    participant UI as DataSources Panel
    participant Store as Jotai Store (localStorage)
    participant Backend as Backend API
    participant Cache as React useMemo

    Note over UI,Cache: Initial Load
    
    UI->>Store: NEW: read hideEmptyDatasourcesAtom (from localStorage key "marimo:datasources:hideEmpty")
    Store-->>UI: false (default)

    UI->>Backend: fetch databases & schemas
    Backend-->>UI: rawConnections with all databases & schemas

    Note over UI,Cache: Toggle Filter
    
    UI->>UI: user clicks Eye/EyeOff button
    UI->>Store: NEW: setHideEmpty(!hideEmpty)
    Store-->>UI: confirm toggle

    Note over UI,Cache: Re-render with filter applied
    
    UI->>Cache: NEW: useMemo recomputes dataConnections
    Cache->>Cache: NEW: filterEmptyDatabases() applied per connection
    
    alt hideEmpty === false
        Cache-->>UI: return rawConnections unchanged
    else hideEmpty === true
        Note over Cache: For each connection.databases:
        Cache->>Cache: filter schemas with 0 tables
        Cache->>Cache: filter databases where all schemas are empty
        alt database.schemas.length === 0
            Note over Cache: preserve - lazy state
        end
        Cache-->>UI: filteredConnections
    end

    alt filteredConnections changed
        UI->>UI: re-render tree with filtered data
    else no change (immuatable check)
        UI->>UI: return previous reference
    end

    Note over UI,Backend: Unchanged Backend Behavior
    
    Note over Backend: CHANGED: get_schemas() no longer filters empty schemas server-side
    Note over Backend: now returns ALL schemas regardless of table count
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread frontend/src/components/datasources/datasources.tsx Outdated
@Light2Dark Light2Dark added the enhancement New feature or request label May 28, 2026
## 📝 Summary

<!--
If this PR closes any issues, list them here by number (e.g., Closes
#123).

Detail the specific changes made in this pull request. Explain the
problem addressed and how it was resolved. If applicable, provide before
and after comparisons, screenshots, or any relevant details to help
reviewers understand the changes easily.
-->
These fields are to indicate whether a table's schemas has been loaded
vs truly empty.
That allows the frontend to distinguish whether to hide empty vs lazy
(which we shouldn't hide).

This change makes sense for future work, since it's important to
distinguish between truly empty vs not yet loaded. Another option was
considered: `list[DataTable] | None`, where `None` indicates not yet
loaded. However, this is semantically not clear even if a simpler code
change.

This is in support of this PR
#9708

## 📋 Pre-Review Checklist
<!-- These checks need to be completed before a PR is reviewed -->

- [x] For large changes, or changes that affect the public API: this
change was discussed or approved through an issue, on
[Discord](https://marimo.io/discord?ref=pr), or the community
[discussions](https://github.com/marimo-team/marimo/discussions) (Please
provide a link if applicable).
- [x] Any AI generated code has been reviewed line-by-line by the human
PR author, who stands by it.
- [ ] Video or media evidence is provided for any visual changes
(optional). <!-- PR is more likely to be merged if evidence is provided
for changes made -->

## ✅ Merge Checklist

- [x] I have read the [contributor
guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md).
- [ ] Documentation has been updated where applicable, including
docstrings for API changes.
- [x] Tests have been added for the changes made.

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added the bash-focus Area to focus on during release bug bash label Jun 2, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Bundle Report

Changes will increase total bundle size by 27.09kB (0.11%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
marimo-esm 25.29MB 27.09kB (0.11%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: marimo-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/cells-*.js 160 bytes 710.09kB 0.02%
assets/JsonOutput-*.js 3.38kB 557.8kB 0.61%
assets/index-*.css 43 bytes 367.66kB 0.01%
assets/dist-*.js 155 bytes 259 bytes 149.04% ⚠️
assets/dist-*.js 33 bytes 137 bytes 31.73% ⚠️
assets/dist-*.js -95 bytes 164 bytes -36.68%
assets/dist-*.js 87 bytes 256 bytes 51.48% ⚠️
assets/dist-*.js 127 bytes 403 bytes 46.01% ⚠️
assets/dist-*.js 139 bytes 276 bytes 101.46% ⚠️
assets/dist-*.js -65 bytes 104 bytes -38.46%
assets/dist-*.js 46 bytes 183 bytes 33.58% ⚠️
assets/dist-*.js -62 bytes 102 bytes -37.8%
assets/dist-*.js -166 bytes 169 bytes -49.55%
assets/dist-*.js 75 bytes 177 bytes 73.53% ⚠️
assets/dist-*.js -72 bytes 104 bytes -40.91%
assets/dist-*.js -23 bytes 137 bytes -14.37%
assets/dist-*.js -227 bytes 176 bytes -56.33%
assets/dist-*.js 204 bytes 387 bytes 111.48% ⚠️
assets/dist-*.js -218 bytes 169 bytes -56.33%
assets/dist-*.js -17 bytes 160 bytes -9.6%
assets/dist-*.js 79 bytes 335 bytes 30.86% ⚠️
assets/edit-*.js 402 bytes 325.54kB 0.12%
assets/ai-*.js 19.71kB 276.99kB 7.66% ⚠️
assets/reveal-*.js 42 bytes 249.59kB 0.02%
assets/layout-*.js 65 bytes 198.76kB 0.03%
assets/cell-*.js 144 bytes 184.28kB 0.08%
assets/dependency-*.js 37 bytes 156.75kB 0.02%
assets/panels-*.js 5 bytes 47.9kB 0.01%
assets/chat-*.js 996 bytes 33.62kB 3.05%
assets/utils-*.js 234 bytes 6.21kB 3.91%
assets/MarimoErrorOutput-*.js -5 bytes 26.63kB -0.02%
assets/session-*.js 1.28kB 26.32kB 5.1% ⚠️
assets/useNotebookActions-*.js -7.15kB 22.8kB -23.86%
assets/pair-*.js (New) 7.74kB 7.74kB 100.0% 🚀
assets/radio-*.js 5 bytes 5.48kB 0.09%
assets/useDependencyPanelTab-*.js -158 bytes 4.22kB -3.61%
assets/mermaid-*.core-aYU6qXxk.js (New) 2.38kB 2.38kB 100.0% 🚀
assets/arrow-*.js (New) 165 bytes 165 bytes 100.0% 🚀
assets/__vite-*.js -5 bytes 93 bytes -5.1%
assets/__vite-*.js 5 bytes 98 bytes 5.38% ⚠️
assets/mermaid-*.core-CMygPhv_.js (Deleted) -2.38kB 0 bytes -100.0% 🗑️

Files in assets/cells-*.js:

  • ./src/core/datasets/data-source-connections.ts → Total Size: 6.32kB

Files in assets/session-*.js:

  • ./src/components/datasources/datasources.tsx → Total Size: 37.94kB

@Light2Dark Light2Dark marked this pull request as ready for review June 2, 2026 04:23
Copilot AI review requested due to automatic review settings June 2, 2026 04:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a per-user toggle in the Datasources panel to hide databases and schemas that are confirmed empty, while still showing those whose contents are merely deferred. To support this safely, a new tables_resolved/schemas_resolved flag is propagated through every SQL engine and the public API schema so the frontend can distinguish "known empty" from "not yet fetched" (closes #6807).

Changes:

  • Add schemas_resolved to Database and tables_resolved to Schema in the data models, OpenAPI YAML, and generated TS types; defaults to True for backward compatibility.
  • Update SQL engines (sqlalchemy, ibis, clickhouse, redshift, pyiceberg, adbc) and connection update helpers to set these flags, and stop unconditionally hiding empty schemas in the ibis engine.
  • Add a hideEmptyDatasourcesAtom (persisted via atomWithStorage) and a filterEmptyDatabases helper plus an Eye/EyeOff toggle button in the datasources panel UI; ship vitest coverage for the filter and Python tests for engine behaviors.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
marimo/_data/models.py Adds tables_resolved / schemas_resolved fields with docstrings.
marimo/_sql/connection_utils.py Marks resolved=true after schemas/tables are populated.
marimo/_sql/engines/sqlalchemy.py Marks meta-schema tables as unresolved; populates schemas_resolved.
marimo/_sql/engines/ibis.py Stops dropping empty schemas; threads schemas_resolved/tables_resolved.
marimo/_sql/engines/clickhouse.py New _get_tables_in_schema_with_resolution returns authoritative flag.
marimo/_sql/engines/redshift.py Sets schemas_resolved and tables_resolved based on inputs.
marimo/_sql/engines/pyiceberg.py Records tables_resolved from auto-discover decision.
marimo/_sql/engines/adbc.py Sets resolution flags from include_* booleans.
packages/openapi/api.yaml, packages/openapi/src/api.ts Adds new optional boolean fields with default: true.
frontend/src/core/datasets/data-source-connections.ts Marks resolved=true after schema/table updates.
frontend/src/components/datasources/datasources.tsx Adds storage atom, filter helper, and toggle button.
frontend/src/components/datasources/tests/filter-empty.test.ts Vitest coverage for filterEmptyDatabases edge cases.
tests/_sql/test_sqlalchemy.py, test_ibis.py, test_clickhouse.py Asserts new resolved flags across engines and failure paths.

@Light2Dark Light2Dark requested a review from mscolnick June 2, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bash-focus Area to focus on during release bug bash enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Datasource panel with IbisEngine shows empty database and schema

2 participants