Skip to content

fix: Skip empty nested filter groups in SQLite and Postgres filter translators - #7052

Open
RaphaelFakhri wants to merge 1 commit into
feast-dev:masterfrom
RaphaelFakhri:fix/sql-filter-empty-compound
Open

RaphaelFakhri wants to merge 1 commit into
feast-dev:masterfrom
RaphaelFakhri:fix/sql-filter-empty-compound

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

What this PR does / why we need it:

SqliteFilterTranslator.translate_compound and PostgresFilterTranslator.translate_compound join every sub-clause, including the empty clause returned for an empty nested CompoundFilter. A filter such as and[eq(title, "Title 1"), or[]] becomes (... AND ), and SQLite fails with near ")": syntax error. Postgres gets the same trailing AND ). A group made only of empty groups becomes ( AND ) or ().

This change skips empty sub-clauses and returns an empty clause when none remain, which matches MilvusFilterTranslator. The callers already treat an empty clause as "no filter".

Tests in tests/unit/test_filter_models.py check the generated clause for both translators, run the SQLite clause against an in-memory database, and cover groups made only of empty groups.

Which issue(s) this PR fixes:

Fixes #7051

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

Misc

pytest tests/unit/test_filter_models.py: 4 of the new tests fail without the fix and all 27 pass with it.

@RaphaelFakhri
RaphaelFakhri requested a review from a team as a code owner October 20, 2026 10:21
@patelchaitany

Copy link
Copy Markdown
Contributor

LGTM

@patelchaitany

Copy link
Copy Markdown
Contributor

@RaphaelFakhri could you please rebase this onto the latest master? The branch is currently behind master.

@RaphaelFakhri

Copy link
Copy Markdown
Author

Rebased onto the latest master. sdk/python/tests/unit/test_filter_models.py passes on the rebased branch (27 tests).

@RaphaelFakhri
RaphaelFakhri force-pushed the fix/sql-filter-empty-compound branch from 8005ce5 to 8ee447d Compare October 28, 2026 14:35
@codecov-commenter

codecov-commenter commented Oct 28, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.07%. Comparing base (1e5e90c) to head (8ee447d).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7052      +/-   ##
==========================================
+ Coverage   50.97%   51.07%   +0.09%     
==========================================
  Files         455      455              
  Lines       56994    57002       +8     
  Branches     8321     8325       +4     
==========================================
+ Hits        29055    29111      +56     
+ Misses      25954    25899      -55     
- Partials     1985     1992       +7     
Flag Coverage Δ
go-feature-server 30.58% <ø> (+0.20%) ⬆️
python-unit 52.53% <100.00%> (+0.08%) ⬆️
Files with missing lines Coverage Δ
...ra/online_stores/postgres_online_store/postgres.py 38.25% <100.00%> (+5.07%) ⬆️
sdk/python/feast/infra/online_stores/sqlite.py 65.70% <100.00%> (+4.93%) ⬆️

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e5e90c...8ee447d. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty nested filter group produces invalid SQL in the SQLite and Postgres online stores

4 participants