Skip to content

Commit 26c9911

Browse files
authored
Fix PARTITION_COUNT option name and add tests (#9012)
1 parent ce3201c commit 26c9911

File tree

5 files changed

+38
-13
lines changed

5 files changed

+38
-13
lines changed

ydb/core/kqp/ut/olap/kqp_olap_ut.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
5151
PARTITION BY HASH(timestamp)
5252
WITH (
5353
STORE = COLUMN,
54-
PARTITIONS_COUNT = %d
54+
PARTITION_COUNT = %d
5555
)
5656
)",
5757
storeName.data(), tableName.data(), shardsCount);
@@ -1846,7 +1846,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
18461846
PARTITION BY HASH(WatchID)
18471847
WITH (
18481848
STORE = COLUMN,
1849-
PARTITIONS_COUNT =)" << numShards
1849+
PARTITION_COUNT =)" << numShards
18501850
<< ")";
18511851
auto result = session.ExecuteSchemeQuery(query).GetValueSync();
18521852
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
@@ -1934,7 +1934,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
19341934
WITH (
19351935
STORE = COLUMN,
19361936
AUTO_PARTITIONING_BY_SIZE = ENABLED,
1937-
PARTITIONS_COUNT = 1
1937+
PARTITION_COUNT = 1
19381938
);
19391939
)");
19401940

@@ -1988,7 +1988,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
19881988
WITH (
19891989
STORE = COLUMN,
19901990
AUTO_PARTITIONING_BY_SIZE = ENABLED,
1991-
PARTITIONS_COUNT = 1
1991+
PARTITION_COUNT = 1
19921992
);
19931993
)");
19941994

@@ -2039,7 +2039,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
20392039
WITH (
20402040
STORE = COLUMN,
20412041
AUTO_PARTITIONING_BY_SIZE = ENABLED,
2042-
PARTITIONS_COUNT = 8
2042+
PARTITION_COUNT = 8
20432043
);
20442044
)"
20452045
);
@@ -2510,7 +2510,7 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
25102510
PRIMARY KEY (a)
25112511
)
25122512
PARTITION BY HASH(a)
2513-
WITH (STORE = COLUMN, PARTITIONS_COUNT = 4);
2513+
WITH (STORE = COLUMN, PARTITION_COUNT = 4);
25142514
)";
25152515

25162516
auto result = session.ExecuteSchemeQuery(query).GetValueSync();

ydb/library/yql/sql/v1/node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ namespace NSQLTranslationV1 {
11211121
TMaybe<TIdentifier> AutoPartitioningByLoad;
11221122
TNodePtr MinPartitions;
11231123
TNodePtr MaxPartitions;
1124-
TNodePtr PartitionsCount;
1124+
TNodePtr PartitionCount;
11251125
TNodePtr UniformPartitions;
11261126
TVector<TVector<TNodePtr>> PartitionAtKeys;
11271127
TMaybe<TIdentifier> KeyBloomFilter;

ydb/library/yql/sql/v1/query.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ static INode::TPtr CreateTableSettings(const TTableSettings& tableSettings, ETab
224224
if (tableSettings.MaxPartitions) {
225225
settings = L(settings, Q(Y(Q("maxPartitions"), tableSettings.MaxPartitions)));
226226
}
227-
if (tableSettings.PartitionsCount) {
228-
settings = L(settings, Q(Y(Q("maxPartitions"), tableSettings.PartitionsCount)));
229-
settings = L(settings, Q(Y(Q("minPartitions"), tableSettings.PartitionsCount)));
227+
if (tableSettings.PartitionCount) {
228+
settings = L(settings, Q(Y(Q("maxPartitions"), tableSettings.PartitionCount)));
229+
settings = L(settings, Q(Y(Q("minPartitions"), tableSettings.PartitionCount)));
230230
}
231231
if (tableSettings.KeyBloomFilter) {
232232
const auto& ref = tableSettings.KeyBloomFilter.GetRef();

ydb/library/yql/sql/v1/sql_translation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,7 @@ bool TSqlTranslation::StoreExternalTableSettingsEntry(const TIdentifier& id, con
20412041
}
20422042

20432043
bool TSqlTranslation::ValidateTableSettings(const TTableSettings& settings) {
2044-
if (settings.PartitionsCount) {
2044+
if (settings.PartitionCount) {
20452045
if (!settings.StoreType || to_lower(settings.StoreType->Name) != "column") {
20462046
Ctx.Error() << " PARTITION_COUNT can be used only with STORE=COLUMN";
20472047
return false;
@@ -2109,13 +2109,13 @@ bool TSqlTranslation::StoreTableSettingsEntry(const TIdentifier& id, const TRule
21092109
Ctx.Error() << to_upper(id.Name) << " value should be an integer";
21102110
return false;
21112111
}
2112-
} else if (to_lower(id.Name) == "partitions_count") {
2112+
} else if (to_lower(id.Name) == "partition_count") {
21132113
if (reset) {
21142114
Ctx.Error() << to_upper(id.Name) << " reset is not supported";
21152115
return false;
21162116
}
21172117

2118-
if (!StoreInt(*value, settings.PartitionsCount, Ctx)) {
2118+
if (!StoreInt(*value, settings.PartitionCount, Ctx)) {
21192119
Ctx.Error() << to_upper(id.Name) << " value should be an integer";
21202120
return false;
21212121
}

ydb/library/yql/sql/v1/sql_ut.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7204,3 +7204,28 @@ Y_UNIT_TEST_SUITE(ResourcePoolClassifier) {
72047204
UNIT_ASSERT_VALUES_EQUAL(1, elementStat["Write"]);
72057205
}
72067206
}
7207+
7208+
Y_UNIT_TEST_SUITE(OlapPartitionCount) {
7209+
Y_UNIT_TEST(CorrectUsage) {
7210+
NYql::TAstParseResult res = SqlToYql(R"sql(
7211+
USE plato;
7212+
CREATE TABLE `mytable` (id Uint32, PRIMARY KEY (id))
7213+
PARTITION BY HASH(id)
7214+
WITH (STORE = COLUMN, PARTITION_COUNT = 8);
7215+
)sql");
7216+
7217+
UNIT_ASSERT_C(res.IsOk(), res.Issues.ToString());
7218+
}
7219+
7220+
Y_UNIT_TEST(UseWithoutColumnStore) {
7221+
NYql::TAstParseResult res = SqlToYql(R"sql(
7222+
USE plato;
7223+
CREATE TABLE `mytable` (id Uint32, PRIMARY KEY (id))
7224+
WITH (PARTITION_COUNT = 8);
7225+
)sql");
7226+
7227+
UNIT_ASSERT(!res.IsOk());
7228+
UNIT_ASSERT(res.Issues.Size() == 1);
7229+
UNIT_ASSERT_STRING_CONTAINS(res.Issues.ToString(), "PARTITION_COUNT can be used only with STORE=COLUMN");
7230+
}
7231+
}

0 commit comments

Comments
 (0)