fix(ClickHouse): fixes for version 21.7 and 21.8#8831
Conversation
| posthog_max_version = "1.33.9" | ||
|
|
||
| service_version_requirements = [ | ||
| ServiceVersionRequirement(service="clickhouse", supported_version=">=21.6.0,<21.7.0"), |
There was a problem hiding this comment.
cc @yakkomajuri I don't remember why this was added in the first place but looks safe to be removed.
There was a problem hiding this comment.
I don't think this is still relevant, though I might be missing something due to tests.
This will make it to the next release and be required to be run before then anyways :)
| /* Making sure bin_count bins are returned */ | ||
| /* Those not present in the results query due to lack of data simply get person_count 0 */ | ||
| SELECT histogram_from_seconds + number * bin_width_seconds AS bin_from_seconds FROM system.numbers LIMIT {bin_count_identifier} + 1 | ||
| SELECT histogram_from_seconds + number * bin_width_seconds AS bin_from_seconds FROM system.numbers LIMIT ifNull({bin_count_identifier}, 0) + 1 |
There was a problem hiding this comment.
There should be a @snapshot_clickhouse_queries code path covering this - really surprised this doesn't have coverage.
Do we want to add the test here or e.g. tag @neilkakkar to take a look?
There was a problem hiding this comment.
Tests added. Let me know if it's 👍
hazzadous
left a comment
There was a problem hiding this comment.
Looks good
Can you see an easy way to identify if this could be an issue elsewhere?
| bin_count_expression = f""" | ||
| count() AS sample_count, | ||
| least(60, greatest(3, ceil(cbrt(sample_count)))) AS {bin_count_identifier}, | ||
| ifNull(least(60, greatest(3, ceil(cbrt(sample_count)))), 0) AS {bin_count_identifier}, |
There was a problem hiding this comment.
Do we need both of the ifNull additions?
Is there a reason to not put this directly on the count()?
For other CH versions you mean?
|
I mean, this instance was picked up by a test, but could there be other queries that would fail due to the same underlying issue. |
|
LGTM. I agree with harry re verifying that other queries weren't relying on this coalescing logic + we should make sure the path is covered with tests (+ query snapshot tests). Once some consensus is reached there, happy to have this be merged. :) |
59b6c73 to
3f8d2ee
Compare
As discussed on Slack:
|
Changes
Code change to support the ClickHouse upgrade to version 21.7 and 21.8.
The code and the underlying generated query are quite complex (at least for me) so I've opted for a quick solution. The underlying issue is that in a subquery we select an empty
group bywithcountthat returns null.I've also added a snapshot for those tests.
How did you test this code?
Before:
After: