aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorniksaveliev <nik@saveliev.me>2024-10-23 13:45:57 +0500
committerGitHub <noreply@github.com>2024-10-23 13:45:57 +0500
commit2c08f125d8dc71a6ffd67df23231949cc43c272f (patch)
tree234980c794ea51f056665dc1d10491304ad4f167
parentef743dddf1a4870cf1cb9f4aca41286127b64e21 (diff)
downloadydb-2c08f125d8dc71a6ffd67df23231949cc43c272f.tar.gz
Allow short auto partitioning strategies yql (#10701)
-rw-r--r--ydb/core/kqp/provider/yql_kikimr_gateway.cpp18
-rw-r--r--ydb/services/persqueue_v1/topic_yql_ut.cpp37
2 files changed, 35 insertions, 20 deletions
diff --git a/ydb/core/kqp/provider/yql_kikimr_gateway.cpp b/ydb/core/kqp/provider/yql_kikimr_gateway.cpp
index f43d42a982..cae2db91ba 100644
--- a/ydb/core/kqp/provider/yql_kikimr_gateway.cpp
+++ b/ydb/core/kqp/provider/yql_kikimr_gateway.cpp
@@ -198,7 +198,7 @@ bool SetColumnType(const TTypeAnnotationNode* typeNode, bool notNull, Ydb::Type&
const TStringBuf typeName = dataTypeNode->GetName();
NUdf::EDataSlot dataSlot = NUdf::GetDataSlot(typeName);
if (dataSlot == NUdf::EDataSlot::Decimal) {
- auto dataExprTypeNode = typeNode->Cast<TDataExprParamsType>();
+ auto dataExprTypeNode = typeNode->Cast<TDataExprParamsType>();
ui32 precision = FromString(dataExprTypeNode->GetParamOne());
ui32 scale = FromString(dataExprTypeNode->GetParamTwo());
if (!NKikimr::NScheme::TDecimalType::Validate(precision, scale, error)) {
@@ -348,8 +348,20 @@ static std::shared_ptr<THashMap<TString, Ydb::Topic::Codec>> GetCodecsMapping()
static std::shared_ptr<THashMap<TString, Ydb::Topic::AutoPartitioningStrategy>> GetAutoPartitioningStrategiesMapping() {
static std::shared_ptr<THashMap<TString, Ydb::Topic::AutoPartitioningStrategy>> strategiesMapping;
- if (strategiesMapping == nullptr) {
- strategiesMapping = MakeEnumMapping<Ydb::Topic::AutoPartitioningStrategy>(Ydb::Topic::AutoPartitioningStrategy_descriptor(), "auto_partitioning_strategy_");
+ if (!strategiesMapping) {
+ strategiesMapping = MakeEnumMapping<Ydb::Topic::AutoPartitioningStrategy>(
+ Ydb::Topic::AutoPartitioningStrategy_descriptor(), "auto_partitioning_strategy_");
+
+ const TString prefix = "scale_";
+ for (const auto& [key, value] : *strategiesMapping) {
+ if (key.StartsWith(prefix)) {
+ TString newKey = key;
+ newKey.erase(0, prefix.length());
+
+ Y_ABORT_UNLESS(strategiesMapping->find(newKey) == strategiesMapping->end());
+ (*strategiesMapping)[newKey] = value;
+ }
+ }
}
return strategiesMapping;
}
diff --git a/ydb/services/persqueue_v1/topic_yql_ut.cpp b/ydb/services/persqueue_v1/topic_yql_ut.cpp
index bda80c105b..92534059a6 100644
--- a/ydb/services/persqueue_v1/topic_yql_ut.cpp
+++ b/ydb/services/persqueue_v1/topic_yql_ut.cpp
@@ -23,31 +23,34 @@ Y_UNIT_TEST_SUITE(TTopicYqlTest) {
UNIT_ASSERT_VALUES_EQUAL(after + 1, before);
}
- Y_UNIT_TEST(CreateAndAlterTopicYqlBackCompatibility) {
+ Y_UNIT_TEST(CreateTopicYqlBackCompatibility) {
NKikimrConfig::TFeatureFlags ff;
ff.SetEnableTopicSplitMerge(true);
auto settings = NKikimr::NPersQueueTests::PQSettings();
settings.SetFeatureFlags(ff);
NPersQueue::TTestServer server(settings);
+ {
+ const char *query = R"__(
+ CREATE TOPIC `/Root/PQ/rt3.dc1--legacy--topic1` (
+ CONSUMER c1
+ ) WITH (min_active_partitions = 2,
+ partition_count_limit = 5,
+ auto_partitioning_strategy = 'scale_up'
+ );
+ )__";
- const char *query = R"__(
- CREATE TOPIC `/Root/PQ/rt3.dc1--legacy--topic1` (
- CONSUMER c1
- ) WITH (min_active_partitions = 2,
- partition_count_limit = 5,
- auto_partitioning_strategy = 'scale_up'
- );
- )__";
+ server.AnnoyingClient->RunYqlSchemeQuery(query);
+ auto pqGroup = server.AnnoyingClient->Ls("/Root/PQ/rt3.dc1--legacy--topic1")->Record.GetPathDescription()
+ .GetPersQueueGroup();
+ const auto& describeAfterCreate = pqGroup.GetPQTabletConfig();
+ Cerr <<"=== PATH DESCRIPTION: \n" << pqGroup.DebugString();
- server.AnnoyingClient->RunYqlSchemeQuery(query);
- auto pqGroup = server.AnnoyingClient->Ls("/Root/PQ/rt3.dc1--legacy--topic1")->Record.GetPathDescription()
- .GetPersQueueGroup();
- const auto& describeAfterCreate = pqGroup.GetPQTabletConfig();
- Cerr <<"=== PATH DESCRIPTION: \n" << pqGroup.DebugString();
+ UNIT_ASSERT_VALUES_EQUAL(describeAfterCreate.GetPartitionStrategy().GetMinPartitionCount(), 2);
+ UNIT_ASSERT_VALUES_EQUAL(describeAfterCreate.GetPartitionStrategy().GetMaxPartitionCount(), 5);
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(describeAfterCreate.GetPartitionStrategy().GetPartitionStrategyType()), static_cast<int>(::NKikimrPQ::TPQTabletConfig_TPartitionStrategyType::TPQTabletConfig_TPartitionStrategyType_CAN_SPLIT));
+ }
- UNIT_ASSERT_VALUES_EQUAL(describeAfterCreate.GetPartitionStrategy().GetMinPartitionCount(), 2);
- UNIT_ASSERT_VALUES_EQUAL(describeAfterCreate.GetPartitionStrategy().GetMaxPartitionCount(), 5);
}
Y_UNIT_TEST(CreateAndAlterTopicYql) {
@@ -77,7 +80,7 @@ Y_UNIT_TEST_SUITE(TTopicYqlTest) {
supported_codecs = 'RAW, GZIP',
partition_write_speed_bytes_per_second = 9000,
partition_write_burst_bytes = 100500,
- auto_partitioning_strategy = 'scale_up'
+ auto_partitioning_strategy = 'up'
);
)__";