Allow using insertRangeFrom when lowCardinality numeric#80376
Allow using insertRangeFrom when lowCardinality numeric#80376Ergus wants to merge 3 commits intoClickHouse:masterfrom
Conversation
|
Please edit the description with the template: https://raw.githubusercontent.com/ClickHouse/ClickHouse/refs/heads/master/.github/PULL_REQUEST_TEMPLATE.md Otherwise, tests cannot start. |
da0bf0f to
757aaf4
Compare
ecb6017 to
e944979
Compare
4f1f7f5 to
658d3a0
Compare
* src/Functions/GatherUtils/Algorithms.h (writeSlice) : Extend the condition to allow use insertRangeFrom when lowCardinality numeric
types. This is a preliminar fix that works, but maybe this extension is not general enough.
* tests/queries/0_stateless/02447_join_numeric_low_cardinality.{sql,reference}: New tests with previously failing queries.
Fixes: ClickHouse#57243
| { | ||
| if (slice.elements->structureEquals(sink.elements)) | ||
| const bool can_insert = | ||
| // Check same type |
| const bool can_insert = | ||
| // Check same type | ||
| slice.elements->structureEquals(sink.elements) | ||
| // insertRangeFrom casts numeric types if they are different, so it can insert them. |
There was a problem hiding this comment.
Reading l. 78, one wonders why l. 79 checks for low cardinality. Please either update the comment or remove sink.elements.lowCardinality() && slice.elements->lowCardinality() &&.
There was a problem hiding this comment.
It's not okay to have this check inside a function that is called in a loop.
tests/queries/0_stateless/02447_join_numeric_low_cardinality.sql
Outdated
Show resolved
Hide resolved
|
Let's continue with this PR (there was still an exception |
I suppose that this comes from a different code part (cause my error message is different now): The only candidate so far is: ClickHouse/src/Functions/GatherUtils/Algorithms.h Lines 152 to 161 in 66b38dc The code is very similar form outside, but in the inner part the function I modified relies on: ClickHouse/src/Columns/ColumnLowCardinality.cpp Lines 810 to 826 in 66b38dc But this function relies on: ClickHouse/src/Columns/ColumnLowCardinality.cpp Lines 786 to 793 in 66b38dc That as you can see looks not as "elaborated". So, in order to relax the outer condition as I did in the other function I need to add similar boundaries checks and casting code if needed. The issue here is that this looks like a single position insertion, so adding all the same checks could produce potential overhead. WDYT? |
|
Merging |
|
@Ergus Question number 0 is: Is there a functional issue at SQL level caused by the other function inline ALWAYS_INLINE void writeSlice(const GenericValueSlice & slice, GenericArraySink & sink)? There are two ways to find out:
I would say once it is clear if there is a problem at all, we can check how to fix it. |
|
Dear @tuanpach, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
I tried this, but couldn't manage to force it go throw the failing function. We should try something else. |
| @@ -72,13 +72,21 @@ inline ALWAYS_INLINE void writeSlice(const StringSource::Slice & slice, FixedStr | |||
| /// Assuming same types of underlying columns for slice and sink if (ArraySlice, ArraySink) is (GenericArraySlice, GenericArraySink). | |||
There was a problem hiding this comment.
Also the assumption is stated in the comment.
|
@Ergus, find another approach. |
Resolves #57243
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix an exception with ARRAY JOINs:
Function writeSlice expects same column types for GenericArraySlice and GenericArraySinkwhich happens when lowCardinality numeric types are used (issue #57243).