Skip to content

Commit

Permalink
Merge branch 'ydb-platform:stable-24-1' into stable-24-1
Browse files Browse the repository at this point in the history
  • Loading branch information
jepett0 authored Mar 11, 2024
2 parents 3acf9dd + f24b02a commit 1b5d43a
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ui64> 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) {
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/kqp/provider/yql_kikimr_type_ann.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ class TKiSinkTypeAnnotationTransformer : public TKiSinkVisitorTransformer
continue;
}

if (op == TYdbOperation::UpdateOn) {
if (op == TYdbOperation::UpdateOn || op == TYdbOperation::DeleteOn) {
continue;
}

Expand Down
93 changes: 93 additions & 0 deletions ydb/core/kqp/ut/scheme/kqp_constraints_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/protos/feature_flags.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/protos/table_service_config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 4 additions & 15 deletions ydb/core/tx/scheme_board/replica.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,6 @@ class TReplica: public TMonitorableActor<TReplica> {
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,
Expand Down Expand Up @@ -540,13 +529,13 @@ class TReplica: public TMonitorableActor<TReplica> {
}

// 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
Expand Down Expand Up @@ -898,7 +887,7 @@ class TReplica: public TMonitorableActor<TReplica> {
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);
}

Expand All @@ -923,7 +912,7 @@ class TReplica: public TMonitorableActor<TReplica> {
}

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);
}

Expand Down

0 comments on commit 1b5d43a

Please sign in to comment.