fix(react): deduplicate filters for multi-occurrence table nodes#2
Merged
Merged
Conversation
When the same table is referenced multiple times within a single SQL statement (e.g., self-join or two subqueries over the same table), the Rust core appends each occurrence's WHERE predicates to node.filters, producing N identical sets for N references. This caused the FILTERS section of a TableNode to display the same predicates twice (or more). Root cause: node.filters already arrives from the backend with duplicates baked in (visible in metadata.statementFilters). The frontend had no deduplication before rendering. Fixes: - Add deduplicateFilters() helper in graphBuilders.ts and graphBuilder.worker.ts that collapses node.filters to unique expressions (preserving first occurrence order) before the data reaches TableNodeData. - Add per-occurrence filter storage (occurrenceFilters[][]) in mergeNodesForNavigation so that cross-statement multi-occurrence cases can also display per-occurrence filters in the future. - TableNode subscribes to focusedOccurrenceIndex and uses occurrenceFilters[index] when available (cross-statement path), falling back to the now-deduplicated flat filters for the same-statement path. - TableNodeData gains occurrenceFilters?: FilterPredicate[][] for the per-occurrence display path. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ref: pondpilot/flowscope#44
When the same table is referenced multiple times within a single SQL statement (e.g., two subqueries over the same table inside one CTE), the Rust core appends each occurrence's WHERE predicates to
node.filters, producing N identical filter sets. The FILTERS section ofTableNodedisplayed all duplicates.Before fix:
dwd_eng_device_active_da(referenced twice) showed 8 filter predicatesAfter fix: Shows 4 unique predicates
Changes
graphBuilders.tsdeduplicateFilters()helper; apply tonode.filtersbeforeTableNodeDatagraphBuilder.worker.tsnodeOccurrences.tsmetadata.occurrenceFilters[][]for cross-statement casesTableNode.tsxfocusedOccurrenceIndex; useoccurrenceFilters[index]when availabletypes.tsTableNodeDatagainsoccurrenceFilters?: FilterPredicate[][]Test plan
OccurrenceCyclershows◀ 1/2 ▶Made with Cursor