fix bug when column description has settings, ttl and statistics

This commit is contained in:
Han Fei 2024-11-15 18:54:01 +01:00
parent 9caac43b2a
commit 91b62c56d2
3 changed files with 17 additions and 12 deletions

View File

@ -157,18 +157,6 @@ void ColumnDescription::writeText(WriteBuffer & buf, IAST::FormatState & state,
writeEscapedString(formatASTStateAware(*codec, state), buf);
}
if (!settings.empty())
{
writeChar('\t', buf);
DB::writeText("SETTINGS ", buf);
DB::writeText("(", buf);
ASTSetQuery ast;
ast.is_standalone = false;
ast.changes = settings;
writeEscapedString(formatASTStateAware(ast, state), buf);
DB::writeText(")", buf);
}
if (!statistics.empty())
{
writeChar('\t', buf);
@ -182,6 +170,18 @@ void ColumnDescription::writeText(WriteBuffer & buf, IAST::FormatState & state,
writeEscapedString(formatASTStateAware(*ttl, state), buf);
}
if (!settings.empty())
{
writeChar('\t', buf);
DB::writeText("SETTINGS ", buf);
DB::writeText("(", buf);
ASTSetQuery ast;
ast.is_standalone = false;
ast.changes = settings;
writeEscapedString(formatASTStateAware(ast, state), buf);
DB::writeText(")", buf);
}
writeChar('\n', buf);
}

View File

@ -0,0 +1,5 @@
drop table if exists t1;
SET allow_experimental_statistics = 1;
create table t1 (d Datetime, c0 Int TTL d + INTERVAL 1 MONTH SETTINGS (max_compress_block_size = 1), c2 Int STATISTICS(Uniq) SETTINGS (max_compress_block_size = 1)) Engine = MergeTree() ORDER BY ();
insert into t1 values ('2024-11-15 18:30:00', 25, 20);