Add default granularity

This commit is contained in:
Nikolay Degterinsky 2023-01-19 20:52:38 +00:00
parent b80ee8df50
commit dd7fef11a2
3 changed files with 11 additions and 6 deletions

View File

@ -131,15 +131,15 @@ bool ParserIndexDeclaration::parseImpl(Pos & pos, ASTPtr & node, Expected & expe
if (!data_type_p.parse(pos, type, expected))
return false;
if (!s_granularity.ignore(pos, expected))
return false;
if (!granularity_p.parse(pos, granularity, expected))
return false;
if (s_granularity.ignore(pos, expected))
{
if (!granularity_p.parse(pos, granularity, expected))
return false;
}
auto index = std::make_shared<ASTIndexDeclaration>();
index->name = name->as<ASTIdentifier &>().name();
index->granularity = granularity->as<ASTLiteral &>().value.safeGet<UInt64>();
index->granularity = granularity ? granularity->as<ASTLiteral &>().value.safeGet<UInt64>() : 1;
index->set(index->expr, expr);
index->set(index->type, type);
node = index;

View File

@ -0,0 +1 @@
CREATE TABLE default.users_02534\n(\n `id` Int16,\n `name` String,\n INDEX bf_idx name TYPE minmax GRANULARITY 1\n)\nENGINE = MergeTree\nORDER BY id\nSETTINGS index_granularity = 8192

View File

@ -0,0 +1,4 @@
DROP TABLE IF EXISTS users_02534;
CREATE TABLE users_02534 (id Int16, name String, INDEX bf_idx(name) TYPE minmax) ENGINE=MergeTree ORDER BY id;
SHOW CREATE TABLE users_02534;
DROP TABLE users_02534;