Skip to content

Commit cd516c6

Browse files
committed
YQL-20068 backport mode
commit_hash:4ad0e146a3e92836d6aec7eaac00ae0225484b09
1 parent f6c2d16 commit cd516c6

File tree

8 files changed

+60
-5
lines changed

8 files changed

+60
-5
lines changed

yql/essentials/core/langver/yql_core_langver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bool CheckLangVersion(TLangVersion ver, TLangVersion max, TMaybe<TIssue>& issue)
2929
return false;
3030
}
3131

32-
if (!IsAvalableLangVersion(ver, max)) {
32+
if (!IsAvailableLangVersion(ver, max)) {
3333
TStringBuilder builder;
3434
builder << "YQL language version '";
3535
WriteVersion(builder, ver);

yql/essentials/core/type_ann/type_ann_core.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7626,7 +7626,10 @@ template <NKikimr::NUdf::EDataSlot DataSlot>
76267626
}
76277627

76287628
if (ctx.Types.LangVer != UnknownLangVersion) {
7629-
if (settingName == "minLang" && ctx.Types.LangVer < FromString<NYql::TLangVersion>(child->Tail().Content())) {
7629+
if (settingName == "minLang" && !IsBackwardCompatibleFeatureAvailable(
7630+
ctx.Types.LangVer,
7631+
FromString<NYql::TLangVersion>(child->Tail().Content()),
7632+
ctx.Types.BackportMode)) {
76307633
TLangVersionBuffer buffer;
76317634
TStringBuf str;
76327635
if (!FormatLangVersion(FromString<NYql::TLangVersion>(child->Tail().Content()), buffer, str)) {

yql/essentials/core/yql_type_annotation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ struct TTypeAnnotationContext: public TThrRefBase {
386386
TSimpleSharedPtr<NDq::TOrderingsStateMachine> SortingsFSM;
387387
TSimpleSharedPtr<NDq::TOrderingsStateMachine> OrderingsFSM;
388388
TLangVersion LangVer = MinLangVersion;
389+
EBackportCompatibleFeaturesMode BackportMode = EBackportCompatibleFeaturesMode::None;
389390
THashMap<TString, TIntrusivePtr<TOptimizerStatistics::TColumnStatMap>> ColumnStatisticsByTableName;
390391
THashMap<ui64, std::shared_ptr<TOptimizerStatistics>> StatisticsMap;
391392
TIntrusivePtr<ITimeProvider> TimeProvider;

yql/essentials/public/langver/ut/yql_langver_ut.cpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ Y_UNIT_TEST_SUITE(TLangVerTests) {
4848
}
4949

5050
Y_UNIT_TEST(Available) {
51-
UNIT_ASSERT(IsAvalableLangVersion(MakeLangVersion(2025,2),MakeLangVersion(2025,2)));
52-
UNIT_ASSERT(!IsAvalableLangVersion(MakeLangVersion(2025,3),MakeLangVersion(2025,2)));
51+
UNIT_ASSERT(IsAvailableLangVersion(MakeLangVersion(2025,2),MakeLangVersion(2025,2)));
52+
UNIT_ASSERT(!IsAvailableLangVersion(MakeLangVersion(2025,3),MakeLangVersion(2025,2)));
5353
}
5454

5555
Y_UNIT_TEST(MaxReleasedLangVersionIsValid) {
@@ -63,6 +63,33 @@ Y_UNIT_TEST_SUITE(TLangVerTests) {
6363
Y_UNIT_TEST(MaxVersionIsAboveThanReleased) {
6464
UNIT_ASSERT(GetMaxLangVersion() > GetMaxReleasedLangVersion());
6565
}
66+
67+
Y_UNIT_TEST(BackwardCompatibleFeatureAvailable_All) {
68+
UNIT_ASSERT(IsBackwardCompatibleFeatureAvailable(MinLangVersion, MinLangVersion,
69+
EBackportCompatibleFeaturesMode::All));
70+
UNIT_ASSERT(IsBackwardCompatibleFeatureAvailable(MinLangVersion, GetMaxReleasedLangVersion(),
71+
EBackportCompatibleFeaturesMode::All));
72+
UNIT_ASSERT(IsBackwardCompatibleFeatureAvailable(MinLangVersion, GetMaxLangVersion(),
73+
EBackportCompatibleFeaturesMode::All));
74+
}
75+
76+
Y_UNIT_TEST(BackwardCompatibleFeatureAvailable_Released) {
77+
UNIT_ASSERT(IsBackwardCompatibleFeatureAvailable(MinLangVersion, MinLangVersion,
78+
EBackportCompatibleFeaturesMode::Released));
79+
UNIT_ASSERT(IsBackwardCompatibleFeatureAvailable(MinLangVersion, GetMaxReleasedLangVersion(),
80+
EBackportCompatibleFeaturesMode::Released));
81+
UNIT_ASSERT(!IsBackwardCompatibleFeatureAvailable(MinLangVersion, GetMaxLangVersion(),
82+
EBackportCompatibleFeaturesMode::Released));
83+
}
84+
85+
Y_UNIT_TEST(BackwardCompatibleFeatureAvailable_None) {
86+
UNIT_ASSERT(IsBackwardCompatibleFeatureAvailable(MinLangVersion, MinLangVersion,
87+
EBackportCompatibleFeaturesMode::None));
88+
UNIT_ASSERT(!IsBackwardCompatibleFeatureAvailable(MinLangVersion, GetMaxReleasedLangVersion(),
89+
EBackportCompatibleFeaturesMode::None));
90+
UNIT_ASSERT(!IsBackwardCompatibleFeatureAvailable(MinLangVersion, GetMaxLangVersion(),
91+
EBackportCompatibleFeaturesMode::None));
92+
}
6693
}
6794

6895
}

yql/essentials/public/langver/ya.make

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ SRCS(
77
PEERDIR(
88
)
99

10+
GENERATE_ENUM_SERIALIZATION(yql_langver.h)
11+
1012
END()
1113

1214
RECURSE_FOR_TESTS(

yql/essentials/public/langver/yql_langver.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,16 @@ TLangVersion GetMaxLangVersion() {
8383
return max;
8484
}
8585

86+
bool IsBackwardCompatibleFeatureAvailable(TLangVersion currentVer, TLangVersion featureVer,
87+
EBackportCompatibleFeaturesMode mode) {
88+
switch (mode) {
89+
case EBackportCompatibleFeaturesMode::All:
90+
return true;
91+
case EBackportCompatibleFeaturesMode::Released:
92+
return IsAvailableLangVersion(featureVer, GetMaxReleasedLangVersion());
93+
case EBackportCompatibleFeaturesMode::None:
94+
return IsAvailableLangVersion(featureVer, currentVer);
95+
}
96+
}
97+
8698
}

yql/essentials/public/langver/yql_langver.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ constexpr inline ui32 GetMinorFromLangVersion(TLangVersion ver) {
2222
return ver % 100u;
2323
}
2424

25-
constexpr inline bool IsAvalableLangVersion(TLangVersion ver, TLangVersion max) {
25+
constexpr inline bool IsAvailableLangVersion(TLangVersion ver, TLangVersion max) {
2626
if (ver == UnknownLangVersion || max == UnknownLangVersion) {
2727
return true;
2828
}
@@ -58,4 +58,13 @@ bool IsValidLangVersion(TLangVersion ver);
5858
bool ParseLangVersion(TStringBuf str, TLangVersion& result);
5959
bool FormatLangVersion(TLangVersion ver, TLangVersionBuffer& buffer, TStringBuf& result);
6060

61+
enum class EBackportCompatibleFeaturesMode {
62+
None,
63+
Released,
64+
All
65+
};
66+
67+
bool IsBackwardCompatibleFeatureAvailable(TLangVersion currentVer, TLangVersion featureVer,
68+
EBackportCompatibleFeaturesMode mode);
69+
6170
}

yql/essentials/sql/settings/translation_settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ namespace NSQLTranslation {
7878
google::protobuf::Arena* Arena = nullptr;
7979

8080
NYql::TLangVersion LangVer = NYql::MinLangVersion;
81+
NYql::EBackportCompatibleFeaturesMode BackportMode = NYql::EBackportCompatibleFeaturesMode::None;
8182
THashMap<TString, TString> ClusterMapping;
8283
TString PathPrefix;
8384
// keys (cluster name) should be normalized

0 commit comments

Comments
 (0)