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.

…anslators

Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
@RaphaelFakhri
RaphaelFakhri requested a review from a team as a code owner October 20, 2026 10:21

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

Labels

None yet

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

1 participant