Merge pull request #53347 from amosbird/fix_52607

Fix incorrect normal projection AST format
This commit is contained in:
Alexey Milovidov 2023-08-12 17:26:05 +03:00 committed by GitHub
commit f098b51283
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View File

@ -73,11 +73,11 @@ void ASTProjectionSelectQuery::formatImpl(const FormatSettings & s, FormatState
if (orderBy()) if (orderBy())
{ {
/// Let's convert the ASTFunction into ASTExpressionList, which generates consistent format /// Let's convert tuple ASTFunction into ASTExpressionList, which generates consistent format
/// between GROUP BY and ORDER BY projection definition. /// between GROUP BY and ORDER BY projection definition.
s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "ORDER BY " << (s.hilite ? hilite_none : ""); s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "ORDER BY " << (s.hilite ? hilite_none : "");
ASTPtr order_by; ASTPtr order_by;
if (auto * func = orderBy()->as<ASTFunction>()) if (auto * func = orderBy()->as<ASTFunction>(); func && func->name == "tuple")
order_by = func->arguments; order_by = func->arguments;
else else
{ {

View File

@ -0,0 +1 @@
CREATE TABLE default.test\n(\n `uuid` FixedString(16),\n `id` Int32,\n `ns` FixedString(16),\n `dt` DateTime64(6),\n PROJECTION mtlog_proj_source_reference\n (\n SELECT *\n ORDER BY substring(ns, 1, 5)\n )\n)\nENGINE = MergeTree\nORDER BY (id, dt, uuid)\nSETTINGS index_granularity = 8192

View File

@ -0,0 +1,17 @@
DROP TABLE if exists test;
CREATE TABLE test
(
uuid FixedString(16),
id int,
ns FixedString(16),
dt DateTime64(6),
)
ENGINE = MergeTree
ORDER BY (id, dt, uuid);
ALTER TABLE test ADD PROJECTION mtlog_proj_source_reference (SELECT * ORDER BY substring(ns, 1, 5));
SHOW CREATE test;
drop table test;