mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 10:52:30 +00:00
8b438bcd3c
Fix trailing whitespaces in FROM/IN clause with subqueries in multiline mode, and also changes the output of the queries slightly in a more human friendly way. Before: $ clickhouse-format <<<'select * from system.one, (select * from system.one)' SELECT * FROM system.one , ( SELECT * FROM system.one ) After: $ clickhouse-format <<<'select * from system.one, (select * from system.one)' SELECT * FROM system.one, ( SELECT * FROM system.one ) v2: Fix subqueries formatting in a different way v3: Adjust *.reference in tests v4: Fix modernize-loop-convert in ASTTablesInSelectQuery
44 lines
896 B
SQL
44 lines
896 B
SQL
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;
|