Skip to content

fix(query): match boolean features the way Druid stores them - #594

Draft
reitblatt wants to merge 2 commits into
mainfrom
reitblatt/fix-demo-boolean-query
Draft

reitblatt wants to merge 2 commits into
mainfrom
reitblatt/fix-demo-boolean-query

Conversation

@reitblatt

Copy link
Copy Markdown
Contributor

Summary

The demo query the docs and demo.sh suggest, ContainsHello == True, matched nothing. Boolean features couldn't be filtered at all.

Root cause: Druid's schema discovery (useSchemaDiscovery: true in druid/specs/execution_results.json) ingests JSON booleans as BIGINT 1/0. DruidQueryTransformer sent Feature == True as {"type": "selector", "value": true}, which never matches a long column. The query language's type checker rejects ContainsHello == 1 (bool vs int), so users had no working form. ContainsHello != True matched every event.

Fix: boolean comparisons (==, !=, in, not in, and not of these) now translate to an in filter on ["1", "true"] / ["0", "false"]. That matches the long columns schema discovery produces and also string-typed dimensions. Non-boolean comparisons are unchanged.

The query is now correct as written, so the docs (docs/concepts.md, docs/development/README.md, docs/rules/examples.md) and demo.sh need no changes.

Testing

  • New parametrized test test_boolean_comparisons_match_how_druid_stores_booleans covers ==, !=, reversed operands, not, in, and not in.
  • ./run-tests.sh (full suite) passes; pre-commit passes.
  • Local stack with --profile test_data, via POST /events/timeseries on the UI API:
Query Before After
ContainsHello == True 0 27
ContainsHello == False 0 66
ContainsHello != True all events 66
ContainsHello in [True] — 27
EventType == "create_post" (all events) — 93

The /events/scan results for ContainsHello == True are the posts that contain "hello".

🤖 Generated with Claude Code

claude-agent and others added 2 commits October 30, 2026 20:53
Druid's schema discovery ingests boolean features as the longs 1/0, but
the query translator sent `Feature == True` as a selector on the literal
`true`, which never matches. The type checker rejects `Feature == 1` for
bool features, so boolean features couldn't be queried at all, including
the `ContainsHello == True` query the demo suggests. `!= True` matched
every event.

Translate boolean comparisons (==, !=, in, not in) to an `in` filter on
both the numeric and string forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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.

1 participant