Skip to content

feat: introduce FilterGroup model for recursive table filters#9119

Merged
kirangadhave merged 12 commits intomainfrom
kg/table-filter-model
Apr 13, 2026
Merged

feat: introduce FilterGroup model for recursive table filters#9119
kirangadhave merged 12 commits intomainfrom
kg/table-filter-model

Conversation

@kirangadhave
Copy link
Copy Markdown
Member

@kirangadhave kirangadhave commented Apr 9, 2026

Introduces a recursive filter model (FilterGroup, FilterCondition) that can represent arbitrarily complex filter trees with AND/OR composition, negation, and nested groups. This replaces the flat list[Condition] model.

Note

The UI behavior will remain unchanged, we will have a list of filters which we AND together. The richer model is to support future work with AI/LLM generated filters, maybe a query language or an poweruser UI, and programatic filtering.

Changes

  • rename Condition to FilterCondition with type discriminator
  • added FilterGroup with recursive children, operator (and/or), and negative
  • add the between and is_empty operator to simplify than model it with comparision operators
    • will help with rendering different UIs.
  • added dtype <-> operator validation on the backend
  • refactored the filter handler to use match...case instead of chaining if..elif...else
  • updated fe to use and send FilterGroup
  • DataFramePlugin unchanged (future work)

Tests

  • all existing backend filter tests updated to use new types, and passing
  • added tests for new operators, groups, nesting, negation
  • FE tests for filterToFilterCondition, filterToFilterGroup, schema validation
  • make fe-check passes
  • tested manually in browser

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 9, 2026

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

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Apr 13, 2026 6:12pm

Request Review

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Bundle Report

Changes will increase total bundle size by 699 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
marimo-esm 24.84MB 699 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: marimo-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/index-*.js 237 bytes 602.39kB 0.04%
assets/JsonOutput-*.js 462 bytes 336.75kB 0.14%

Files in assets/index-*.js:

  • ./src/plugins/impl/data-frames/DataFramePlugin.tsx → Total Size: 10.47kB

  • ./src/plugins/impl/DataTablePlugin.tsx → Total Size: 28.17kB

  • ./src/plugins/impl/data-frames/utils/operators.ts → Total Size: 4.03kB

  • ./src/plugins/impl/data-frames/schema.ts → Total Size: 5.87kB

Files in assets/JsonOutput-*.js:

  • ./src/components/data-table/filters.ts → Total Size: 3.64kB

@kirangadhave kirangadhave changed the title feat: add a new filter model feat: introduce FilterGroup model for recursive table filters Apr 10, 2026
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

This PR introduces a recursive filter model (FilterGroup / FilterCondition) to represent complex filter trees (AND/OR composition, negation, nesting), adds between and is_empty operators, and updates backend + frontend plumbing and tests to use the new structure.

Changes:

  • Replace the flat list[Condition] filter representation with FilterGroup / FilterCondition across backend and frontend.
  • Add new filter operators (between, is_empty) plus backend dtype↔operator validation for table filtering.
  • Update/extend backend and frontend test suites to cover the new filter model and operators.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
marimo/_plugins/ui/_impl/dataframes/transforms/types.py Introduces RangeValue, FilterCondition, FilterGroup, dtype↔operator validation, and updates FilterRowsTransform.where to use FilterGroup.
marimo/_plugins/ui/_impl/dataframes/transforms/handlers.py Implements recursive evaluation of FilterGroup (AND/OR + negation) and supports new operators in execution logic.
marimo/_plugins/ui/_impl/table.py Updates table search args to accept FilterGroup and adds recursive validation/filtering of conditions by column existence + dtype/operator compatibility.
marimo/_plugins/ui/_impl/dataframes/transforms/print_code.py Updates codegen inputs to FilterCondition/FilterGroup (but currently lacks full support for nested groups/negation/new operators).
frontend/src/components/data-table/filters.ts Converts TanStack column filters into FilterGroup payloads for RPC.
frontend/src/plugins/impl/DataTablePlugin.tsx Sends FilterGroup filters to the backend search API and updates zod request schema accordingly.
frontend/src/plugins/impl/data-frames/schema.ts Adds FilterGroupSchema / FilterConditionSchema and transforms filter-rows UI inputs into a FilterGroup.
frontend/src/plugins/impl/data-frames/utils/operators.ts Adds frontend operator schemas for between and is_empty.
frontend/src/plugins/impl/data-frames/DataFramePlugin.tsx Updates plugin request schema to accept FilterGroup.
tests/_plugins/ui/_impl/test_table.py Migrates table tests to pass FilterGroup rather than a list of conditions.
tests/_plugins/ui/_impl/dataframes/test_transforms.py Updates transform parsing tests to use the group-based filter structure.
tests/_plugins/ui/_impl/dataframes/test_print_code.py Updates hypothesis strategies/usages to build filter transforms with FilterGroup.
tests/_plugins/ui/_impl/dataframes/test_handlers.py Migrates handler tests and adds extensive coverage for between, is_empty, nesting, OR, and negation.
tests/_plugins/ui/_impl/dataframes/test_filter_model.py New unit tests for filter model normalization/hashability and dtype/operator validation.
frontend/src/components/data-table/__tests__/filters.test.ts New tests for frontend filter→condition/group conversion and schema validation.

Comment thread marimo/_plugins/ui/_impl/dataframes/transforms/print_code.py
Comment thread marimo/_plugins/ui/_impl/dataframes/transforms/print_code.py
Comment thread marimo/_plugins/ui/_impl/dataframes/transforms/print_code.py
Comment thread marimo/_plugins/ui/_impl/dataframes/transforms/print_code.py
Comment thread marimo/_plugins/ui/_impl/dataframes/transforms/print_code.py
Comment thread marimo/_plugins/ui/_impl/dataframes/transforms/print_code.py
Comment thread frontend/src/plugins/impl/DataTablePlugin.tsx
Comment thread frontend/src/plugins/impl/DataTablePlugin.tsx
mscolnick
mscolnick previously approved these changes Apr 13, 2026
@kirangadhave kirangadhave merged commit cd40306 into main Apr 13, 2026
43 checks passed
@kirangadhave kirangadhave deleted the kg/table-filter-model branch April 13, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants