Repository navigation
Fix IN with a bare array column on the right argument - #109416
Conversation
The right side of `IN` treats an array as the set of its elements, so `x IN [1, 2, 3]` and `x IN array_returning_function()` are already rewritten to `has`. A bare array *column* on the right, however, was unconditionally wrapped in `tuple(column)` and treated as a single set element. For a stringifiable element type this silently produced an always-false result (e.g. `'system.tables' IN tables` returned nothing while `has(tables, 'system.tables')` matched); for other element types it threw `ILLEGAL_TYPE_OF_ARGUMENT`. Rewrite `x IN arr` to `has(arr, x)` when the column is `Array`-typed and exactly one dimension deeper than the left argument, so that the element type of `has` matches the left argument (e.g. a scalar and `Array(scalar)`, or `Array(T)` and `Array(Array(T))`). Columns of equal depth (e.g. `Array(T) IN Array(T)`) stay a one-element set, i.e. equality. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [287deae] Summary: ✅
AI ReviewSummaryThis PR fixes the analyzer path for Final VerdictStatus: ✅ Approve |
… the right The AI review asked to unwrap `LowCardinality` around `Array` in the new depth checks. Such a type cannot exist: `DataTypeLowCardinality` rejects `Array` as its dictionary type regardless of `allow_suspicious_low_cardinality_types` (that setting only relaxes the separate validation for small fixed-size types), so there is nothing to unwrap and no code change is needed. Add regression queries for the LowCardinality shapes that can occur - a `LowCardinality` scalar left argument (including a suspicious `LowCardinality(UInt8)`) and `Array(LowCardinality(String))` on the right - plus a guard that creating `LowCardinality(Array(...))` keeps throwing `ILLEGAL_TYPE_OF_ARGUMENT`. Co-Authored-By: Claude Fable 5 <[email protected]>
|
@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109416&sha=f5dc138ca3afaa5093238e2fa66daf4d84e8b8ab&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.
|
|
This is the known flaky The failing statement is query 2: select * from remote('127.{2..11}', view(select * from numbers(1e6)))
group by number order by number limit 20
settings distributed_group_by_no_merge=2, max_memory_usage='100Mi';It is expected to pass (with
That 512 MiB is a size reservation, not incremental growth, so it either trips the 100 MiB cap immediately or not at all depending on whether the size hint is populated. #109456 fixes it by disabling that reservation for this test. It is under review with @azat. CIDB, last 7d: same test + same |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 15/15 (100.00%) · Uncovered code |
…right-argument Fix `IN` with a bare array column on the right argument
On the right side of
IN, an array is treated as the set of its elements, sox IN [1, 2, 3]andx IN array_returning_function()are already rewritten tohas. A bare array column on the right, however, was unconditionally wrapped intuple(column)and treated as a single set element. As a result:'system.tables' IN tablessilently returned an empty result (the whole array was stringified into one set element and never matched), whilehas(tables, 'system.tables')matched — the two are expected to be equivalent.Array(UInt8)) it threwILLEGAL_TYPE_OF_ARGUMENT.This rewrites
x IN arrtohas(arr, x)when the right argument is anArray-typed column that is exactly one dimension deeper than the left argument, so that the element type ofhasmatches the left argument (e.g. a scalar andArray(scalar), orArray(T)andArray(Array(T))). Columns of equal depth (e.g.Array(T) IN Array(T)) remain a one-element set, i.e. equality. Every other case falls through to the pre-existing behavior unchanged.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
INwith a bare array column on the right argument silently returning a wrong (always-false) result or throwing an exception, so thatx IN arrbehaves likehas(arr, x).Version info
26.7.1.819(included in26.7and later)