mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 07:01:59 +00:00
Change formatting of subqueries (make it more human friendly)
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
This commit is contained in:
parent
0037713dd3
commit
8b438bcd3c
@ -95,7 +95,7 @@ void ASTSelectQuery::formatImpl(const FormatSettings & s, FormatState & state, F
|
||||
|
||||
if (tables())
|
||||
{
|
||||
s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "FROM " << (s.hilite ? hilite_none : "");
|
||||
s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "FROM" << (s.hilite ? hilite_none : "");
|
||||
tables()->formatImpl(s, state, frame);
|
||||
}
|
||||
|
||||
|
@ -35,24 +35,24 @@ void ASTSelectWithUnionQuery::formatQueryImpl(const FormatSettings & settings, F
|
||||
if (mode == Mode::Unspecified)
|
||||
return "";
|
||||
else if (mode == Mode::ALL)
|
||||
return "ALL";
|
||||
return " ALL";
|
||||
else
|
||||
return "DISTINCT";
|
||||
return " DISTINCT";
|
||||
};
|
||||
|
||||
for (ASTs::const_iterator it = list_of_selects->children.begin(); it != list_of_selects->children.end(); ++it)
|
||||
{
|
||||
if (it != list_of_selects->children.begin())
|
||||
settings.ostr << settings.nl_or_ws << indent_str << (settings.hilite ? hilite_keyword : "") << "UNION "
|
||||
settings.ostr << settings.nl_or_ws << indent_str << (settings.hilite ? hilite_keyword : "") << "UNION"
|
||||
<< mode_to_str((is_normalized) ? union_mode : list_of_modes[it - list_of_selects->children.begin() - 1])
|
||||
<< (settings.hilite ? hilite_none : "");
|
||||
|
||||
if (auto * node = (*it)->as<ASTSelectWithUnionQuery>())
|
||||
{
|
||||
settings.ostr << settings.nl_or_ws << indent_str;
|
||||
|
||||
if (node->list_of_selects->children.size() == 1)
|
||||
{
|
||||
if (it != list_of_selects->children.begin())
|
||||
settings.ostr << settings.nl_or_ws;
|
||||
(node->list_of_selects->children.at(0))->formatImpl(settings, state, frame);
|
||||
}
|
||||
else
|
||||
|
@ -29,6 +29,11 @@ void ASTSubquery::appendColumnNameImpl(WriteBuffer & ostr) const
|
||||
|
||||
void ASTSubquery::formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
||||
{
|
||||
/// NOTE: due to trickery of filling cte_name (in interpreters) it is hard
|
||||
/// to print it w/o newline (for !oneline case), since if nl_or_ws
|
||||
/// prepended here, then formatting will be incorrect with alias:
|
||||
///
|
||||
/// (select 1 in ((select 1) as sub))
|
||||
if (!cte_name.empty())
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_identifier : "");
|
||||
@ -40,7 +45,7 @@ void ASTSubquery::formatImplWithoutAlias(const FormatSettings & settings, Format
|
||||
std::string indent_str = settings.one_line ? "" : std::string(4u * frame.indent, ' ');
|
||||
std::string nl_or_nothing = settings.one_line ? "" : "\n";
|
||||
|
||||
settings.ostr << nl_or_nothing << indent_str << "(" << nl_or_nothing;
|
||||
settings.ostr << "(" << nl_or_nothing;
|
||||
FormatStateStacked frame_nested = frame;
|
||||
frame_nested.need_parens = false;
|
||||
++frame_nested.indent;
|
||||
|
@ -109,14 +109,17 @@ void ASTTableExpression::formatImpl(const FormatSettings & settings, FormatState
|
||||
|
||||
if (database_and_table_name)
|
||||
{
|
||||
settings.ostr << " ";
|
||||
database_and_table_name->formatImpl(settings, state, frame);
|
||||
}
|
||||
else if (table_function)
|
||||
{
|
||||
settings.ostr << " ";
|
||||
table_function->formatImpl(settings, state, frame);
|
||||
}
|
||||
else if (subquery)
|
||||
{
|
||||
settings.ostr << settings.nl_or_ws << indent_str;
|
||||
subquery->formatImpl(settings, state, frame);
|
||||
}
|
||||
|
||||
@ -142,9 +145,15 @@ void ASTTableExpression::formatImpl(const FormatSettings & settings, FormatState
|
||||
}
|
||||
|
||||
|
||||
void ASTTableJoin::formatImplBeforeTable(const FormatSettings & settings, FormatState &, FormatStateStacked) const
|
||||
void ASTTableJoin::formatImplBeforeTable(const FormatSettings & settings, FormatState &, FormatStateStacked frame) const
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "");
|
||||
std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
|
||||
|
||||
if (kind != Kind::Comma)
|
||||
{
|
||||
settings.ostr << settings.nl_or_ws << indent_str;
|
||||
}
|
||||
|
||||
switch (locality)
|
||||
{
|
||||
@ -241,6 +250,7 @@ void ASTArrayJoin::formatImpl(const FormatSettings & settings, FormatState & sta
|
||||
frame.expression_list_prepend_whitespace = true;
|
||||
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "")
|
||||
<< settings.nl_or_ws
|
||||
<< (kind == Kind::Left ? "LEFT " : "") << "ARRAY JOIN" << (settings.hilite ? hilite_none : "");
|
||||
|
||||
settings.one_line
|
||||
@ -254,10 +264,7 @@ void ASTTablesInSelectQueryElement::formatImpl(const FormatSettings & settings,
|
||||
if (table_expression)
|
||||
{
|
||||
if (table_join)
|
||||
{
|
||||
table_join->as<ASTTableJoin &>().formatImplBeforeTable(settings, state, frame);
|
||||
settings.ostr << " ";
|
||||
}
|
||||
|
||||
table_expression->formatImpl(settings, state, frame);
|
||||
|
||||
@ -275,13 +282,8 @@ void ASTTablesInSelectQuery::formatImpl(const FormatSettings & settings, FormatS
|
||||
{
|
||||
std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
|
||||
|
||||
for (ASTs::const_iterator it = children.begin(); it != children.end(); ++it)
|
||||
{
|
||||
if (it != children.begin())
|
||||
settings.ostr << settings.nl_or_ws << indent_str;
|
||||
|
||||
(*it)->formatImpl(settings, state, frame);
|
||||
}
|
||||
for (const auto & child : children)
|
||||
child->formatImpl(settings, state, frame);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,8 +16,11 @@ ASTPtr ASTWithElement::clone() const
|
||||
|
||||
void ASTWithElement::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
||||
{
|
||||
std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
|
||||
|
||||
settings.writeIdentifier(name);
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " AS " << (settings.hilite ? hilite_none : "");
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " AS" << (settings.hilite ? hilite_none : "");
|
||||
settings.ostr << settings.nl_or_ws << indent_str;
|
||||
dynamic_cast<const ASTWithAlias &>(*subquery).formatImplWithoutAlias(settings, state, frame);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
SET max_block_size = 1000;
|
||||
|
||||
SELECT number FROM
|
||||
SELECT number FROM
|
||||
(
|
||||
SELECT * FROM system.numbers LIMIT 10000
|
||||
)
|
||||
|
@ -2,7 +2,7 @@ SET any_join_distinct_right_table_keys = 1;
|
||||
|
||||
SELECT
|
||||
floor((ReferrerTimestamp - InstallTimestamp) / 86400) AS DaysSinceInstallations
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT 6534090703218709881 AS DeviceIDHash, 1458586663 AS InstallTimestamp
|
||||
UNION ALL SELECT 2697418689476658272, 1458561552
|
||||
|
@ -11,7 +11,7 @@ INSERT INTO transactions VALUES ('facebook.com'), ('yandex.ru'), ('baidu.com');
|
||||
SELECT
|
||||
sum(total_count) AS total,
|
||||
domain
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT(*) AS total_count,
|
||||
@ -36,7 +36,7 @@ FORMAT JSONEachRow;
|
||||
SELECT
|
||||
sum(total_count) AS total,
|
||||
domain
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT(*) AS total_count,
|
||||
@ -63,7 +63,7 @@ SELECT DISTINCT * FROM
|
||||
SELECT
|
||||
sum(total_count) AS total,
|
||||
domain
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT(*) AS total_count,
|
||||
@ -88,7 +88,7 @@ UNION ALL
|
||||
SELECT
|
||||
sum(total_count) AS total,
|
||||
domain
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT(*) AS total_count,
|
||||
@ -116,7 +116,7 @@ SELECT
|
||||
sum(total_count) AS total,
|
||||
sum(facebookHits) AS facebook,
|
||||
domain
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT(*) AS total_count,
|
||||
@ -142,7 +142,7 @@ SELECT
|
||||
sum(total_count) AS total,
|
||||
max(facebookHits) AS facebook,
|
||||
domain
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT(*) AS total_count,
|
||||
@ -170,7 +170,7 @@ SELECT * FROM
|
||||
SELECT
|
||||
sum(total_count) AS total,
|
||||
domain
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT(*) AS total_count,
|
||||
@ -195,7 +195,7 @@ ALL FULL OUTER JOIN
|
||||
SELECT
|
||||
sum(total_count) AS total,
|
||||
domain
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT(*) AS total_count,
|
||||
@ -224,7 +224,7 @@ SELECT total FROM
|
||||
SELECT
|
||||
sum(total_count) AS total,
|
||||
domain
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT(*) AS total_count,
|
||||
@ -249,7 +249,7 @@ ALL FULL OUTER JOIN
|
||||
SELECT
|
||||
sum(total_count) AS total,
|
||||
domain
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT(*) AS total_count,
|
||||
@ -278,7 +278,7 @@ SELECT domain FROM
|
||||
SELECT
|
||||
sum(total_count) AS total,
|
||||
domain
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT(*) AS total_count,
|
||||
@ -303,7 +303,7 @@ ALL FULL OUTER JOIN
|
||||
SELECT
|
||||
sum(total_count) AS total,
|
||||
domain
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT(*) AS total_count,
|
||||
|
@ -5,7 +5,7 @@
|
||||
2000-01-01 1 test string 1 1
|
||||
-------Forbid push down-------
|
||||
SELECT count()
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
[number] AS a,
|
||||
@ -21,11 +21,11 @@ WHERE NOT ignore(a + b)
|
||||
SELECT
|
||||
a,
|
||||
b
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT 1 AS a
|
||||
)
|
||||
ANY LEFT JOIN
|
||||
ANY LEFT JOIN
|
||||
(
|
||||
SELECT
|
||||
1 AS a,
|
||||
@ -35,13 +35,13 @@ WHERE b = 0
|
||||
SELECT
|
||||
a,
|
||||
b
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
1 AS a,
|
||||
1 AS b
|
||||
)
|
||||
ANY RIGHT JOIN
|
||||
ANY RIGHT JOIN
|
||||
(
|
||||
SELECT 1 AS a
|
||||
) USING (a)
|
||||
@ -49,11 +49,11 @@ WHERE b = 0
|
||||
SELECT
|
||||
a,
|
||||
b
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT 1 AS a
|
||||
)
|
||||
ANY FULL OUTER JOIN
|
||||
ANY FULL OUTER JOIN
|
||||
(
|
||||
SELECT
|
||||
1 AS a,
|
||||
@ -63,26 +63,26 @@ WHERE b = 0
|
||||
SELECT
|
||||
a,
|
||||
b
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
1 AS a,
|
||||
1 AS b
|
||||
)
|
||||
ANY FULL OUTER JOIN
|
||||
ANY FULL OUTER JOIN
|
||||
(
|
||||
SELECT 1 AS a
|
||||
) USING (a)
|
||||
WHERE b = 0
|
||||
-------Need push down-------
|
||||
SELECT toString(value) AS value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT 1 AS value
|
||||
)
|
||||
1
|
||||
SELECT id
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT 1 AS id
|
||||
UNION ALL
|
||||
@ -92,7 +92,7 @@ FROM
|
||||
WHERE id = 1
|
||||
1
|
||||
SELECT id
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT arrayJoin([1, 2, 3]) AS id
|
||||
WHERE id = 1
|
||||
@ -100,7 +100,7 @@ FROM
|
||||
WHERE id = 1
|
||||
1
|
||||
SELECT id
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT arrayJoin([1, 2, 3]) AS id
|
||||
WHERE id = 1
|
||||
@ -110,7 +110,7 @@ WHERE id = 1
|
||||
SELECT
|
||||
id,
|
||||
subquery
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
1 AS id,
|
||||
@ -122,7 +122,7 @@ WHERE subquery = 1
|
||||
SELECT
|
||||
a,
|
||||
b
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
toUInt64(sum(id) AS b) AS a,
|
||||
@ -137,7 +137,7 @@ SELECT
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -156,7 +156,7 @@ WHERE id = 1
|
||||
SELECT
|
||||
a,
|
||||
b
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
toUInt64(sum(id) AS b) AS a,
|
||||
@ -171,7 +171,7 @@ SELECT
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -188,14 +188,14 @@ SELECT
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -214,14 +214,14 @@ SELECT
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -240,7 +240,7 @@ SELECT
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -257,14 +257,14 @@ SELECT
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -283,7 +283,7 @@ SELECT
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -300,14 +300,14 @@ SELECT
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -325,7 +325,7 @@ SELECT
|
||||
id,
|
||||
date,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
id,
|
||||
@ -344,7 +344,7 @@ SELECT
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -373,7 +373,7 @@ SELECT
|
||||
date,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -383,7 +383,7 @@ FROM
|
||||
FROM test_00597
|
||||
WHERE id = 1
|
||||
)
|
||||
ANY LEFT JOIN
|
||||
ANY LEFT JOIN
|
||||
(
|
||||
SELECT id
|
||||
FROM test_00597
|
||||
@ -395,11 +395,11 @@ SELECT
|
||||
date,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT toInt8(1) AS id
|
||||
)
|
||||
ANY LEFT JOIN
|
||||
ANY LEFT JOIN
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -411,7 +411,7 @@ ANY LEFT JOIN
|
||||
WHERE value = 1
|
||||
1 2000-01-01 test string 1 1
|
||||
SELECT value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT toInt8(1) AS id
|
||||
)
|
||||
@ -423,7 +423,7 @@ SELECT
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -433,7 +433,7 @@ FROM
|
||||
date,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -443,7 +443,7 @@ FROM
|
||||
FROM test_00597
|
||||
WHERE id = 1
|
||||
)
|
||||
ANY LEFT JOIN
|
||||
ANY LEFT JOIN
|
||||
(
|
||||
SELECT id
|
||||
FROM test_00597
|
||||
@ -460,7 +460,7 @@ SELECT
|
||||
b.date,
|
||||
b.name,
|
||||
b.value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -469,7 +469,7 @@ FROM
|
||||
value
|
||||
FROM test_00597
|
||||
)
|
||||
ANY LEFT JOIN
|
||||
ANY LEFT JOIN
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -485,7 +485,7 @@ SELECT
|
||||
date,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
toInt8(1) AS id,
|
||||
@ -493,7 +493,7 @@ FROM
|
||||
FROM system.numbers
|
||||
LIMIT 1
|
||||
)
|
||||
ANY LEFT JOIN
|
||||
ANY LEFT JOIN
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -513,7 +513,7 @@ SELECT
|
||||
`b.id`,
|
||||
`b.name`,
|
||||
`b.value`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -524,7 +524,7 @@ FROM
|
||||
b.id,
|
||||
b.name,
|
||||
b.value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -534,7 +534,7 @@ FROM
|
||||
FROM test_00597
|
||||
WHERE id = 1
|
||||
) AS a
|
||||
ANY LEFT JOIN
|
||||
ANY LEFT JOIN
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -555,7 +555,7 @@ SELECT
|
||||
r.date,
|
||||
r.name,
|
||||
r.value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -564,14 +564,14 @@ FROM
|
||||
value
|
||||
FROM test_00597
|
||||
)
|
||||
SEMI LEFT JOIN
|
||||
SEMI LEFT JOIN
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date,
|
||||
@ -586,7 +586,7 @@ SEMI LEFT JOIN
|
||||
WHERE r.id = 1
|
||||
2000-01-01 1 test string 1 1 2000-01-01 test string 1 1
|
||||
SELECT value + t1.value AS expr
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
value,
|
||||
|
@ -1 +1 @@
|
||||
CREATE VIEW default.test_view_00599\n(\n `id` UInt64\n) AS\nSELECT *\nFROM default.test_00599\nWHERE id = \n(\n SELECT 1\n)
|
||||
CREATE VIEW default.test_view_00599\n(\n `id` UInt64\n) AS\nSELECT *\nFROM default.test_00599\nWHERE id = (\n SELECT 1\n)
|
||||
|
@ -5,7 +5,7 @@ SELECT
|
||||
uniqExact(x) AS u,
|
||||
uniqExactIf(x, name = 'a') AS ue,
|
||||
uniqExactIf(x, name IN ('a', 'b')) AS ui
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
toNullable('a') AS name,
|
||||
|
@ -22,7 +22,7 @@ DROP TABLE installation_stats;
|
||||
CREATE TEMPORARY TABLE Accounts (AccountID UInt64, Currency String);
|
||||
|
||||
SELECT AccountID
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
AccountID,
|
||||
|
@ -12,14 +12,11 @@ SELECT
|
||||
platform,
|
||||
app
|
||||
FROM test_00751.t_00751
|
||||
WHERE (app =
|
||||
(
|
||||
WHERE (app = (
|
||||
SELECT min(app)
|
||||
FROM test_00751.u_00751
|
||||
)) AND (platform =
|
||||
(
|
||||
SELECT
|
||||
(
|
||||
)) AND (platform = (
|
||||
SELECT (
|
||||
SELECT min(platform)
|
||||
FROM test_00751.v_00751
|
||||
)
|
||||
|
@ -18,7 +18,7 @@
|
||||
SELECT
|
||||
n,
|
||||
`finalizeAggregation(s)`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
n,
|
||||
|
@ -10,7 +10,7 @@ FROM t1
|
||||
ALL INNER JOIN t2 ON b = t2.b
|
||||
WHERE b = t2.b
|
||||
SELECT `--t1.a` AS `t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
a AS `--t1.a`,
|
||||
@ -21,7 +21,7 @@ FROM
|
||||
ALL INNER JOIN t3 ON `--t1.a` = a
|
||||
WHERE (`--t1.a` = `--t2.a`) AND (`--t1.a` = a)
|
||||
SELECT `--t1.a` AS `t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
b AS `--t1.b`,
|
||||
@ -33,13 +33,13 @@ FROM
|
||||
ALL INNER JOIN t3 ON `--t1.b` = b
|
||||
WHERE (`--t1.b` = `--t2.b`) AND (`--t1.b` = b)
|
||||
SELECT `--t1.a` AS `t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
`--t1.a`,
|
||||
`--t2.a`,
|
||||
a AS `--t3.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
a AS `--t1.a`,
|
||||
@ -52,14 +52,14 @@ FROM
|
||||
ALL INNER JOIN t4 ON `--t1.a` = a
|
||||
WHERE (`--t1.a` = `--t2.a`) AND (`--t1.a` = `--t3.a`) AND (`--t1.a` = a)
|
||||
SELECT `--t1.a` AS `t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
`--t1.b`,
|
||||
`--t1.a`,
|
||||
`--t2.b`,
|
||||
b AS `--t3.b`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
b AS `--t1.b`,
|
||||
@ -73,13 +73,13 @@ FROM
|
||||
ALL INNER JOIN t4 ON `--t1.b` = b
|
||||
WHERE (`--t1.b` = `--t2.b`) AND (`--t1.b` = `--t3.b`) AND (`--t1.b` = b)
|
||||
SELECT `--t1.a` AS `t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
`--t1.a`,
|
||||
`--t2.a`,
|
||||
a AS `--t3.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
a AS `--t1.a`,
|
||||
@ -92,13 +92,13 @@ FROM
|
||||
ALL INNER JOIN t4 ON `--t2.a` = a
|
||||
WHERE (`--t2.a` = `--t1.a`) AND (`--t2.a` = `--t3.a`) AND (`--t2.a` = a)
|
||||
SELECT `--t1.a` AS `t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
`--t1.a`,
|
||||
`--t2.a`,
|
||||
a AS `--t3.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
a AS `--t1.a`,
|
||||
@ -111,13 +111,13 @@ FROM
|
||||
ALL INNER JOIN t4 ON `--t3.a` = a
|
||||
WHERE (`--t3.a` = `--t1.a`) AND (`--t3.a` = `--t2.a`) AND (`--t3.a` = a)
|
||||
SELECT `--t1.a` AS `t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
`--t1.a`,
|
||||
`--t2.a`,
|
||||
a AS `--t3.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
a AS `--t1.a`,
|
||||
@ -130,13 +130,13 @@ FROM
|
||||
ALL INNER JOIN t4 ON (a = `--t1.a`) AND (a = `--t2.a`) AND (a = `--t3.a`)
|
||||
WHERE (a = `--t1.a`) AND (a = `--t2.a`) AND (a = `--t3.a`)
|
||||
SELECT `--t1.a` AS `t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
`--t1.a`,
|
||||
`--t2.a`,
|
||||
a AS `--t3.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
a AS `--t1.a`,
|
||||
@ -149,10 +149,10 @@ FROM
|
||||
ALL INNER JOIN t4 ON `--t3.a` = a
|
||||
WHERE (`--t1.a` = `--t2.a`) AND (`--t2.a` = `--t3.a`) AND (`--t3.a` = a)
|
||||
SELECT `--t1.a` AS `t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT `--t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT a AS `--t1.a`
|
||||
FROM t1
|
||||
@ -162,10 +162,10 @@ FROM
|
||||
) AS `--.s`
|
||||
CROSS JOIN t4
|
||||
SELECT `--t1.a` AS `t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT `--t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT a AS `--t1.a`
|
||||
FROM t1
|
||||
@ -175,7 +175,7 @@ FROM
|
||||
) AS `--.s`
|
||||
CROSS JOIN t4
|
||||
SELECT `--t1.a` AS `t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT a AS `--t1.a`
|
||||
FROM t1
|
||||
@ -183,7 +183,7 @@ FROM
|
||||
) AS `--.s`
|
||||
CROSS JOIN t3
|
||||
SELECT `--t1.a` AS `t1.a`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
a AS `--t1.a`,
|
||||
|
@ -1,7 +1,7 @@
|
||||
SELECT
|
||||
1 AS x,
|
||||
x.y
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT 'Hello, world' AS y
|
||||
) AS x
|
||||
|
@ -4,8 +4,7 @@ SELECT 1
|
||||
SELECT 1
|
||||
WHERE (1 IN (0, 2)) AND (2 = (identity(CAST(2, \'UInt8\')) AS subquery))
|
||||
SELECT 1
|
||||
WHERE 1 IN (
|
||||
(
|
||||
WHERE 1 IN ((
|
||||
SELECT arrayJoin([1, 2, 3])
|
||||
) AS subquery)
|
||||
SELECT 1
|
||||
|
@ -48,7 +48,7 @@ dictGet('one_cell_cache_ints_overflow', 'i8', toUInt64(19)),
|
||||
dictGet('one_cell_cache_ints_overflow', 'i8', toUInt64(20));
|
||||
|
||||
SELECT arrayMap(x -> dictGet('one_cell_cache_ints_overflow', 'i8', toUInt64(x)), array)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] AS array
|
||||
);
|
||||
|
@ -3,14 +3,14 @@ SELECT
|
||||
v,
|
||||
d,
|
||||
i
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
t.1 AS k,
|
||||
t.2 AS v,
|
||||
runningDifference(v) AS d,
|
||||
runningDifference(cityHash64(t.1)) AS i
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT arrayJoin([(\'a\', 1), (\'a\', 2), (\'a\', 3), (\'b\', 11), (\'b\', 13), (\'b\', 15)]) AS t
|
||||
)
|
||||
@ -26,14 +26,14 @@ SELECT
|
||||
co2,
|
||||
co3,
|
||||
num
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
co,
|
||||
co2,
|
||||
co3,
|
||||
count() AS num
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
1 AS co,
|
||||
@ -51,13 +51,13 @@ WHERE (co != 0) AND (co2 != 2)
|
||||
1 0 3 1
|
||||
1 0 0 1
|
||||
SELECT alias AS name
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT name AS alias
|
||||
FROM system.settings
|
||||
WHERE alias = \'enable_optimize_predicate_expression\'
|
||||
)
|
||||
ANY INNER JOIN
|
||||
ANY INNER JOIN
|
||||
(
|
||||
SELECT name
|
||||
FROM system.settings
|
||||
@ -66,17 +66,17 @@ WHERE name = \'enable_optimize_predicate_expression\'
|
||||
enable_optimize_predicate_expression
|
||||
1 val11 val21 val31
|
||||
SELECT ccc
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT 1 AS ccc
|
||||
WHERE 0
|
||||
UNION ALL
|
||||
SELECT ccc
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT 2 AS ccc
|
||||
)
|
||||
ANY INNER JOIN
|
||||
ANY INNER JOIN
|
||||
(
|
||||
SELECT 2 AS ccc
|
||||
) USING (ccc)
|
||||
@ -91,7 +91,7 @@ SELECT
|
||||
b.ts,
|
||||
b.id,
|
||||
id_c
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
ts,
|
||||
@ -109,7 +109,7 @@ SELECT
|
||||
b.ts AS `--b.ts`,
|
||||
b.id AS `--b.id`,
|
||||
id_c AS `--b.id_c`
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
ts,
|
||||
@ -129,7 +129,7 @@ WHERE `--a.ts` <= toDateTime(\'1970-01-01 03:00:00\')
|
||||
2 3
|
||||
4 5
|
||||
SELECT dummy
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT dummy
|
||||
FROM system.one
|
||||
@ -141,13 +141,13 @@ SELECT
|
||||
id,
|
||||
value,
|
||||
value_1
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
1 AS id,
|
||||
2 AS value
|
||||
)
|
||||
ALL INNER JOIN
|
||||
ALL INNER JOIN
|
||||
(
|
||||
SELECT
|
||||
1 AS id,
|
||||
|
@ -1,5 +1,5 @@
|
||||
SELECT id
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT 1 AS id
|
||||
UNION ALL
|
||||
@ -20,7 +20,7 @@ ORDER BY id;
|
||||
SELECT '---';
|
||||
|
||||
SELECT *
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT NULL AS x
|
||||
) js1
|
||||
@ -32,7 +32,7 @@ INNER JOIN
|
||||
SELECT '---';
|
||||
|
||||
SELECT *
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT NULL AS x
|
||||
) js1
|
||||
|
@ -3,7 +3,7 @@ SELECT
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT *
|
||||
FROM default.test
|
||||
@ -15,7 +15,7 @@ SELECT
|
||||
id,
|
||||
name,
|
||||
value
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT *
|
||||
FROM default.test
|
||||
@ -23,7 +23,7 @@ FROM
|
||||
) AS test_view
|
||||
WHERE id = 2
|
||||
SELECT id
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT *
|
||||
FROM default.test
|
||||
@ -31,7 +31,7 @@ FROM
|
||||
) AS test_view
|
||||
WHERE id = 1
|
||||
SELECT id
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT *
|
||||
FROM default.test
|
||||
|
@ -6,6 +6,6 @@ CREATE TABLE default.distributed\n(\n `n` Int8\n)\nENGINE = Distributed(\'tes
|
||||
CREATE TABLE default.distributed_tf\n(\n `n` Int8\n) AS cluster(\'test_shard_localhost\', \'default\', \'buffer\')
|
||||
CREATE TABLE default.url\n(\n `n` UInt64,\n `col` String\n)\nENGINE = URL(\'https://localhost:8443/?query=select+n,+_table+from+default.merge+format+CSV\', \'CSV\')
|
||||
CREATE TABLE default.rich_syntax\n(\n `n` Int64\n) AS remote(\'localhos{x|y|t}\', cluster(\'test_shard_localhost\', remote(\'127.0.0.{1..4}\', \'default\', \'view\')))
|
||||
CREATE VIEW default.view\n(\n `n` Int64\n) AS\nSELECT toInt64(n) AS n\nFROM \n(\n SELECT toString(n) AS n\n FROM default.merge\n WHERE _table != \'qwerty\'\n ORDER BY _table ASC\n)\nUNION ALL\nSELECT *\nFROM default.file
|
||||
CREATE VIEW default.view\n(\n `n` Int64\n) AS\nSELECT toInt64(n) AS n\nFROM\n(\n SELECT toString(n) AS n\n FROM default.merge\n WHERE _table != \'qwerty\'\n ORDER BY _table ASC\n)\nUNION ALL\nSELECT *\nFROM default.file
|
||||
CREATE DICTIONARY default.dict\n(\n `n` UInt64,\n `col` String DEFAULT \'42\'\n)\nPRIMARY KEY n\nSOURCE(CLICKHOUSE(HOST \'localhost\' PORT 9440 SECURE 1 USER \'default\' TABLE \'url\'))\nLIFETIME(MIN 0 MAX 1)\nLAYOUT(CACHE(SIZE_IN_CELLS 1))
|
||||
16
|
||||
|
@ -1,5 +1,5 @@
|
||||
SELECT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT zero AS number
|
||||
FROM remote('127.0.0.2', system.zeros)
|
||||
|
@ -3,7 +3,7 @@ SELECT
|
||||
sum(1 + n),
|
||||
sum(n - 1),
|
||||
sum(1 - n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -13,7 +13,7 @@ SELECT
|
||||
2 * sum(n),
|
||||
sum(n) / 2,
|
||||
sum(1 / n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -23,7 +23,7 @@ SELECT
|
||||
1 + min(n),
|
||||
min(n) - 1,
|
||||
1 - min(n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -33,7 +33,7 @@ SELECT
|
||||
2 * min(n),
|
||||
min(n) / 2,
|
||||
min(1 / n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -43,7 +43,7 @@ SELECT
|
||||
1 + max(n),
|
||||
max(n) - 1,
|
||||
1 - max(n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -53,7 +53,7 @@ SELECT
|
||||
2 * max(n),
|
||||
max(n) / 2,
|
||||
max(1 / n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -63,7 +63,7 @@ SELECT
|
||||
sum(-1 + n),
|
||||
sum(n - -1),
|
||||
sum(-1 - n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -73,7 +73,7 @@ SELECT
|
||||
-2 * sum(n),
|
||||
sum(n) / -2,
|
||||
sum(-1 / n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -83,7 +83,7 @@ SELECT
|
||||
-1 + min(n),
|
||||
min(n) - -1,
|
||||
-1 - min(n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -93,7 +93,7 @@ SELECT
|
||||
-2 * max(n),
|
||||
max(n) / -2,
|
||||
min(-1 / n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -103,7 +103,7 @@ SELECT
|
||||
-1 + max(n),
|
||||
max(n) - -1,
|
||||
-1 - max(n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -113,7 +113,7 @@ SELECT
|
||||
-2 * min(n),
|
||||
min(n) / -2,
|
||||
max(-1 / n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -123,7 +123,7 @@ SELECT
|
||||
sum(abs(2) + n),
|
||||
sum(n - abs(2)),
|
||||
sum(1 - abs(2))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -133,7 +133,7 @@ SELECT
|
||||
sum(abs(2) * n),
|
||||
sum(n / abs(2)),
|
||||
sum(1 / abs(2))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -143,7 +143,7 @@ SELECT
|
||||
min(abs(2) + n),
|
||||
min(n - abs(2)),
|
||||
1 - min(abs(2))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -153,7 +153,7 @@ SELECT
|
||||
min(abs(2) * n),
|
||||
min(n / abs(2)),
|
||||
min(1 / abs(2))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -163,7 +163,7 @@ SELECT
|
||||
max(abs(2) + n),
|
||||
max(n - abs(2)),
|
||||
1 - max(abs(2))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -173,7 +173,7 @@ SELECT
|
||||
max(abs(2) * n),
|
||||
max(n / abs(2)),
|
||||
max(1 / abs(2))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -183,7 +183,7 @@ SELECT
|
||||
sum(abs(n) + n),
|
||||
sum(n - abs(n)),
|
||||
sum(1 - abs(n))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -193,7 +193,7 @@ SELECT
|
||||
sum(abs(n) * n),
|
||||
sum(n / abs(n)),
|
||||
sum(1 / abs(n))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -203,7 +203,7 @@ SELECT
|
||||
min(abs(n) + n),
|
||||
min(n - abs(n)),
|
||||
1 - min(abs(n))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -213,7 +213,7 @@ SELECT
|
||||
min(abs(n) * n),
|
||||
min(n / abs(n)),
|
||||
min(1 / abs(n))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -223,7 +223,7 @@ SELECT
|
||||
max(abs(n) + n),
|
||||
max(n - abs(n)),
|
||||
1 - max(abs(n))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -233,7 +233,7 @@ SELECT
|
||||
max(abs(n) * n),
|
||||
max(n / abs(n)),
|
||||
max(1 / abs(n))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -243,7 +243,7 @@ SELECT
|
||||
sum(1 + (n * n)),
|
||||
sum((n * n) - 1),
|
||||
sum(1 - (n * n))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -253,7 +253,7 @@ SELECT
|
||||
sum((2 * n) * n),
|
||||
sum(n * n) / 2,
|
||||
sum((1 / n) * n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -263,7 +263,7 @@ SELECT
|
||||
1 + min(n * n),
|
||||
min(n * n) - 1,
|
||||
1 - min(n * n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -273,7 +273,7 @@ SELECT
|
||||
min((2 * n) * n),
|
||||
min(n * n) / 2,
|
||||
min((1 / n) * n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -283,7 +283,7 @@ SELECT
|
||||
1 + max(n * n),
|
||||
max(n * n) - 1,
|
||||
1 - max(n * n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -293,7 +293,7 @@ SELECT
|
||||
max((2 * n) * n),
|
||||
max(n * n) / 2,
|
||||
max((1 / n) * n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -303,7 +303,7 @@ SELECT
|
||||
sum((1 + 1) + n),
|
||||
sum((1 + n) - 1),
|
||||
sum((1 + 1) - n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -313,7 +313,7 @@ SELECT
|
||||
sum(1 + (2 * n)),
|
||||
sum(1 + (n / 2)),
|
||||
sum(1 + (1 / n))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -323,7 +323,7 @@ SELECT
|
||||
min((1 + 1) + n),
|
||||
(1 + min(n)) - 1,
|
||||
min((1 + 1) - n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -333,7 +333,7 @@ SELECT
|
||||
1 + min(2 * n),
|
||||
1 + min(n / 2),
|
||||
1 + min(1 / n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -343,7 +343,7 @@ SELECT
|
||||
max((1 + 1) + n),
|
||||
(1 + max(n)) - 1,
|
||||
max((1 + 1) - n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -353,7 +353,7 @@ SELECT
|
||||
1 + max(2 * n),
|
||||
1 + max(n / 2),
|
||||
1 + max(1 / n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -363,7 +363,7 @@ SELECT
|
||||
sum((-1 + n) + -1),
|
||||
sum((n - -1) + -1),
|
||||
sum((-1 - n) + -1)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -373,7 +373,7 @@ SELECT
|
||||
(-2 * sum(n)) * -1,
|
||||
(sum(n) / -2) / -1,
|
||||
sum(-1 / n) / -1
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -383,7 +383,7 @@ SELECT
|
||||
(-1 + min(n)) + -1,
|
||||
(min(n) - -1) + -1,
|
||||
(-1 - min(n)) + -1
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -393,7 +393,7 @@ SELECT
|
||||
(-2 * min(n)) * -1,
|
||||
(min(n) / -2) / -1,
|
||||
max(-1 / n) / -1
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -403,7 +403,7 @@ SELECT
|
||||
(-1 + max(n)) + -1,
|
||||
(max(n) - -1) + -1,
|
||||
(-1 - max(n)) + -1
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
@ -413,43 +413,43 @@ SELECT
|
||||
(-2 * max(n)) * -1,
|
||||
(max(n) / -2) / -1,
|
||||
min(-1 / n) / -1
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT ((sum(n + 1) + sum(1 + n)) + sum(n - 1)) + sum(1 - n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT (((sum(n) * 2) + (2 * sum(n))) + (sum(n) / 2)) + sum(1 / n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT (((min(n) + 1) + (1 + min(n))) + (min(n) - 1)) + (1 - min(n))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT (((min(n) * 2) + (2 * min(n))) + (min(n) / 2)) + min(1 / n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT (((max(n) + 1) + (1 + max(n))) + (max(n) - 1)) + (1 - max(n))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT (((max(n) * 2) + (2 * max(n))) + (max(n) / 2)) + max(1 / n)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS n
|
||||
FROM numbers(10)
|
||||
|
@ -1,8 +1,8 @@
|
||||
SELECT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number
|
||||
FROM numbers(3)
|
||||
@ -13,10 +13,10 @@ ORDER BY number ASC
|
||||
1
|
||||
2
|
||||
SELECT DISTINCT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number
|
||||
FROM numbers(3)
|
||||
@ -29,10 +29,10 @@ ORDER BY number ASC
|
||||
1
|
||||
2
|
||||
SELECT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number % 2 AS number
|
||||
FROM numbers(3)
|
||||
@ -42,10 +42,10 @@ ORDER BY number ASC
|
||||
0
|
||||
1
|
||||
SELECT DISTINCT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number % 2 AS number
|
||||
FROM numbers(3)
|
||||
|
@ -74,7 +74,7 @@ GROUP BY
|
||||
number % 5
|
||||
ORDER BY a ASC
|
||||
SELECT foo
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS foo
|
||||
FROM numbers(1)
|
||||
@ -155,7 +155,7 @@ GROUP BY
|
||||
number % 5
|
||||
ORDER BY a ASC
|
||||
SELECT foo
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT anyLast(number) AS foo
|
||||
FROM numbers(1)
|
||||
|
@ -16,21 +16,21 @@
|
||||
2 2
|
||||
3 3
|
||||
SELECT groupArray(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS x
|
||||
FROM numbers(3)
|
||||
ORDER BY x ASC
|
||||
)
|
||||
SELECT groupArray(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS x
|
||||
FROM numbers(3)
|
||||
ORDER BY x ASC
|
||||
)
|
||||
SELECT groupArray(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS x
|
||||
FROM numbers(3)
|
||||
@ -43,7 +43,7 @@ SELECT
|
||||
a,
|
||||
b,
|
||||
c
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number + 2 AS key
|
||||
FROM numbers(4)
|
||||
@ -84,7 +84,7 @@ ORDER BY
|
||||
2 2
|
||||
3 3
|
||||
SELECT groupArray(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS x
|
||||
FROM numbers(3)
|
||||
@ -93,7 +93,7 @@ FROM
|
||||
exp(x) ASC
|
||||
)
|
||||
SELECT groupArray(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS x
|
||||
FROM numbers(3)
|
||||
@ -102,7 +102,7 @@ FROM
|
||||
exp(exp(x)) ASC
|
||||
)
|
||||
SELECT groupArray(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number AS x
|
||||
FROM numbers(3)
|
||||
@ -115,7 +115,7 @@ SELECT
|
||||
a,
|
||||
b,
|
||||
c
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number + 2 AS key
|
||||
FROM numbers(4)
|
||||
|
@ -1,7 +1,7 @@
|
||||
SELECT
|
||||
k,
|
||||
groupArrayMovingSum(v)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
k,
|
||||
|
@ -4,7 +4,7 @@ SELECT
|
||||
uniqHLL12(x),
|
||||
uniqCombined(x),
|
||||
uniqCombined64(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
@ -15,7 +15,7 @@ SELECT
|
||||
uniqHLL12(x + y),
|
||||
uniqCombined(x + y),
|
||||
uniqCombined64(x + y)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
number % 2 AS x,
|
||||
@ -28,7 +28,7 @@ SELECT
|
||||
uniqHLL12(x),
|
||||
uniqCombined(x),
|
||||
uniqCombined64(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
@ -39,7 +39,7 @@ SELECT
|
||||
uniqHLL12(x),
|
||||
uniqCombined(x),
|
||||
uniqCombined64(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
@ -50,7 +50,7 @@ SELECT
|
||||
uniqHLL12(x),
|
||||
uniqCombined(x),
|
||||
uniqCombined64(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
@ -61,13 +61,13 @@ SELECT
|
||||
uniqHLL12(x),
|
||||
uniqCombined(x),
|
||||
uniqCombined64(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT uniqExact(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
@ -80,7 +80,7 @@ SELECT
|
||||
uniqHLL12(x),
|
||||
uniqCombined(x),
|
||||
uniqCombined64(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
@ -91,7 +91,7 @@ SELECT
|
||||
uniqHLL12(x + y),
|
||||
uniqCombined(x + y),
|
||||
uniqCombined64(x + y)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
number % 2 AS x,
|
||||
@ -104,7 +104,7 @@ SELECT
|
||||
uniqHLL12(-x),
|
||||
uniqCombined(-x),
|
||||
uniqCombined64(-x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
@ -115,7 +115,7 @@ SELECT
|
||||
uniqHLL12(bitNot(x)),
|
||||
uniqCombined(bitNot(x)),
|
||||
uniqCombined64(bitNot(x))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
@ -126,7 +126,7 @@ SELECT
|
||||
uniqHLL12(bitNot(-x)),
|
||||
uniqCombined(bitNot(-x)),
|
||||
uniqCombined64(bitNot(-x))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
@ -137,13 +137,13 @@ SELECT
|
||||
uniqHLL12(-bitNot(-x)),
|
||||
uniqCombined(-bitNot(-x)),
|
||||
uniqCombined64(-bitNot(-x))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT uniqExact(-bitNot(-x))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
|
@ -11,7 +11,7 @@ insert into tracking_events_tmp select 2, '2020-07-10' from numbers(1881);
|
||||
insert into tracking_events_tmp select 2, '2020-07-11' from numbers(1623);
|
||||
|
||||
SELECT EventDate
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT EventDate
|
||||
FROM tracking_events_tmp AS t1
|
||||
|
@ -3,7 +3,7 @@
|
||||
SELECT
|
||||
number,
|
||||
square_number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
WITH number * 2 AS square_number
|
||||
SELECT
|
||||
|
@ -1,13 +1,13 @@
|
||||
SELECT DISTINCT number
|
||||
FROM numbers(1)
|
||||
SELECT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number
|
||||
FROM numbers(1)
|
||||
)
|
||||
SELECT DISTINCT number * 2
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT
|
||||
number * 2,
|
||||
@ -15,7 +15,7 @@ FROM
|
||||
FROM numbers(1)
|
||||
)
|
||||
SELECT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number * 2 AS number
|
||||
FROM numbers(1)
|
||||
@ -23,7 +23,7 @@ FROM
|
||||
SELECT
|
||||
b,
|
||||
a
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT
|
||||
number % 2 AS a,
|
||||
@ -31,7 +31,7 @@ FROM
|
||||
FROM numbers(100)
|
||||
)
|
||||
SELECT DISTINCT a
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT
|
||||
number % 2 AS a,
|
||||
@ -39,10 +39,10 @@ FROM
|
||||
FROM numbers(100)
|
||||
)
|
||||
SELECT a
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT a
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT
|
||||
number % 2 AS a,
|
||||
@ -51,12 +51,12 @@ FROM
|
||||
)
|
||||
)
|
||||
SELECT DISTINCT a
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
a,
|
||||
b
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT
|
||||
number % 2 AS a,
|
||||
@ -67,12 +67,12 @@ FROM
|
||||
SELECT
|
||||
a,
|
||||
b
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
b,
|
||||
a
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT
|
||||
number AS a,
|
||||
@ -83,13 +83,13 @@ FROM
|
||||
SELECT
|
||||
a,
|
||||
b
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
b,
|
||||
a,
|
||||
a + b
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT
|
||||
number % 2 AS a,
|
||||
@ -98,10 +98,10 @@ FROM
|
||||
)
|
||||
)
|
||||
SELECT DISTINCT a
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT a
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT
|
||||
number % 2 AS a,
|
||||
@ -110,21 +110,21 @@ FROM
|
||||
)
|
||||
)
|
||||
SELECT DISTINCT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number
|
||||
FROM numbers(1)
|
||||
) AS t1
|
||||
CROSS JOIN numbers(2) AS t2
|
||||
SELECT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number
|
||||
FROM numbers(1) AS t1
|
||||
CROSS JOIN numbers(2) AS t2
|
||||
)
|
||||
SELECT DISTINCT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT number
|
||||
FROM numbers(1)
|
||||
|
@ -1,5 +1,5 @@
|
||||
0 0
|
||||
WITH it AS
|
||||
WITH it AS
|
||||
(
|
||||
SELECT *
|
||||
FROM numbers(1)
|
||||
@ -7,4 +7,5 @@ WITH it AS
|
||||
SELECT
|
||||
number,
|
||||
number
|
||||
FROM it AS i
|
||||
FROM
|
||||
it AS i
|
||||
|
@ -13,7 +13,7 @@ WITH 1 AS x
|
||||
SELECT x
|
||||
WITH 1 AS x
|
||||
SELECT x
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
WITH 1 AS x
|
||||
SELECT x
|
||||
@ -22,7 +22,7 @@ WITH 1 AS x
|
||||
SELECT
|
||||
y,
|
||||
x
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
WITH 2 AS x
|
||||
SELECT 2 AS y
|
||||
@ -39,7 +39,7 @@ WITH 2 AS x
|
||||
SELECT x
|
||||
WITH
|
||||
5 AS q1,
|
||||
x AS
|
||||
x AS
|
||||
(
|
||||
WITH 5 AS q1
|
||||
SELECT
|
||||
@ -51,4 +51,5 @@ WITH
|
||||
SELECT
|
||||
b,
|
||||
a
|
||||
FROM x
|
||||
FROM
|
||||
x
|
||||
|
@ -3,7 +3,7 @@ create table local_t engine Log as select 1 a;
|
||||
|
||||
SELECT '127.0.0.{1,2}';
|
||||
SELECT *
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT a
|
||||
FROM remote('127.0.0.{1,2}', currentDatabase(), local_t)
|
||||
@ -17,7 +17,7 @@ WHERE a IN
|
||||
|
||||
SELECT '127.0.0.1';
|
||||
SELECT *
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT a
|
||||
FROM remote('127.0.0.1', currentDatabase(), local_t)
|
||||
|
@ -11,7 +11,7 @@ SELECT
|
||||
min(x) AS lower,
|
||||
max(x) + 1 AS upper,
|
||||
upper - lower AS range
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT arrayJoin([1, 2]) AS x
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
SELECT MAX(aggr)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT MAX(-1) AS aggr
|
||||
FROM system.one
|
||||
@ -11,7 +11,7 @@ FROM
|
||||
|
||||
);
|
||||
SELECT MaX(aggr)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT mAX(-1) AS aggr
|
||||
FROM system.one
|
||||
@ -22,7 +22,7 @@ FROM
|
||||
WHERE 1
|
||||
);
|
||||
SELECT MaX(aggr)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT mAX(-1) AS aggr
|
||||
FROM system.one
|
||||
@ -33,7 +33,7 @@ FROM
|
||||
WHERE 1
|
||||
);
|
||||
SELECT MaX(aggr)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT mAX(-1) AS aggr
|
||||
FROM system.one
|
||||
@ -45,7 +45,7 @@ FROM
|
||||
);
|
||||
SET aggregate_functions_null_for_empty=1;
|
||||
SELECT MAX(aggr)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT MAX(-1) AS aggr
|
||||
FROM system.one
|
||||
@ -57,7 +57,7 @@ FROM
|
||||
|
||||
);
|
||||
SELECT MaX(aggr)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT mAX(-1) AS aggr
|
||||
FROM system.one
|
||||
@ -68,7 +68,7 @@ FROM
|
||||
WHERE 1
|
||||
);
|
||||
SELECT MaX(aggr)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT mAX(-1) AS aggr
|
||||
FROM system.one
|
||||
@ -79,7 +79,7 @@ FROM
|
||||
WHERE 1
|
||||
);
|
||||
SELECT MaX(aggr)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT mAX(-1) AS aggr
|
||||
FROM system.one
|
||||
|
@ -31,7 +31,7 @@ SELECT
|
||||
dt64 != dt,
|
||||
toDateTime(dt64) != dt,
|
||||
dt64 != toDateTime64(dt, 1, 'UTC')
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
WITH toDateTime('2015-05-18 07:40:11') as value
|
||||
SELECT
|
||||
|
@ -1,7 +1,7 @@
|
||||
WITH arrayJoin(range(2)) AS delta
|
||||
SELECT
|
||||
toDate(time) + toIntervalDay(delta) AS dt
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT toDateTime('2020.11.12 19:02:04') AS time
|
||||
)
|
||||
@ -10,7 +10,7 @@ ORDER BY dt ASC;
|
||||
WITH arrayJoin([0, 1]) AS delta
|
||||
SELECT
|
||||
toDate(time) + toIntervalDay(delta) AS dt
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT toDateTime('2020.11.12 19:02:04') AS time
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
SELECT count()
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number
|
||||
FROM numbers(1000000)
|
||||
|
@ -1,7 +1,7 @@
|
||||
SELECT
|
||||
msg,
|
||||
toDateTime(intDiv(ms, 1000)) AS time
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
\'hello\' AS msg,
|
||||
|
@ -1,6 +1,6 @@
|
||||
EXPLAIN SYNTAX
|
||||
SELECT msg, toDateTime(intDiv(ms, 1000)) AS time
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
'hello' AS msg,
|
||||
|
@ -4,7 +4,7 @@ SELECT
|
||||
'',
|
||||
number,
|
||||
NULL AS k
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
materialize(NULL) OR materialize(-9223372036854775808),
|
||||
|
@ -13,7 +13,7 @@ insert into tracking_events_tmp select 2, '2020-07-10' from numbers(1881);
|
||||
insert into tracking_events_tmp select 2, '2020-07-11' from numbers(1623);
|
||||
|
||||
SELECT EventDate
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT EventDate
|
||||
FROM tracking_events_tmp AS t1
|
||||
|
@ -7,7 +7,7 @@ SELECT
|
||||
9223372036854775807
|
||||
),
|
||||
NULL
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT
|
||||
NULL,
|
||||
|
@ -33,7 +33,7 @@ SELECT
|
||||
val_low,
|
||||
neighbor(val_low, -1) AS low_m1,
|
||||
neighbor(val_low, 1) AS low_p1
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT *
|
||||
FROM neighbor_test
|
||||
|
@ -7,7 +7,7 @@ UNION ALL
|
||||
SELECT 1
|
||||
UNION ALL
|
||||
SELECT 1
|
||||
|
||||
-
|
||||
SELECT 1
|
||||
UNION ALL
|
||||
(
|
||||
@ -19,9 +19,9 @@ UNION ALL
|
||||
)
|
||||
UNION ALL
|
||||
SELECT 1
|
||||
|
||||
-
|
||||
SELECT x
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT 1 AS x
|
||||
UNION ALL
|
||||
@ -35,9 +35,9 @@ FROM
|
||||
UNION ALL
|
||||
SELECT 1
|
||||
)
|
||||
|
||||
-
|
||||
SELECT x
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT 1 AS x
|
||||
UNION ALL
|
||||
@ -45,15 +45,15 @@ FROM
|
||||
UNION ALL
|
||||
SELECT 1
|
||||
)
|
||||
|
||||
-
|
||||
SELECT 1
|
||||
UNION DISTINCT
|
||||
SELECT 1
|
||||
UNION DISTINCT
|
||||
SELECT 1
|
||||
|
||||
-
|
||||
SELECT 1
|
||||
|
||||
-
|
||||
|
||||
(
|
||||
SELECT 1
|
||||
|
@ -13,7 +13,7 @@ UNION ALL
|
||||
SELECT 1
|
||||
);
|
||||
|
||||
SELECT ' ';
|
||||
SELECT '-';
|
||||
|
||||
EXPLAIN SYNTAX
|
||||
SELECT 1
|
||||
@ -30,7 +30,7 @@ UNION ALL
|
||||
SELECT 1
|
||||
);
|
||||
|
||||
SELECT ' ';
|
||||
SELECT '-';
|
||||
|
||||
EXPLAIN SYNTAX
|
||||
SELECT x
|
||||
@ -51,11 +51,11 @@ FROM
|
||||
)
|
||||
);
|
||||
|
||||
SELECT ' ';
|
||||
SELECT '-';
|
||||
|
||||
EXPLAIN SYNTAX
|
||||
SELECT x
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT 1 AS x
|
||||
UNION ALL
|
||||
@ -66,7 +66,7 @@ FROM
|
||||
)
|
||||
);
|
||||
|
||||
SELECT ' ';
|
||||
SELECT '-';
|
||||
|
||||
EXPLAIN SYNTAX
|
||||
SELECT 1
|
||||
@ -75,12 +75,12 @@ SELECT 1
|
||||
UNION DISTINCT
|
||||
SELECT 1;
|
||||
|
||||
SELECT ' ';
|
||||
SELECT '-';
|
||||
|
||||
EXPLAIN SYNTAX
|
||||
(((((((((((((((SELECT 1)))))))))))))));
|
||||
|
||||
SELECT ' ';
|
||||
SELECT '-';
|
||||
|
||||
EXPLAIN SYNTAX
|
||||
(((((((((((((((SELECT 1 UNION DISTINCT SELECT 1))) UNION DISTINCT SELECT 1)))) UNION ALL SELECT 1))))))));
|
||||
|
@ -1,5 +1,5 @@
|
||||
SELECT * \
|
||||
FROM \
|
||||
FROM \
|
||||
( \
|
||||
SELECT 1 AS x \
|
||||
UNION ALL \
|
||||
|
@ -32,13 +32,13 @@ uniqTheta decimals
|
||||
(101,101,101)
|
||||
uniqTheta remove injective
|
||||
SELECT uniqTheta(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT uniqTheta(x + y)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
number % 2 AS x,
|
||||
@ -46,37 +46,37 @@ FROM
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT uniqTheta(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT uniqTheta(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT uniqTheta(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT uniqTheta(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT uniqTheta(x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT uniqTheta(x + y)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
number % 2 AS x,
|
||||
@ -84,25 +84,25 @@ FROM
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT uniqTheta(-x)
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT uniqTheta(bitNot(x))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT uniqTheta(bitNot(-x))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT uniqTheta(-bitNot(-x))
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT number % 2 AS x
|
||||
FROM numbers(10)
|
||||
|
@ -0,0 +1,114 @@
|
||||
# select * from system.one a
|
||||
SELECT *
|
||||
FROM system.one AS a
|
||||
# /* oneline */ select * from system.one a
|
||||
SELECT * FROM system.one AS a
|
||||
# select * from (select * from system.one) b, system.one a
|
||||
SELECT *
|
||||
FROM
|
||||
(
|
||||
SELECT *
|
||||
FROM system.one
|
||||
) AS b, system.one AS a
|
||||
# /* oneline */ select * from (select * from system.one) b, system.one a
|
||||
SELECT * FROM (SELECT * FROM system.one) AS b, system.one AS a
|
||||
# select * from system.one a, (select * from system.one) b, system.one c
|
||||
SELECT *
|
||||
FROM system.one AS a,
|
||||
(
|
||||
SELECT *
|
||||
FROM system.one
|
||||
) AS b, system.one AS c
|
||||
# /* oneline */ select * from system.one a, (select * from system.one) b, system.one c
|
||||
SELECT * FROM system.one AS a, (SELECT * FROM system.one) AS b, system.one AS c
|
||||
# select * from system.one a, (select * from system.one) b, system.one c, (select * from system.one) d
|
||||
SELECT *
|
||||
FROM system.one AS a,
|
||||
(
|
||||
SELECT *
|
||||
FROM system.one
|
||||
) AS b, system.one AS c,
|
||||
(
|
||||
SELECT *
|
||||
FROM system.one
|
||||
) AS d
|
||||
# /* oneline */ select * from system.one a, (select * from system.one) b, system.one c, (select * from system.one) d
|
||||
SELECT * FROM system.one AS a, (SELECT * FROM system.one) AS b, system.one AS c, (SELECT * FROM system.one) AS d
|
||||
# select * from system.one union all select * from system.one
|
||||
SELECT *
|
||||
FROM system.one
|
||||
UNION ALL
|
||||
SELECT *
|
||||
FROM system.one
|
||||
# /* oneline */ select * from system.one union all select * from system.one
|
||||
SELECT * FROM system.one UNION ALL SELECT * FROM system.one
|
||||
# select * from system.one union all (select * from system.one)
|
||||
SELECT *
|
||||
FROM system.one
|
||||
UNION ALL
|
||||
SELECT *
|
||||
FROM system.one
|
||||
# /* oneline */ select * from system.one union all (select * from system.one)
|
||||
SELECT * FROM system.one UNION ALL SELECT * FROM system.one
|
||||
# select 1 union all (select 1 union distinct select 1)
|
||||
SELECT 1
|
||||
UNION ALL
|
||||
(
|
||||
SELECT 1
|
||||
UNION DISTINCT
|
||||
SELECT 1
|
||||
)
|
||||
# /* oneline */ select 1 union all (select 1 union distinct select 1)
|
||||
SELECT 1 UNION ALL (SELECT 1 UNION DISTINCT SELECT 1)
|
||||
# select * from system.one array join arr as row
|
||||
SELECT *
|
||||
FROM system.one
|
||||
ARRAY JOIN arr AS row
|
||||
# /* oneline */ select * from system.one array join arr as row
|
||||
SELECT * FROM system.one ARRAY JOIN arr AS row
|
||||
# select 1 in 1
|
||||
SELECT 1 IN (1)
|
||||
# /* oneline */ select 1 in 1
|
||||
SELECT 1 IN (1)
|
||||
# select 1 in (select 1)
|
||||
SELECT 1 IN (
|
||||
SELECT 1
|
||||
)
|
||||
# /* oneline */ select 1 in (select 1)
|
||||
SELECT 1 IN (SELECT 1)
|
||||
# select 1 in f(1)
|
||||
SELECT 1 IN f(1)
|
||||
# /* oneline */ select 1 in f(1)
|
||||
SELECT 1 IN f(1)
|
||||
# select 1 in ((select 1) as sub)
|
||||
SELECT 1 IN ((
|
||||
SELECT 1
|
||||
) AS sub)
|
||||
# /* oneline */ select 1 in ((select 1) as sub)
|
||||
SELECT 1 IN ((SELECT 1) AS sub)
|
||||
# with it as ( select * from numbers(1) ) select it.number, i.number from it as i
|
||||
WITH it AS
|
||||
(
|
||||
SELECT *
|
||||
FROM numbers(1)
|
||||
)
|
||||
SELECT
|
||||
it.number,
|
||||
i.number
|
||||
FROM it AS i
|
||||
# /* oneline */ with it as ( select * from numbers(1) ) select it.number, i.number from it as i
|
||||
WITH it AS (SELECT * FROM numbers(1)) SELECT it.number, i.number FROM it AS i
|
||||
# SELECT x FROM ( SELECT 1 AS x UNION ALL ( SELECT 1 UNION ALL SELECT 1))
|
||||
SELECT x
|
||||
FROM
|
||||
(
|
||||
SELECT 1 AS x
|
||||
UNION ALL
|
||||
(
|
||||
SELECT 1
|
||||
UNION ALL
|
||||
SELECT 1
|
||||
)
|
||||
)
|
||||
# /* oneline */ SELECT x FROM ( SELECT 1 AS x UNION ALL ( SELECT 1 UNION ALL SELECT 1))
|
||||
SELECT x FROM (SELECT 1 AS x UNION ALL (SELECT 1 UNION ALL SELECT 1))
|
30
tests/queries/0_stateless/01874_select_from_trailing_whitespaces.sh
Executable file
30
tests/queries/0_stateless/01874_select_from_trailing_whitespaces.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
set -e
|
||||
|
||||
queries=(
|
||||
"select * from system.one a"
|
||||
"select * from (select * from system.one) b, system.one a"
|
||||
"select * from system.one a, (select * from system.one) b, system.one c"
|
||||
"select * from system.one a, (select * from system.one) b, system.one c, (select * from system.one) d"
|
||||
"select * from system.one union all select * from system.one"
|
||||
"select * from system.one union all (select * from system.one)"
|
||||
"select 1 union all (select 1 union distinct select 1)"
|
||||
"select * from system.one array join arr as row"
|
||||
"select 1 in 1"
|
||||
"select 1 in (select 1)"
|
||||
"select 1 in f(1)"
|
||||
"select 1 in ((select 1) as sub)"
|
||||
"with it as ( select * from numbers(1) ) select it.number, i.number from it as i"
|
||||
"SELECT x FROM ( SELECT 1 AS x UNION ALL ( SELECT 1 UNION ALL SELECT 1))"
|
||||
)
|
||||
for q in "${queries[@]}"; do
|
||||
echo "# $q"
|
||||
$CLICKHOUSE_FORMAT <<<"$q"
|
||||
echo "# /* oneline */ $q"
|
||||
$CLICKHOUSE_FORMAT --oneline <<<"$q"
|
||||
done
|
@ -1,5 +1,5 @@
|
||||
SELECT UserID, arrayEnumerateUniq(groupArray(SearchPhrase)) AS arr
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT UserID, SearchPhrase
|
||||
FROM test.hits
|
||||
|
@ -23,7 +23,7 @@ ORDER BY loyalty ASC;
|
||||
SELECT
|
||||
loyalty,
|
||||
count()
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT UserID
|
||||
FROM test.hits
|
||||
@ -46,12 +46,12 @@ ORDER BY loyalty ASC;
|
||||
SELECT
|
||||
loyalty,
|
||||
count()
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
loyalty,
|
||||
UserID
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT UserID
|
||||
FROM test.hits
|
||||
@ -81,7 +81,7 @@ FROM test.hits ANY INNER JOIN
|
||||
SELECT
|
||||
UserID,
|
||||
toInt8(if(yandex > google, yandex / (yandex + google), -google / (yandex + google)) * 10) AS loyalty
|
||||
FROM
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
UserID,
|
||||
|
Loading…
Reference in New Issue
Block a user