Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
swalrus1 committed Nov 28, 2024
1 parent 2908bf9 commit 3de0325
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
37 changes: 21 additions & 16 deletions ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5444,10 +5444,10 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
UNIT_ASSERT_C(desc.IsSuccess(), desc.GetIssues().ToString());

UNIT_ASSERT(desc.GetTableDescription().GetTtlSettings());
auto ttl = desc.GetTableDescription().GetTtlSettings()->GetDateTypeColumn();
UNIT_ASSERT_VALUES_EQUAL(ttl.GetTiers().size(), 1);
UNIT_ASSERT_VALUES_EQUAL(ttl.GetTiers()[0].GetStorageName(), "tier1");
UNIT_ASSERT_VALUES_EQUAL(ttl.GetTiers()[0].GetEvictionDelay(), TDuration::Seconds(10));
auto ttl = desc.GetTableDescription().GetTtlSettings();
UNIT_ASSERT_VALUES_EQUAL(ttl->GetTiers().size(), 1);
UNIT_ASSERT_VALUES_EQUAL(std::get<TTtlEvictToExternalStorageAction>(ttl->GetTiers()[0].GetAction()).StorageName, "tier1");
UNIT_ASSERT_VALUES_EQUAL(ttl->GetTiers()[0].GetApplyAfter(), TDuration::Seconds(10));
}
auto query2 = TStringBuilder() << R"(
--!syntax_v1
Expand All @@ -5460,10 +5460,10 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
UNIT_ASSERT_C(desc.IsSuccess(), desc.GetIssues().ToString());

UNIT_ASSERT(desc.GetTableDescription().GetTtlSettings());
auto ttl = desc.GetTableDescription().GetTtlSettings()->GetDateTypeColumn();
UNIT_ASSERT_VALUES_EQUAL(ttl.GetTiers().size(), 1);
UNIT_ASSERT_VALUES_EQUAL(ttl.GetTiers()[0].GetStorageName(), "tier2");
UNIT_ASSERT_VALUES_EQUAL(ttl.GetTiers()[0].GetEvictionDelay(), TDuration::Seconds(10));
auto ttl = desc.GetTableDescription().GetTtlSettings();
UNIT_ASSERT_VALUES_EQUAL(ttl->GetTiers().size(), 1);
UNIT_ASSERT_VALUES_EQUAL(std::get<TTtlEvictToExternalStorageAction>(ttl->GetTiers()[0].GetAction()).StorageName, "tier2");
UNIT_ASSERT_VALUES_EQUAL(ttl->GetTiers()[0].GetApplyAfter(), TDuration::Seconds(10));
}

auto query3 = TStringBuilder() << R"(
Expand Down Expand Up @@ -5491,10 +5491,10 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
UNIT_ASSERT_C(desc.IsSuccess(), desc.GetIssues().ToString());

UNIT_ASSERT(desc.GetTableDescription().GetTtlSettings());
auto ttl = desc.GetTableDescription().GetTtlSettings()->GetDateTypeColumn();
UNIT_ASSERT_VALUES_EQUAL(ttl.GetTiers().size(), 1);
UNIT_ASSERT_VALUES_EQUAL(ttl.GetTiers()[0].GetStorageName(), "tier1");
UNIT_ASSERT_VALUES_EQUAL(ttl.GetTiers()[0].GetEvictionDelay(), TDuration::Seconds(10));
auto ttl = desc.GetTableDescription().GetTtlSettings();
UNIT_ASSERT_VALUES_EQUAL(ttl->GetTiers().size(), 1);
UNIT_ASSERT_VALUES_EQUAL(std::get<TTtlEvictToExternalStorageAction>(ttl->GetTiers()[0].GetAction()).StorageName, "tier1");
UNIT_ASSERT_VALUES_EQUAL(ttl->GetTiers()[0].GetApplyAfter(), TDuration::Seconds(10));
}

auto query5 = TStringBuilder() << R"(
Expand Down Expand Up @@ -8191,10 +8191,15 @@ Y_UNIT_TEST_SUITE(KqpOlapScheme) {

const auto& description = describeResult.GetTableDescription();
UNIT_ASSERT(describeResult.GetTableDescription().GetTtlSettings());
auto ttl = describeResult.GetTableDescription().GetTtlSettings()->GetDateTypeColumn();
UNIT_ASSERT_VALUES_EQUAL(ttl.GetExpireAfter(), TDuration::Hours(1));
UNIT_ASSERT_VALUES_EQUAL(ttl.GetTiers().size(), 1);
UNIT_ASSERT_VALUES_EQUAL(ttl.GetTiers()[0].GetStorageName(), "tier1");
auto ttl = describeResult.GetTableDescription().GetTtlSettings();
UNIT_ASSERT_VALUES_EQUAL(ttl->GetTiers().size(), 2);
auto evictTier = ttl->GetTiers()[0];
UNIT_ASSERT(std::holds_alternative<TTtlEvictToExternalStorageAction>(evictTier.GetAction()));
UNIT_ASSERT_VALUES_EQUAL(std::get<TTtlEvictToExternalStorageAction>(evictTier.GetAction()).StorageName, "tier1");
UNIT_ASSERT_VALUES_EQUAL(evictTier.GetApplyAfter(), TDuration::Seconds(10));
auto deleteTier = ttl->GetTiers()[1];
UNIT_ASSERT(std::holds_alternative<TTtlDeleteAction>(deleteTier.GetAction()));
UNIT_ASSERT_VALUES_EQUAL(deleteTier.GetApplyAfter(), TDuration::Hours(1));
}
{
auto alterQuery = TStringBuilder() << "ALTER TABLE `" << testTable.GetName() << R"(` RESET (TTL);)";
Expand Down
12 changes: 6 additions & 6 deletions ydb/public/sdk/cpp/client/ydb_table/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2912,12 +2912,12 @@ bool operator!=(const TChangefeedDescription& lhs, const TChangefeedDescription&
////////////////////////////////////////////////////////////////////////////////

TTtlTierSettings::TTtlTierSettings(TDuration evictionDelay, const TAction& action)
: EvictAfter_(evictionDelay)
: ApplyAfter_(evictionDelay)
, Action_(action) {
}

TTtlTierSettings::TTtlTierSettings(const Ydb::Table::TtlTier& tier)
: EvictAfter_(TDuration::Seconds(tier.apply_after_seconds())) {
: ApplyAfter_(TDuration::Seconds(tier.apply_after_seconds())) {
switch (tier.action_case()) {
case Ydb::Table::TtlTier::kDelete:
Action_ = TTtlDeleteAction();
Expand All @@ -2931,7 +2931,7 @@ TTtlTierSettings::TTtlTierSettings(const Ydb::Table::TtlTier& tier)
}

void TTtlTierSettings::SerializeTo(Ydb::Table::TtlTier& proto) const {
proto.set_apply_after_seconds(EvictAfter_.Seconds());
proto.set_apply_after_seconds(ApplyAfter_.Seconds());

std::visit(TOverloaded{
[&proto](const TTtlDeleteAction&) { proto.mutable_delete_(); },
Expand All @@ -2943,8 +2943,8 @@ void TTtlTierSettings::SerializeTo(Ydb::Table::TtlTier& proto) const {
Action_);
}

TDuration TTtlTierSettings::GetEvictAfter() const {
return EvictAfter_;
TDuration TTtlTierSettings::GetApplyAfter() const {
return ApplyAfter_;
}

const TTtlTierSettings::TAction& TTtlTierSettings::GetAction() const {
Expand Down Expand Up @@ -3145,7 +3145,7 @@ std::optional<TDuration> TTtlSettings::GetExpireAfter() const {
std::optional<TDuration> TTtlSettings::GetExpireAfterFrom(const TVector<TTtlTierSettings>& tiers) {
for (const auto& tier : tiers) {
if (std::holds_alternative<TTtlDeleteAction>(tier.GetAction())) {
return tier.GetEvictAfter();
return tier.GetApplyAfter();
}
}
return std::nullopt;
Expand Down
4 changes: 2 additions & 2 deletions ydb/public/sdk/cpp/client/ydb_table/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,11 @@ class TTtlTierSettings {
explicit TTtlTierSettings(const Ydb::Table::TtlTier& tier);
void SerializeTo(Ydb::Table::TtlTier& proto) const;

TDuration GetEvictAfter() const;
TDuration GetApplyAfter() const;
const TAction& GetAction() const;

private:
TDuration EvictAfter_;
TDuration ApplyAfter_;
TAction Action_;
};

Expand Down

0 comments on commit 3de0325

Please sign in to comment.