Skip to content

Backend/fix : toClickHouseVal support for Boolean Values#1332

Open
dhruv-1010 wants to merge 1 commit into
mainfrom
fix/clickhousev2-bool-filter-in
Open

Backend/fix : toClickHouseVal support for Boolean Values#1332
dhruv-1010 wants to merge 1 commit into
mainfrom
fix/clickhousev2-bool-filter-in

Conversation

@dhruv-1010

@dhruv-1010 dhruv-1010 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor
    • Improved database query handling for filter value transformations and equality/inequality expressions.
    • Enhanced support for flexible filter value representations in database queries.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@dhruv-1010, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 44 minutes and 44 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3616b3ca-a6ac-4578-bed7-7a2204bc0ce4

📥 Commits

Reviewing files that changed from the base of the PR and between 8ddbfbc and dbb0494.

📒 Files selected for processing (2)
  • lib/mobility-core/src/Kernel/Storage/ClickhouseV2/ClickhouseValue.hs
  • lib/mobility-core/src/Kernel/Storage/ClickhouseV2/Internal/ClickhouseQuery.hs

Walkthrough

This PR extends the ClickHouse storage abstraction to support multiple filter value representations for a single logical value. A new toClickhouseFilterValues method on the ClickhouseValue typeclass enables query transformation: when a filter value expands to multiple alternatives, equality and inequality comparisons automatically become IN and NOT IN operations instead of scalar comparisons.

Changes

ClickHouse filter values abstraction and query rendering

Layer / File(s) Summary
ClickhouseValue typeclass contract
lib/mobility-core/src/Kernel/Storage/ClickhouseV2/ClickhouseValue.hs
Typeclass adds toClickhouseFilterValues with default implementation returning single-element NonEmpty list. Bool instance explicitly provides numeric (Number 1/Number 0) and string ("true"/"false") representations.
Query rendering with filter values
lib/mobility-core/src/Kernel/Storage/ClickhouseV2/Internal/ClickhouseQuery.hs
Query generation for Term value now flattens In values through toClickhouseFilterValues and delegates Eq/NotEq to helpers that choose between scalar comparisons and IN/NOT IN based on filter value count.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🐰 A typeclass takes the stage, default values bring grace,
Bool hops in with numbers and strings in place,
Now queries transform with a logical dance,
Equality becomes IN when there's a chance! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title correctly identifies the main change: adding support for Boolean values in the ClickHouse filter value conversion, which is the primary purpose of both modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/clickhousev2-bool-filter-in

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/mobility-core/src/Kernel/Storage/ClickhouseV2/ClickhouseValue.hs`:
- Around line 51-56: The Maybe instance currently collapses Just values to a
single literal; update the ClickhouseValue (Maybe a) implementation so
toClickhouseFilterValues propagates the underlying expansion: implement
toClickhouseFilterValues (Just x) by calling toClickhouseFilterValues x to get
NonEmpty (Value a) and then map each inner Value to the corresponding Value for
Maybe (i.e., wrap the same String/Number variants for the Just cases), and
implement toClickhouseFilterValues Nothing = Null :| []; also ensure
toClickhouseValue/fromClickhouseValue for ClickhouseValue (Maybe a) remain
consistent with that wrapping (use toClickhouseValue for Just and produce Null
for Nothing) so nullable columns get the expanded filter literals.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8dd38de1-c116-4654-8072-2c904fdac391

📥 Commits

Reviewing files that changed from the base of the PR and between 01ed27b and 8ddbfbc.

📒 Files selected for processing (2)
  • lib/mobility-core/src/Kernel/Storage/ClickhouseV2/ClickhouseValue.hs
  • lib/mobility-core/src/Kernel/Storage/ClickhouseV2/Internal/ClickhouseQuery.hs

@dhruv-1010 dhruv-1010 force-pushed the fix/clickhousev2-bool-filter-in branch from 8ddbfbc to dbb0494 Compare June 5, 2026 11:00
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.

2 participants