Skip to content

feat(web-console): Add column name search to Schema filter#476

Merged
emrberk merged 2 commits intoquestdb:feat/schema-column-filterfrom
Itz-Agasta:filter
Oct 2, 2025
Merged

feat(web-console): Add column name search to Schema filter#476
emrberk merged 2 commits intoquestdb:feat/schema-column-filterfrom
Itz-Agasta:filter

Conversation

@Itz-Agasta
Copy link
Copy Markdown

Enhanced the table filter in the Schema panel to search both table names & column names. When a column matches the search query, the table automatically expands (in-memory only) to show the matching columns.

Changes

  • Filter logic: Updated table filtering to include column name matches using existing Redux allColumns data
  • Auto-expansion: Tables with matching columns now auto-expand their table row AND columns folder during search
  • State management: Search-driven expansions are purely in-memory and never persist to localStorage
  • Race condition fix: Added cleanup mechanism (isCancelled flag) to prevent stale async operations from causing incorrect expansion states during rapid input changes

Implementation Details

  1. Column matching: Uses allColumns from Redux store (already fetched via information_schema.columns()) - no additional network requests
  2. tablesWithColumnMatches Set: Computed via useMemo to track which tables need auto-expansion
  3. In-memory expansion: Sets node.isExpanded = true directly on tree nodes without calling setSectionExpanded() (localStorage)
  4. Async safety: Effect cleanup function prevents race conditions when user types/deletes rapidly

Behavior

  • Search for table name → table stays collapsed (existing behavior preserved)
  • Search for column name → table + columns auto-expand, matching columns visible
  • Clear search → all expansions revert to localStorage state (user's manual expansions preserved)
  • Rapid typing/backspace → no ghost expansions

Testing

Tested with sample tables containing columns like col_string, col_ts, sensor_id:

  • Column search correctly expands matching tables
  • Table name search maintains collapsed state
  • Rapid input (backspace spam) correctly handles state
  • Clearing search restores previous expansion states
2025-10-01.20-35-11.mp4

Closes #363

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Oct 1, 2025

CLA assistant check
All committers have signed the CLA.

@Itz-Agasta
Copy link
Copy Markdown
Author

Hi @emrberk Hope y are having a great day,
So, about memoization for column indexing i was talking about in the issue... so, my idea was to pre-compute a searchable index of table→columns mapping when tables/columns change, rather than accessing the Redux store for each table during every search keystroke.

For schemas with many tables, this could avoid repeated Redux store lookups. But while working on the issue, going through the repo, I found that ithis would be unnecessary tbh. As the allColumns data comes from selectors.query.getColumns which is already memoized by Redux's selector pattern. The columns are fetched once via information_schema.columns() and stored in the Redux store.

Also my current implementation uses useMemo for both the filtered tables list and the tablesWithColumnMatches Set, so the column matching computation only runs when tables, query, or allColumns change... exactly when it needs to.


useEffect(() => {
if (state.view === View.ready) {
let isCancelled = false;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

while testing i found a bug , When rapidly backspacing through search text, I encountered a race condition where tables would incorrectly stay expanded even after clearing the search.

Ig the useEffect triggers async fetchColumns() promises for each query change. When typing/deleting rapidly, multiple effect instances run concurrently, like

Type "uuid" → fetch starts → backspace fast → new fetch starts → old fetch completes → incorrectly sets isExpanded=true

The stale fetch promises would resolve AFTER newer queries, incorrectly modifying the tree state.

Thats why i add this effect cleanup with a cancellation flag.....so when the effect re-runs (on rapid input), the cleanup function marks the previous effect as cancelled. Any async operations from the old effect that complete later will skip their state updates, preventing ghost expansions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hey @Itz-Agasta, we will add this feature to the next release, I added a new commit to change the handling of columns and symbol details. You can take a look at it. This race condition should be removed now.
I am merging this to a branch to trigger the CI.

Thanks for your contribution!

@emrberk emrberk changed the base branch from main to feat/schema-column-filter October 2, 2025 23:33
@emrberk emrberk merged commit 92b3687 into questdb:feat/schema-column-filter Oct 2, 2025
1 check passed
@Itz-Agasta Itz-Agasta deleted the filter branch October 3, 2025 04:24
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.

table filter could search in columns too

3 participants