You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Empty nested filter group produces invalid SQL in the SQLite and Postgres online stores #7051
A CompoundFilter that contains an empty nested group, for example an or group with no filters, applies the remaining filters. The Milvus online store already skips empty groups this way.
Current behavior
SqliteFilterTranslator and PostgresFilterTranslator join every sub-clause, including the empty string returned for an empty group. The generated WHERE fragment ends in AND ), and the query fails:
fromfeast.filter_modelsimportComparisonFilter, CompoundFilterfromfeast.infra.online_stores.sqliteimportSqliteFilterTranslatorf=CompoundFilter(
type="and",
filters=[
ComparisonFilter(type="eq", key="title", value="Title 1"),
CompoundFilter(type="or", filters=[]),
],
)
print(SqliteFilterTranslator("t", alias="fv").translate(f)[0])
# (fv.entity_key IN (SELECT ... WHERE feature_name = ? AND value_text = ?) AND )
Running that clause in SQLite raises sqlite3.OperationalError: near ")": syntax error. The Postgres translator generates the same trailing AND ). A group that contains only empty groups becomes ( AND ) in SQLite and () in Postgres.
These filters come from retrieve_online_documents_v2(filters=...) and from the OpenAI-compatible openai_search endpoint, where clients build filter JSON programmatically and can send an empty group.
Steps to reproduce
Run the snippet above, then execute the clause against a table with entity_key, feature_name, value_text and value_num columns.
Specifications
Version: master as of 2026-10-20
Platform: Linux
Subsystem: SQLite and Postgres online stores, metadata filters
Possible solution
Skip empty sub-clauses in translate_compound, and return an empty clause when no sub-clause remains, as MilvusFilterTranslator.translate_compound does.
Activity