2024-05-24 10:54:06 +00:00
|
|
|
SET allow_deprecated_error_prone_window_functions = 1;
|
2024-03-23 02:10:14 +00:00
|
|
|
SET output_format_pretty_row_numbers = 0;
|
|
|
|
|
2021-01-26 10:31:29 +00:00
|
|
|
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
|
2021-05-15 09:11:13 +00:00
|
|
|
FROM
|
2021-01-26 10:31:29 +00:00
|
|
|
(
|
|
|
|
SELECT *
|
|
|
|
FROM neighbor_test
|
2022-02-09 11:23:20 +00:00
|
|
|
ORDER BY val_string, rowNr
|
2022-01-31 22:25:35 +00:00
|
|
|
)
|
2022-02-06 13:31:59 +00:00
|
|
|
ORDER BY rowNr, val_string, str_m1, str_p1, val_low, low_m1, low_p1
|
2024-01-15 17:15:15 +00:00
|
|
|
SETTINGS output_format_pretty_color=1
|
2022-01-31 22:25:35 +00:00
|
|
|
format PrettyCompact;
|
2021-01-26 10:31:29 +00:00
|
|
|
|
|
|
|
drop table if exists neighbor_test;
|