From 7918d7f4aa2db56cbd1a0d56824980b51e717039 Mon Sep 17 00:00:00 2001 From: Semyon Yentsov Date: Thu, 14 Nov 2024 15:00:26 +0000 Subject: [PATCH 1/2] parse TTL syntax with tiering on KQP --- ydb/core/kqp/provider/yql_kikimr_gateway.cpp | 30 +++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/ydb/core/kqp/provider/yql_kikimr_gateway.cpp b/ydb/core/kqp/provider/yql_kikimr_gateway.cpp index 03dc943126bb..0ef6459352e6 100644 --- a/ydb/core/kqp/provider/yql_kikimr_gateway.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_gateway.cpp @@ -101,7 +101,8 @@ bool TTtlSettings::TryParse(const NNodes::TCoNameValueTupleList& node, TTtlSetti if (name == "columnName") { YQL_ENSURE(field.Value().Maybe()); settings.ColumnName = field.Value().Cast().StringValue(); - } else if (name == "expireAfter") { + } else if (name == "expireAfter") { + // TODO (yentsovsemyon): remove this clause after extending TTL syntax in YQL YQL_ENSURE(field.Value().Maybe()); auto value = FromString(field.Value().Cast().Literal().Value()); if (value < 0) { @@ -110,6 +111,33 @@ bool TTtlSettings::TryParse(const NNodes::TCoNameValueTupleList& node, TTtlSetti } settings.ExpireAfter = TDuration::FromValue(value); + } else if (name == "tiers") { + YQL_ENSURE(field.Value().Maybe()); + auto listNode = field.Value().Cast(); + + for (size_t i = 0; i < listNode.Size(); ++i) { + auto tierNode = listNode.Item(i); + + YQL_ENSURE(tierNode.Maybe()); + for (const auto& tierField : tierNode.Cast()) { + auto tierFieldName = tierField.Name().Value(); + if (tierFieldName == "storageName") { + error = "TTL cannot contain tiered storage: tiering in TTL syntax is not supported"; + return false; + } else if (tierFieldName == "evictionDelay") { + YQL_ENSURE(tierField.Value().Maybe()); + auto value = FromString(tierField.Value().Cast().Literal().Value()); + if (value < 0) { + error = "Interval value cannot be negative"; + return false; + } + settings.ExpireAfter = TDuration::FromValue(value); + } else { + error = TStringBuilder() << "Unknown field: " << tierFieldName; + return false; + } + } + } } else if (name == "columnUnit") { YQL_ENSURE(field.Value().Maybe()); auto value = field.Value().Cast().StringValue(); From dfd030ed427802ba36b6bf6e1095506f6787473e Mon Sep 17 00:00:00 2001 From: Semyon Date: Thu, 14 Nov 2024 18:50:29 +0300 Subject: [PATCH 2/2] erase a space --- ydb/core/kqp/provider/yql_kikimr_gateway.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ydb/core/kqp/provider/yql_kikimr_gateway.cpp b/ydb/core/kqp/provider/yql_kikimr_gateway.cpp index 0ef6459352e6..77c94daf2096 100644 --- a/ydb/core/kqp/provider/yql_kikimr_gateway.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_gateway.cpp @@ -101,7 +101,7 @@ bool TTtlSettings::TryParse(const NNodes::TCoNameValueTupleList& node, TTtlSetti if (name == "columnName") { YQL_ENSURE(field.Value().Maybe()); settings.ColumnName = field.Value().Cast().StringValue(); - } else if (name == "expireAfter") { + } else if (name == "expireAfter") { // TODO (yentsovsemyon): remove this clause after extending TTL syntax in YQL YQL_ENSURE(field.Value().Maybe()); auto value = FromString(field.Value().Cast().Literal().Value());