From 52d299a4eb8b6c2f630bd91dc116fc1baabb9118 Mon Sep 17 00:00:00 2001 From: spuchin Date: Thu, 7 Mar 2024 22:26:46 +0300 Subject: [PATCH 1/4] Enable feature flags for QueryService. (#2560) --- ydb/core/protos/feature_flags.proto | 2 +- ydb/core/protos/table_service_config.proto | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ydb/core/protos/feature_flags.proto b/ydb/core/protos/feature_flags.proto index 5035f3b0f897..30c770825054 100644 --- a/ydb/core/protos/feature_flags.proto +++ b/ydb/core/protos/feature_flags.proto @@ -104,7 +104,7 @@ message TFeatureFlags { optional bool EnableTopicDiskSubDomainQuota = 89 [default = true]; optional bool EnableSeparationComputeActorsFromRead = 90 [default = false]; optional bool EnablePQConfigTransactionsAtSchemeShard = 91 [default = false]; - optional bool EnableScriptExecutionOperations = 92 [default = false]; + optional bool EnableScriptExecutionOperations = 92 [default = true]; optional bool EnableImplicitQueryParameterTypes = 93 [default = false]; optional bool EnableForceImmediateEffectsExecution = 94 [default = false]; optional bool EnableTopicSplitMerge = 95 [default = false]; diff --git a/ydb/core/protos/table_service_config.proto b/ydb/core/protos/table_service_config.proto index 8653d314d56a..1bb2f32f8ef3 100644 --- a/ydb/core/protos/table_service_config.proto +++ b/ydb/core/protos/table_service_config.proto @@ -234,7 +234,7 @@ message TTableServiceConfig { optional bool EnablePredicateExtractForDataQueries = 37 [default = true]; optional bool EnableKqpImmediateEffects = 38 [default = true]; optional bool EnableSequentialReads = 39 [default = true]; - optional bool EnablePreparedDdl = 42 [default = false]; + optional bool EnablePreparedDdl = 42 [default = true]; optional bool EnableSequences = 43 [default = false]; optional bool EnableAsyncComputationPatternCompilation = 48 [default = true]; optional TCompileComputationPatternServiceConfig CompileComputationPatternServiceConfig = 47; From 7444062926c57835a2f629480cc270d02a10f1b3 Mon Sep 17 00:00:00 2001 From: Vitalii Gridnev Date: Fri, 8 Mar 2024 17:45:12 +0300 Subject: [PATCH 2/4] Merge fix delete on queries with default values (#2569) --- ydb/core/kqp/provider/yql_kikimr_type_ann.cpp | 2 +- ydb/core/kqp/ut/scheme/kqp_constraints_ut.cpp | 93 +++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp b/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp index 12eaf9cd1432..527cc1dce28e 100644 --- a/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp @@ -429,7 +429,7 @@ class TKiSinkTypeAnnotationTransformer : public TKiSinkVisitorTransformer continue; } - if (op == TYdbOperation::UpdateOn) { + if (op == TYdbOperation::UpdateOn || op == TYdbOperation::DeleteOn) { continue; } diff --git a/ydb/core/kqp/ut/scheme/kqp_constraints_ut.cpp b/ydb/core/kqp/ut/scheme/kqp_constraints_ut.cpp index e0ab76506b08..71ff6bc7da91 100644 --- a/ydb/core/kqp/ut/scheme/kqp_constraints_ut.cpp +++ b/ydb/core/kqp/ut/scheme/kqp_constraints_ut.cpp @@ -287,6 +287,99 @@ Y_UNIT_TEST_SUITE(KqpConstraints) { TestSerialType("serial8"); } + Y_UNIT_TEST(DefaultsAndDeleteAndUpdate) { + NKikimrConfig::TAppConfig appConfig; + appConfig.MutableTableServiceConfig()->SetEnableSequences(false); + appConfig.MutableTableServiceConfig()->SetEnableColumnsWithDefault(true); + auto serverSettings = TKikimrSettings().SetAppConfig(appConfig); + TKikimrRunner kikimr(serverSettings); + auto db = kikimr.GetTableClient(); + auto session = db.CreateSession().GetValueSync().GetSession(); + + { + auto query = R"( + --!syntax_v1 + CREATE TABLE `/Root/DefaultsAndDeleteAndUpdate` ( + Key Int32, + Value String DEFAULT "somestring", + PRIMARY KEY (Key) + ); + )"; + + auto result = session.ExecuteSchemeQuery(query).GetValueSync(); + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, + result.GetIssues().ToString()); + } + + { + TString query = R"( + UPSERT INTO `/Root/DefaultsAndDeleteAndUpdate` (Key) VALUES (1), (2), (3), (4); + )"; + + NYdb::NTable::TExecDataQuerySettings execSettings; + execSettings.KeepInQueryCache(true); + execSettings.CollectQueryStats(ECollectQueryStatsMode::Basic); + + auto result = + session + .ExecuteDataQuery(query, TTxControl::BeginTx().CommitTx(), + execSettings) + .ExtractValueSync(); + + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, + result.GetIssues().ToString()); + } + + { + TString query = R"( + SELECT * FROM `/Root/DefaultsAndDeleteAndUpdate`; + )"; + + NYdb::NTable::TExecDataQuerySettings execSettings; + execSettings.KeepInQueryCache(true); + execSettings.CollectQueryStats(ECollectQueryStatsMode::Basic); + + auto result = + session + .ExecuteDataQuery(query, TTxControl::BeginTx().CommitTx(), + execSettings) + .ExtractValueSync(); + + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, + result.GetIssues().ToString()); + CompareYson(R"( + [ + [[1];["somestring"]]; + [[2];["somestring"]]; + [[3];["somestring"]]; + [[4];["somestring"]] + ] + )", + NYdb::FormatResultSetYson(result.GetResultSet(0))); + } + + { + TString query = R"( + $object_pk = <|Key:1|>; + DELETE FROM `/Root/DefaultsAndDeleteAndUpdate` ON + SELECT * FROM AS_TABLE(AsList($object_pk)); + )"; + + NYdb::NTable::TExecDataQuerySettings execSettings; + execSettings.KeepInQueryCache(true); + execSettings.CollectQueryStats(ECollectQueryStatsMode::Basic); + + auto result = + session + .ExecuteDataQuery(query, TTxControl::BeginTx().CommitTx(), + execSettings) + .ExtractValueSync(); + + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, + result.GetIssues().ToString()); + } + } + Y_UNIT_TEST(AlterTableAddColumnWithDefaultValue) { NKikimrConfig::TAppConfig appConfig; appConfig.MutableTableServiceConfig()->SetEnableSequences(false); From 179a3cba638d758b9c463996aa82aad1a6a8f3c7 Mon Sep 17 00:00:00 2001 From: ildar-khisambeev Date: Fri, 8 Mar 2024 18:12:32 +0300 Subject: [PATCH 3/4] cherry pick library fix (#2481) --- .../disjoint_interval_tree/disjoint_interval_tree.h | 2 +- .../ut/disjoint_interval_tree_ut.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/library/cpp/containers/disjoint_interval_tree/disjoint_interval_tree.h b/library/cpp/containers/disjoint_interval_tree/disjoint_interval_tree.h index 3f51c61277c5..f0c6644d4be7 100644 --- a/library/cpp/containers/disjoint_interval_tree/disjoint_interval_tree.h +++ b/library/cpp/containers/disjoint_interval_tree/disjoint_interval_tree.h @@ -132,7 +132,7 @@ class TDisjointIntervalTree { } TIterator completelyRemoveEnd = completelyRemoveBegin != Tree.end() ? Tree.lower_bound(end) : Tree.end(); - if (completelyRemoveEnd != Tree.end() && completelyRemoveEnd != Tree.begin() && completelyRemoveEnd->first != end) { + if (completelyRemoveEnd != Tree.begin() && (completelyRemoveEnd == Tree.end() || completelyRemoveEnd->first != end)) { TIterator containingEnd = completelyRemoveEnd; --containingEnd; if (containingEnd->second > end) { diff --git a/library/cpp/containers/disjoint_interval_tree/ut/disjoint_interval_tree_ut.cpp b/library/cpp/containers/disjoint_interval_tree/ut/disjoint_interval_tree_ut.cpp index 8474ae89b04b..508a82459af6 100644 --- a/library/cpp/containers/disjoint_interval_tree/ut/disjoint_interval_tree_ut.cpp +++ b/library/cpp/containers/disjoint_interval_tree/ut/disjoint_interval_tree_ut.cpp @@ -232,6 +232,18 @@ Y_UNIT_TEST_SUITE(DisjointIntervalTreeTest) { UNIT_ASSERT_VALUES_EQUAL(tree.GetNumIntervals(), 2); UNIT_ASSERT_VALUES_EQUAL(tree.GetNumElements(), 8); } + + // 12. The only one interval + { + TDisjointIntervalTree tree; + tree.InsertInterval(1, 10); + UNIT_ASSERT_VALUES_EQUAL(tree.GetNumIntervals(), 1); + UNIT_ASSERT_VALUES_EQUAL(tree.GetNumElements(), 9); + UNIT_ASSERT_VALUES_EQUAL(tree.EraseInterval(0, 6), 5); + UNIT_ASSERT_VALUES_EQUAL(tree.GetNumIntervals(), 1); + UNIT_ASSERT_VALUES_EQUAL(tree.GetNumElements(), 4); + UNIT_ASSERT(tree.Intersects(5, 10)); + } } Y_UNIT_TEST(IntersectsTest) { From f24b02a98f048c5a9461d20c9a15fb06eb80bb13 Mon Sep 17 00:00:00 2001 From: ijon Date: Sun, 10 Mar 2024 20:21:31 +0300 Subject: [PATCH 4/4] schemeboard: fix path updates from both root and tenant schemeshards (#2574) --- ydb/core/tx/scheme_board/replica.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/ydb/core/tx/scheme_board/replica.cpp b/ydb/core/tx/scheme_board/replica.cpp index c1600b4bd644..cb5ddd2e923f 100644 --- a/ydb/core/tx/scheme_board/replica.cpp +++ b/ydb/core/tx/scheme_board/replica.cpp @@ -248,17 +248,6 @@ class TReplica: public TMonitorableActor { TrackMemory(); } - explicit TDescription( - TReplica* owner, - const TPathId& pathId, - TOpaquePathDescription&& pathDescription) - : Owner(owner) - , PathId(pathId) - , PathDescription(std::move(pathDescription)) - { - TrackMemory(); - } - explicit TDescription( TReplica* owner, const TString& path, @@ -540,13 +529,13 @@ class TReplica: public TMonitorableActor { } // upsert description only by pathId - TDescription& UpsertDescription(const TPathId& pathId, TOpaquePathDescription&& pathDescription) { + TDescription& UpsertDescriptionByPathId(const TString& path, const TPathId& pathId, TOpaquePathDescription&& pathDescription) { SBR_LOG_I("Upsert description" << ": pathId# " << pathId << ", pathDescription# " << pathDescription.ToString() ); - return Descriptions.Upsert(pathId, TDescription(this, pathId, std::move(pathDescription))); + return Descriptions.Upsert(pathId, TDescription(this, path, pathId, std::move(pathDescription))); } // upsert description by path AND pathId both @@ -898,7 +887,7 @@ class TReplica: public TMonitorableActor { if (abandonedSchemeShards.contains(pathId.OwnerId)) { // TSS is ignored, present GSS reverted it log("Replace GSS by TSS description is rejected, GSS implicitly knows that TSS has been reverted" ", but still inject description only by pathId for safe"); - UpsertDescription(pathId, std::move(pathDescription)); + UpsertDescriptionByPathId(path, pathId, std::move(pathDescription)); return AckUpdate(ev); } @@ -923,7 +912,7 @@ class TReplica: public TMonitorableActor { } log("Inject description only by pathId, it is update from GSS"); - UpsertDescription(pathId, std::move(pathDescription)); + UpsertDescriptionByPathId(path, pathId, std::move(pathDescription)); return AckUpdate(ev); }