Fix incorrect normal projection AST format

This commit is contained in:
Amos Bird 2023-08-12 15:07:47 +08:00
parent 3232993eeb
commit ec7301b060
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
3 changed files with 20 additions and 2 deletions

View File

@ -73,11 +73,11 @@ void ASTProjectionSelectQuery::formatImpl(const FormatSettings & s, FormatState
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.
s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "ORDER BY " << (s.hilite ? hilite_none : "");
ASTPtr order_by;
if (auto * func = orderBy()->as<ASTFunction>())
if (auto * func = orderBy()->as<ASTFunction>(); func && func->name == "tuple")
order_by = func->arguments;
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;