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
If any of the values (properties) of a statement were null, that would make the entire statement null.
For example, For example, math like sumIf(properties.toppings, event='pizza') + sumIf(properties.cheese, event='pasta') will return null if any of the two sides is null , which might happen if there are just no matching events, or the property is null
concat('code: ', properties.code) returns null if there's no code property, though I'd expect either 'code: ' or 'code: null'
Spent time debugging customer issues around this.
Potential solutions
Property returns default value such as “” or 0 or false depending on type.
Problem with this is the statement properties.bla is null needs to be handled too
Would require rewriting is set and is not set logic to be ≠ ‘’ or empty().
Nullable checkbox in data management
is set and is not set as native constructs.
JS-like 'bla' (NOT) IN properties for "is (not) set"
might be too complex,
doesn’t solve is null for unset property
wrap sumIf in nullIf(x, 0)
Not elegant
Use sumOrDefaultIf
non-ANSI compliant string operator, e.g. f'{NULL}-haha-{properties.bla}',
Some other ones
Chosen solution
Don’t return 0 on numbers, ClickHouse will skip these in aggregations
Strapline
Explain the idea in a sentence or two
Our adventures in handling NULL in HogQL, the problem we ran into, potential solutions we came up with, and ultimate solution we chose.
Why should we do it?
How it will it be useful or interesting for readers/viewers
Handling null is something a lot of projects need to do, our experience could help them.
Change of pace technical blog post, which we haven’t done in a while.
Headlines options
think of two of three possible headlines we could use
Outline
Bullet point outline of structure / questions / topics to be covered
sumIf(properties.toppings, event='pizza') + sumIf(properties.cheese, event='pasta')
will return null if any of the two sides is null , which might happen if there are just no matching events, or the property is nullconcat('code: ', properties.code)
returnsnull
if there's nocode
property, though I'd expect either'code: '
or'code: null'
“”
or0
orfalse
depending on type.properties.bla is null
needs to be handled toois set
andis not set
logic to be≠ ‘’
orempty()
.is set
andis not set
as native constructs.'bla' (NOT) IN properties
for "is (not) set"f'{NULL}-haha-{properties.bla}'
,concat(null, 'a', 3, toString(4), toString(NULL), properties.$screen_width)
turns intoconcat('', 'a', toString(3), toString(4), '')
ifNull
for users instead of having them do itThe text was updated successfully, but these errors were encountered: