mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Merge pull request #19617 from ClickHouse/fix-lc-neighbour
Fix function neighbor for LowCardinality argument.
This commit is contained in:
commit
fa48545b87
@ -50,6 +50,10 @@ public:
|
||||
|
||||
bool useDefaultImplementationForConstants() const override { return false; }
|
||||
|
||||
/// We do not use default implementation for LowCardinality because this is not a pure function.
|
||||
/// If used, optimization for LC may execute function only for dictionary, which gives wrong result.
|
||||
bool useDefaultImplementationForLowCardinalityColumns() const override { return false; }
|
||||
|
||||
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
|
||||
{
|
||||
size_t number_of_arguments = arguments.size();
|
||||
|
15
tests/queries/0_stateless/01670_neighbor_lc_bug.reference
Normal file
15
tests/queries/0_stateless/01670_neighbor_lc_bug.reference
Normal file
@ -0,0 +1,15 @@
|
||||
0
|
||||
0
|
||||
0 0 0
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
4 4 4
|
||||
0 0 0
|
||||
1 1 1
|
||||
2 2 2
|
||||
┌─[1mrowNr[0m─┬─[1mval_string[0m─┬─[1mstr_m1[0m───┬─[1mstr_p1[0m───┬─[1mval_low[0m──┬─[1mlow_m1[0m───┬─[1mlow_p1[0m───┐
|
||||
│ 1 │ String 1 │ │ String 1 │ String 1 │ │ String 1 │
|
||||
│ 2 │ String 1 │ String 1 │ String 2 │ String 1 │ String 1 │ String 2 │
|
||||
│ 3 │ String 2 │ String 1 │ │ String 2 │ String 1 │ │
|
||||
└───────┴────────────┴──────────┴──────────┴──────────┴──────────┴──────────┘
|
43
tests/queries/0_stateless/01670_neighbor_lc_bug.sql
Normal file
43
tests/queries/0_stateless/01670_neighbor_lc_bug.sql
Normal file
@ -0,0 +1,43 @@
|
||||
SELECT
|
||||
neighbor(n, -2) AS int,
|
||||
neighbor(s, -2) AS str,
|
||||
neighbor(lcs, -2) AS lowCstr
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
number % 5 AS n,
|
||||
toString(n) AS s,
|
||||
CAST(s, 'LowCardinality(String)') AS lcs
|
||||
FROM numbers(10)
|
||||
);
|
||||
|
||||
drop table if exists neighbor_test;
|
||||
|
||||
CREATE TABLE neighbor_test
|
||||
(
|
||||
`rowNr` UInt8,
|
||||
`val_string` String,
|
||||
`val_low` LowCardinality(String)
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
PARTITION BY tuple()
|
||||
ORDER BY rowNr;
|
||||
|
||||
INSERT INTO neighbor_test VALUES (1, 'String 1', 'String 1'), (2, 'String 1', 'String 1'), (3, 'String 2', 'String 2');
|
||||
|
||||
SELECT
|
||||
rowNr,
|
||||
val_string,
|
||||
neighbor(val_string, -1) AS str_m1,
|
||||
neighbor(val_string, 1) AS str_p1,
|
||||
val_low,
|
||||
neighbor(val_low, -1) AS low_m1,
|
||||
neighbor(val_low, 1) AS low_p1
|
||||
FROM
|
||||
(
|
||||
SELECT *
|
||||
FROM neighbor_test
|
||||
ORDER BY val_string ASC
|
||||
) format PrettyCompact;
|
||||
|
||||
drop table if exists neighbor_test;
|
Loading…
Reference in New Issue
Block a user