Discover - count() over nullable boolean fields displays `null` value as false
- Dominant language
- Python
- Stars
- 44.8k
- Forks
- 4.9k
- Avg merge
- 22h 21m
- Merged PRs (30d)
- 586
Description
### Environment
SaaS (https://sentry.io/)
### Steps to Reproduce
I believe I found an issue in how Discover handles `count()` of nullable boolean fields, and specifically how it handles null values - they seem to still be treated as false, but then get translated to the wrong query when you try to look at the group with that result.
Do a count() over the `error.main-thread` field:

### Expected Result
The count() should give back a single line with result `null` for all the events which have a null value for the field (which are all of them in the case of my query, thats why there is only one line).
I should then be able to click "View Group" (the button on the side of the row) and reach a search for `!has:error.main_thread` because this is a boolean field.
### Actual Result
it looks like they are all with false value:

but in fact if you check you will see these all actually have "null" value. When you click the on "view group", you get an error saying boolean must be 1 or 0, since its querying for `error.main-thread is ""`:

This happens because the actual value it found on all the events is a null value, and boolean fields can't query for null, they have to do `!has:error.main-thread`.
The way I see it there are two issues here - it should display "null" as the value, and not false, and when viewing group the query should be different.
### Product Area
Discover
### Link
sentry
### DSN
_No response_
### Version
_No response_
Contributor guide
Research direction
Start by reproducing the Discover count() query on the nullable error.main-thread field and inspect the Discover aggregation and View Group query entry points. Done means nullable results display as null, and View Group generates !has:error.main-thread instead of a boolean equality query; add or update coverage for both behaviors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- analytics, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100