Skip to content

Commit

Permalink
Preserve important attributes in TRUNCATE, KEEP_META mode (ydb-platfo…
Browse files Browse the repository at this point in the history
  • Loading branch information
avevad authored and MrLolthe1st committed May 28, 2024
1 parent 6d1e309 commit 68d7b4c
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions ydb/library/yql/providers/yt/gateway/native/yql_yt_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2071,8 +2071,9 @@ class TYtNativeGateway : public IYtGateway {
appendToSorted = attrs.HasKey("sorted_by") && !attrs["sorted_by"].AsList().empty();
}

NYT::TNode storageAttrs = NYT::TNode::CreateMap();
auto yqlAttrs = NYT::TNode::CreateMap();

auto storageAttrs = NYT::TNode::CreateMap();
if (appendToSorted || EYtWriteMode::RenewKeepMeta == mode) {
yqlAttrs = GetUserAttributes(entry->Tx, dstPath, false);
storageAttrs = entry->Tx->Get(dstPath + "/@", TGetOptions()
Expand All @@ -2086,8 +2087,30 @@ class TYtNativeGateway : public IYtGateway {
);
}

bool forceMerge = combineChunks;

NYT::MergeNodes(yqlAttrs, GetUserAttributes(entry->Tx, srcPaths.back(), true));
NYT::MergeNodes(yqlAttrs, YqlOpOptionsToAttrs(execCtx->Session_->OperationOptions_));
if (EYtWriteMode::RenewKeepMeta == mode) {
auto dstAttrs = entry->Tx->Get(dstPath + "/@", TGetOptions()
.AttributeFilter(TAttributeFilter()
.AddAttribute("annotation")
.AddAttribute("expiration_time")
.AddAttribute("expiration_timeout")
.AddAttribute("tablet_cell_bundle")
.AddAttribute("enable_dynamic_store_read")
)
);
if (dstAttrs.AsMap().contains("tablet_cell_bundle") && dstAttrs["tablet_cell_bundle"] != "default") {
forceMerge = true;
}
dstAttrs.AsMap().erase("tablet_cell_bundle");
if (dstAttrs.AsMap().contains("enable_dynamic_store_read")) {
forceMerge = true;
}
dstAttrs.AsMap().erase("enable_dynamic_store_read");
NYT::MergeNodes(yqlAttrs, dstAttrs);
}
NYT::TNode& rowSpecNode = yqlAttrs[YqlRowSpecAttribute];
const auto nativeYtTypeCompatibility = execCtx->Options_.Config()->NativeYtTypeCompatibility.Get(cluster).GetOrElse(NTCF_LEGACY);
const bool rowSpecCompactForm = execCtx->Options_.Config()->UseYqlRowSpecCompactForm.Get().GetOrElse(DEFAULT_ROW_SPEC_COMPACT_FORM);
Expand All @@ -2102,7 +2125,7 @@ class TYtNativeGateway : public IYtGateway {
}
};

if (EYtWriteMode::Renew == mode) {
if (EYtWriteMode::Renew == mode || EYtWriteMode::RenewKeepMeta == mode) {
const auto expirationIt = strOpts.find(EYtSettingType::Expiration);
bool isTimestamp = false, isDuration = false;
TInstant stamp;
Expand Down Expand Up @@ -2139,7 +2162,6 @@ class TYtNativeGateway : public IYtGateway {
}
}

bool forceMerge = combineChunks;
bool forceTransform = false;

#define DEFINE_OPT(name, attr, transform) \
Expand Down

0 comments on commit 68d7b4c

Please sign in to comment.