feat: support multiple filters on the same dimension field#22
Open
jpetey75 wants to merge 1 commit into
Open
Conversation
Remove the self-imposed `NotImplementedError` guard in `CompositeFilter.to_dict()` that rejected more than one filter rule targeting the same field. The Lightdash API accepts multiple rules per field (the same shape already used for single dimension filters), so a range like `(dim >= start) & (dim <= end)` now serializes both rules under `filters.dimensions`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
Verified that removing the duplicate-field guard is safe — this was a self-imposed SDK limitation (note the original "not implemented yet" message), not an API constraint. Live test against the API: ran a query with two filter rules on the same field —
Three months, nothing outside the range → both same-field rules were applied. Two independent lines of evidence:
Also confirmed there's no per-rule |
This was referenced Jun 16, 2026
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.
Closes #20
Problem
Applying more than one filter to the same field — e.g. constraining a date dimension to a range — raised:
Change
Removes the self-imposed
processed_field_idsguard inCompositeFilter.to_dict(). That check was a placeholder ("not implemented yet"), not an API constraint — the Lightdash API accepts multiple rules per field, using the same{target, operator, values}shape already used for single dimension filters. We simply emit one entry per rule underfilters.dimensions.A date range now serializes as:
{"dimensions": {"and": [ {"target": {"fieldId": "orders_datetime_day"}, "operator": "greaterThanOrEqual", "values": ["2026-01-01"]}, {"target": {"fieldId": "orders_datetime_day"}, "operator": "lessThanOrEqual", "values": ["2026-01-31"]} ]}}Tests
Adds
TestSameFieldFilterscovering same-field AND/OR combinations, 3+ rules on one field, and the.filter().filter()chain path. All 54 filter/query-builder unit tests pass.Scope
This is the first of three related issues (#19 row limit, #21 table-calculation filters) — split out on its own because it's a low-risk, self-contained removal of a client-side guard. #19 and #21 will follow in separate PRs.
🤖 Generated with Claude Code