diff --git a/ydb/core/kqp/ut/olap/kqp_olap_ut.cpp b/ydb/core/kqp/ut/olap/kqp_olap_ut.cpp index 267b0857c4a8..635efa2c00b2 100644 --- a/ydb/core/kqp/ut/olap/kqp_olap_ut.cpp +++ b/ydb/core/kqp/ut/olap/kqp_olap_ut.cpp @@ -51,7 +51,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) { PARTITION BY HASH(timestamp) WITH ( STORE = COLUMN, - PARTITIONS_COUNT = %d + PARTITION_COUNT = %d ) )", storeName.data(), tableName.data(), shardsCount); @@ -1846,7 +1846,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) { PARTITION BY HASH(WatchID) WITH ( STORE = COLUMN, - PARTITIONS_COUNT =)" << numShards + PARTITION_COUNT =)" << numShards << ")"; auto result = session.ExecuteSchemeQuery(query).GetValueSync(); UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); @@ -1934,7 +1934,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) { WITH ( STORE = COLUMN, AUTO_PARTITIONING_BY_SIZE = ENABLED, - PARTITIONS_COUNT = 1 + PARTITION_COUNT = 1 ); )"); @@ -1988,7 +1988,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) { WITH ( STORE = COLUMN, AUTO_PARTITIONING_BY_SIZE = ENABLED, - PARTITIONS_COUNT = 1 + PARTITION_COUNT = 1 ); )"); @@ -2039,7 +2039,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) { WITH ( STORE = COLUMN, AUTO_PARTITIONING_BY_SIZE = ENABLED, - PARTITIONS_COUNT = 8 + PARTITION_COUNT = 8 ); )" ); @@ -2510,7 +2510,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) { PRIMARY KEY (a) ) PARTITION BY HASH(a) - WITH (STORE = COLUMN, PARTITIONS_COUNT = 4); + WITH (STORE = COLUMN, PARTITION_COUNT = 4); )"; auto result = session.ExecuteSchemeQuery(query).GetValueSync(); diff --git a/ydb/library/yql/sql/v1/node.h b/ydb/library/yql/sql/v1/node.h index 3643c1b0aaf4..62a8e0ce2f85 100644 --- a/ydb/library/yql/sql/v1/node.h +++ b/ydb/library/yql/sql/v1/node.h @@ -1121,7 +1121,7 @@ namespace NSQLTranslationV1 { TMaybe AutoPartitioningByLoad; TNodePtr MinPartitions; TNodePtr MaxPartitions; - TNodePtr PartitionsCount; + TNodePtr PartitionCount; TNodePtr UniformPartitions; TVector> PartitionAtKeys; TMaybe KeyBloomFilter; diff --git a/ydb/library/yql/sql/v1/query.cpp b/ydb/library/yql/sql/v1/query.cpp index 33a3bb7f8a83..847ffa1a9cde 100644 --- a/ydb/library/yql/sql/v1/query.cpp +++ b/ydb/library/yql/sql/v1/query.cpp @@ -224,9 +224,9 @@ static INode::TPtr CreateTableSettings(const TTableSettings& tableSettings, ETab if (tableSettings.MaxPartitions) { settings = L(settings, Q(Y(Q("maxPartitions"), tableSettings.MaxPartitions))); } - if (tableSettings.PartitionsCount) { - settings = L(settings, Q(Y(Q("maxPartitions"), tableSettings.PartitionsCount))); - settings = L(settings, Q(Y(Q("minPartitions"), tableSettings.PartitionsCount))); + if (tableSettings.PartitionCount) { + settings = L(settings, Q(Y(Q("maxPartitions"), tableSettings.PartitionCount))); + settings = L(settings, Q(Y(Q("minPartitions"), tableSettings.PartitionCount))); } if (tableSettings.KeyBloomFilter) { const auto& ref = tableSettings.KeyBloomFilter.GetRef(); diff --git a/ydb/library/yql/sql/v1/sql_translation.cpp b/ydb/library/yql/sql/v1/sql_translation.cpp index 81b96e3f109f..8b2af4fd8cb2 100644 --- a/ydb/library/yql/sql/v1/sql_translation.cpp +++ b/ydb/library/yql/sql/v1/sql_translation.cpp @@ -2041,7 +2041,7 @@ bool TSqlTranslation::StoreExternalTableSettingsEntry(const TIdentifier& id, con } bool TSqlTranslation::ValidateTableSettings(const TTableSettings& settings) { - if (settings.PartitionsCount) { + if (settings.PartitionCount) { if (!settings.StoreType || to_lower(settings.StoreType->Name) != "column") { Ctx.Error() << " PARTITION_COUNT can be used only with STORE=COLUMN"; return false; @@ -2109,13 +2109,13 @@ bool TSqlTranslation::StoreTableSettingsEntry(const TIdentifier& id, const TRule Ctx.Error() << to_upper(id.Name) << " value should be an integer"; return false; } - } else if (to_lower(id.Name) == "partitions_count") { + } else if (to_lower(id.Name) == "partition_count") { if (reset) { Ctx.Error() << to_upper(id.Name) << " reset is not supported"; return false; } - if (!StoreInt(*value, settings.PartitionsCount, Ctx)) { + if (!StoreInt(*value, settings.PartitionCount, Ctx)) { Ctx.Error() << to_upper(id.Name) << " value should be an integer"; return false; } diff --git a/ydb/library/yql/sql/v1/sql_ut.cpp b/ydb/library/yql/sql/v1/sql_ut.cpp index 9242752f1798..b5cdeb80aca9 100644 --- a/ydb/library/yql/sql/v1/sql_ut.cpp +++ b/ydb/library/yql/sql/v1/sql_ut.cpp @@ -7204,3 +7204,28 @@ Y_UNIT_TEST_SUITE(ResourcePoolClassifier) { UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]); } } + +Y_UNIT_TEST_SUITE(OlapPartitionCount) { + Y_UNIT_TEST(CorrectUsage) { + NYql::TAstParseResult res = SqlToYql(R"sql( + USE plato; + CREATE TABLE `mytable` (id Uint32, PRIMARY KEY (id)) + PARTITION BY HASH(id) + WITH (STORE = COLUMN, PARTITION_COUNT = 8); + )sql"); + + UNIT_ASSERT_C(res.IsOk(), res.Issues.ToString()); + } + + Y_UNIT_TEST(UseWithoutColumnStore) { + NYql::TAstParseResult res = SqlToYql(R"sql( + USE plato; + CREATE TABLE `mytable` (id Uint32, PRIMARY KEY (id)) + WITH (PARTITION_COUNT = 8); + )sql"); + + UNIT_ASSERT(!res.IsOk()); + UNIT_ASSERT(res.Issues.Size() == 1); + UNIT_ASSERT_STRING_CONTAINS(res.Issues.ToString(), "PARTITION_COUNT can be used only with STORE=COLUMN"); + } +}