summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratarasov5 <[email protected]>2025-08-28 14:59:55 +0300
committeratarasov5 <[email protected]>2025-08-28 15:45:33 +0300
commit642fe48387994c15621318e16f98eac8d11a301c (patch)
treef362d0234fe8e4e263bc5b8ad64b12788a6b7039
parent81d828c32c8d5477cb2f0ce5da06a1a8d9392ca3 (diff)
YQL-20340: Fix getelem comp node
commit_hash:4b93115d4e3d46770946a7a462c7413d6183282f
-rw-r--r--yql/essentials/minikql/comp_nodes/mkql_element.cpp127
-rw-r--r--yql/essentials/tests/sql/minirun/part0/canondata/result.json28
-rw-r--r--yql/essentials/tests/sql/minirun/part2/canondata/result.json14
-rw-r--r--yql/essentials/tests/sql/minirun/part3/canondata/result.json14
-rw-r--r--yql/essentials/tests/sql/minirun/part4/canondata/result.json14
-rw-r--r--yql/essentials/tests/sql/minirun/part5/canondata/result.json14
-rw-r--r--yql/essentials/tests/sql/minirun/part7/canondata/result.json28
-rw-r--r--yql/essentials/tests/sql/sql2yql/canondata/result.json96
-rw-r--r--yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_optional_no_tagged_/formatted.sql25
-rw-r--r--yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_optional_no_tagged_no_cache_/formatted.sql45
-rw-r--r--yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_tagged_/formatted.sql28
-rw-r--r--yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_tagged_no_cache_/formatted.sql48
-rw-r--r--yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_/formatted.sql28
-rw-r--r--yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_no_cache_/formatted.sql48
-rw-r--r--yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_no_optional_/formatted.sql25
-rw-r--r--yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_no_optional_no_cache_/formatted.sql45
-rw-r--r--yql/essentials/tests/sql/suites/expr/nth_no_optional_no_tagged.yql25
-rw-r--r--yql/essentials/tests/sql/suites/expr/nth_no_optional_no_tagged_no_cache.yql45
-rw-r--r--yql/essentials/tests/sql/suites/expr/nth_no_tagged.yql28
-rw-r--r--yql/essentials/tests/sql/suites/expr/nth_no_tagged_no_cache.yql48
-rw-r--r--yql/essentials/tests/sql/suites/expr/tagged_nth.yql28
-rw-r--r--yql/essentials/tests/sql/suites/expr/tagged_nth_no_cache.yql49
-rw-r--r--yql/essentials/tests/sql/suites/expr/tagged_nth_no_optional.yql25
-rw-r--r--yql/essentials/tests/sql/suites/expr/tagged_nth_no_optional_no_cache.yql45
-rw-r--r--yt/yql/tests/sql/suites/expr/tagged_runtime.sql3
-rw-r--r--yt/yql/tests/sql/suites/expr/tagged_runtime_null.sql10
26 files changed, 909 insertions, 24 deletions
diff --git a/yql/essentials/minikql/comp_nodes/mkql_element.cpp b/yql/essentials/minikql/comp_nodes/mkql_element.cpp
index 58ab35d8037..c9013b98fc0 100644
--- a/yql/essentials/minikql/comp_nodes/mkql_element.cpp
+++ b/yql/essentials/minikql/comp_nodes/mkql_element.cpp
@@ -8,6 +8,46 @@ namespace NMiniKQL {
namespace {
+enum class EOptionalityHandlerStrategy {
+ // Just return child as is.
+ ReturnChildAsIs,
+ // Return child and add optionality to it.
+ AddOptionalToChild,
+ // Return child but set optionality to (tuple & child) intersection.
+ IntersectOptionals,
+};
+
+inline bool IsOptionalOrNull(const TType* type) {
+ return type->IsOptional() || type->IsNull() || type->IsPg();
+}
+
+// The strategy is based on tuple and its child optionality.
+// Tuple<X> -> return child as is (ReturnChildAsIs).
+// Tuple<X?> -> return child as is (ReturnChildAsIs).
+// Tuple<X>? -> return child and add extra optional level (AddOptionalToChild).
+// Tuple<X?>? -> return child as is BUT set mask to (tuple & child) intersection (IntersectOptionals).
+EOptionalityHandlerStrategy GetStrategyBasedOnTupleType(TType* tupleType, TType* elementType) {
+ if (!tupleType->IsOptional()) {
+ return EOptionalityHandlerStrategy::ReturnChildAsIs;
+ } else if (IsOptionalOrNull(elementType)) {
+ return EOptionalityHandlerStrategy::IntersectOptionals;
+ } else {
+ return EOptionalityHandlerStrategy::AddOptionalToChild;
+ }
+ Y_UNREACHABLE();
+}
+
+constexpr bool IsTupleOptional(EOptionalityHandlerStrategy strategy) {
+ switch (strategy) {
+ case EOptionalityHandlerStrategy::ReturnChildAsIs:
+ return false;
+ case EOptionalityHandlerStrategy::AddOptionalToChild:
+ case EOptionalityHandlerStrategy::IntersectOptionals:
+ return true;
+ }
+ Y_UNREACHABLE();
+}
+
template <bool IsOptional>
class TElementsWrapper : public TMutableCodegeneratorNode<TElementsWrapper<IsOptional>> {
typedef TMutableCodegeneratorNode<TElementsWrapper<IsOptional>> TBaseComputation;
@@ -64,9 +104,9 @@ private:
IComputationNode* const Array;
};
-template <bool IsOptional>
-class TElementWrapper : public TMutableCodegeneratorPtrNode<TElementWrapper<IsOptional>> {
- typedef TMutableCodegeneratorPtrNode<TElementWrapper<IsOptional>> TBaseComputation;
+template <EOptionalityHandlerStrategy Strategy>
+class TElementWrapper : public TMutableCodegeneratorPtrNode<TElementWrapper<Strategy>> {
+ typedef TMutableCodegeneratorPtrNode<TElementWrapper<Strategy>> TBaseComputation;
public:
TElementWrapper(TComputationMutables& mutables, EValueRepresentation kind, IComputationNode* cache, IComputationNode* array, ui32 index)
: TBaseComputation(mutables, kind), Cache(cache), Array(array), Index(index)
@@ -75,19 +115,33 @@ public:
NUdf::TUnboxedValue DoCalculate(TComputationContext& ctx) const {
if (Cache->GetDependencesCount() > 1U) {
const auto cache = Cache->GetValue(ctx);
- if (IsOptional && !cache) {
+ if (IsTupleOptional(Strategy) && !cache) {
return NUdf::TUnboxedValue();
}
- if (const auto elements = cache.Get<ui64>()) {
- return reinterpret_cast<const NUdf::TUnboxedValuePod*>(elements)[Index];
+ const auto elements = cache.Get<ui64>();
+ if (elements) {
+ auto element = reinterpret_cast<const NUdf::TUnboxedValuePod*>(elements)[Index];
+ if constexpr (Strategy == EOptionalityHandlerStrategy::IntersectOptionals) {
+ return element;
+ } else if constexpr (Strategy == EOptionalityHandlerStrategy::AddOptionalToChild) {
+ return element.MakeOptional();
+ } else if constexpr (Strategy == EOptionalityHandlerStrategy::ReturnChildAsIs) {
+ return element;
+ } else {
+ static_assert(false, "Unsupported type.");
+ }
}
}
const auto& array = Array->GetValue(ctx);
- if constexpr (IsOptional) {
+ if constexpr (Strategy == EOptionalityHandlerStrategy::IntersectOptionals) {
return array ? array.GetElement(Index) : NUdf::TUnboxedValue();
- } else {
+ } else if constexpr (Strategy == EOptionalityHandlerStrategy::AddOptionalToChild) {
+ return array ? NUdf::TUnboxedValue(array.GetElement(Index).MakeOptional()) : NUdf::TUnboxedValue();
+ } else if constexpr (Strategy == EOptionalityHandlerStrategy::ReturnChildAsIs) {
return array.GetElement(Index);
+ } else {
+ static_assert(false, "Unsupported type.");
}
}
@@ -95,9 +149,10 @@ public:
void DoGenerateGetElement(const TCodegenContext& ctx, Value* pointer, BasicBlock*& block) const {
auto& context = ctx.Codegen.GetContext();
+ const auto valueType = Type::getInt128Ty(context);
const auto array = GetNodeValue(Array, ctx, block);
const auto index = ConstantInt::get(Type::getInt32Ty(context), Index);
- if constexpr (IsOptional) {
+ if constexpr (IsTupleOptional(Strategy)) {
const auto good = BasicBlock::Create(context, "good", ctx.Func);
const auto zero = BasicBlock::Create(context, "zero", ctx.Func);
const auto exit = BasicBlock::Create(context, "exit", ctx.Func);
@@ -110,15 +165,21 @@ public:
block = good;
CallBoxedValueVirtualMethod<NUdf::TBoxedValueAccessor::EMethod::GetElement>(pointer, array, ctx.Codegen, block, index);
+ if constexpr (Strategy == EOptionalityHandlerStrategy::AddOptionalToChild) {
+ const auto load = new LoadInst(valueType, pointer, "load", block);
+ new StoreInst(MakeOptional(context, load, block), pointer, block);
+ }
if (Array->IsTemporaryValue())
CleanupBoxed(array, ctx, block);
BranchInst::Create(exit, block);
block = exit;
- } else {
+ } else if constexpr (Strategy == EOptionalityHandlerStrategy::ReturnChildAsIs){
CallBoxedValueVirtualMethod<NUdf::TBoxedValueAccessor::EMethod::GetElement>(pointer, array, ctx.Codegen, block, index);
if (Array->IsTemporaryValue())
CleanupBoxed(array, ctx, block);
+ } else {
+ static_assert(false, "Unhandled case.");
}
}
@@ -134,7 +195,7 @@ public:
const auto slow = BasicBlock::Create(context, "slow", ctx.Func);
const auto done = BasicBlock::Create(context, "done", ctx.Func);
- if constexpr (IsOptional) {
+ if constexpr (IsTupleOptional(Strategy)) {
const auto zero = ConstantInt::get(cache->getType(), 0ULL);
const auto check = CmpInst::Create(Instruction::ICmp, ICmpInst::ICMP_EQ, cache, zero, "check", block);
@@ -160,8 +221,14 @@ public:
const auto index = ConstantInt::get(Type::getInt32Ty(context), this->Index);
const auto ptr = GetElementPtrInst::CreateInBounds(cache->getType(), elements, {index}, "ptr", block);
const auto item = new LoadInst(cache->getType(), ptr, "item", block);
+
ValueAddRef(this->GetRepresentation(), item, ctx, block);
- new StoreInst(item, pointer, block);
+ if constexpr (Strategy == EOptionalityHandlerStrategy::AddOptionalToChild) {
+ new StoreInst(MakeOptional(context, item, block), pointer, block);
+ } else {
+ new StoreInst(item, pointer, block);
+ }
+
BranchInst::Create(done, block);
block = slow;
@@ -200,17 +267,19 @@ IComputationNode* WrapNth(TCallable& callable, const TComputationNodeFactoryCont
const auto indexData = AS_VALUE(TDataLiteral, callable.GetInput(1U));
const auto index = indexData->AsValue().Get<ui32>();
MKQL_ENSURE(index < tupleType->GetElementsCount(), "Bad tuple index");
-
+ auto nthStrategy = GetStrategyBasedOnTupleType(input.GetStaticType(), tupleType->GetElementType(index));
const auto tuple = LocateNode(ctx.NodeLocator, callable, 0);
const auto ins = ctx.ElementsCache.emplace(tuple, nullptr);
if (ins.second) {
ctx.NodePushBack(ins.first->second = WrapElements(tuple, ctx, isOptional));
}
-
- if (isOptional) {
- return new TElementWrapper<true>(ctx.Mutables, GetValueRepresentation(tupleType->GetElementType(index)), ins.first->second, tuple, index);
- } else {
- return new TElementWrapper<false>(ctx.Mutables, GetValueRepresentation(tupleType->GetElementType(index)), ins.first->second, tuple, index);
+ switch (nthStrategy) {
+ case EOptionalityHandlerStrategy::ReturnChildAsIs:
+ return new TElementWrapper<EOptionalityHandlerStrategy::ReturnChildAsIs>(ctx.Mutables, GetValueRepresentation(tupleType->GetElementType(index)), ins.first->second, tuple, index);
+ case EOptionalityHandlerStrategy::IntersectOptionals:
+ return new TElementWrapper<EOptionalityHandlerStrategy::IntersectOptionals>(ctx.Mutables, GetValueRepresentation(tupleType->GetElementType(index)), ins.first->second, tuple, index);
+ case EOptionalityHandlerStrategy::AddOptionalToChild:
+ return new TElementWrapper<EOptionalityHandlerStrategy::AddOptionalToChild>(ctx.Mutables, GetValueRepresentation(tupleType->GetElementType(index)), ins.first->second, tuple, index);
}
}
@@ -228,10 +297,24 @@ IComputationNode* WrapMember(TCallable& callable, const TComputationNodeFactoryC
if (ins.second) {
ctx.NodePushBack(ins.first->second = WrapElements(structObj, ctx, isOptional));
}
- if (isOptional) {
- return new TElementWrapper<true>(ctx.Mutables, GetValueRepresentation(structType->GetMemberType(index)), ins.first->second, structObj, index);
- } else {
- return new TElementWrapper<false>(ctx.Mutables, GetValueRepresentation(structType->GetMemberType(index)), ins.first->second, structObj, index);
+
+ auto nthStrategy = GetStrategyBasedOnTupleType(input.GetStaticType(), structType->GetMemberType(index));
+ switch (nthStrategy) {
+ case EOptionalityHandlerStrategy::ReturnChildAsIs:
+ return new TElementWrapper<EOptionalityHandlerStrategy::ReturnChildAsIs>(
+ ctx.Mutables,
+ GetValueRepresentation(structType->GetMemberType(index)),
+ ins.first->second, structObj, index);
+ case EOptionalityHandlerStrategy::AddOptionalToChild:
+ return new TElementWrapper<EOptionalityHandlerStrategy::AddOptionalToChild>(
+ ctx.Mutables,
+ GetValueRepresentation(structType->GetMemberType(index)),
+ ins.first->second, structObj, index);
+ case EOptionalityHandlerStrategy::IntersectOptionals:
+ return new TElementWrapper<EOptionalityHandlerStrategy::IntersectOptionals>(
+ ctx.Mutables,
+ GetValueRepresentation(structType->GetMemberType(index)),
+ ins.first->second, structObj, index);
}
}
diff --git a/yql/essentials/tests/sql/minirun/part0/canondata/result.json b/yql/essentials/tests/sql/minirun/part0/canondata/result.json
index 65b2e9e9175..861fc286679 100644
--- a/yql/essentials/tests/sql/minirun/part0/canondata/result.json
+++ b/yql/essentials/tests/sql/minirun/part0/canondata/result.json
@@ -670,6 +670,34 @@
"uri": "https://{canondata_backend}/1942525/ede9d81525f3cde3c09402fe9435fdbba85f47bc/resource.tar.gz#test.test_expr-struct_literal--Results_/results.txt"
}
],
+ "test.test[expr-tagged_nth-default.txt-Debug]": [
+ {
+ "checksum": "5cfca1323b5db6c402d15491eefdd536",
+ "size": 924,
+ "uri": "https://{canondata_backend}/1817427/71c69e0489dfa612a57e6a73d889c47617e888f9/resource.tar.gz#test.test_expr-tagged_nth-default.txt-Debug_/opt.yql"
+ }
+ ],
+ "test.test[expr-tagged_nth-default.txt-Results]": [
+ {
+ "checksum": "12a7de262fad1f40459870da4d5d6083",
+ "size": 4332,
+ "uri": "https://{canondata_backend}/1775059/9c09d1b7ca039bad9f375e5e993bbd259f8d98bc/resource.tar.gz#test.test_expr-tagged_nth-default.txt-Results_/results.txt"
+ }
+ ],
+ "test.test[expr-tagged_nth_no_optional-default.txt-Debug]": [
+ {
+ "checksum": "c464d8859c092fdfc7ecfb7bec190d2a",
+ "size": 724,
+ "uri": "https://{canondata_backend}/1817427/71c69e0489dfa612a57e6a73d889c47617e888f9/resource.tar.gz#test.test_expr-tagged_nth_no_optional-default.txt-Debug_/opt.yql"
+ }
+ ],
+ "test.test[expr-tagged_nth_no_optional-default.txt-Results]": [
+ {
+ "checksum": "dcf899a35be34f9dcba93487513bc819",
+ "size": 3081,
+ "uri": "https://{canondata_backend}/1775059/9c09d1b7ca039bad9f375e5e993bbd259f8d98bc/resource.tar.gz#test.test_expr-tagged_nth_no_optional-default.txt-Results_/results.txt"
+ }
+ ],
"test.test[expr-to_hashed_dict_tuple_key-default.txt-Debug]": [
{
"checksum": "f0cf1545022f8f237a44d99aaf7b0e7c",
diff --git a/yql/essentials/tests/sql/minirun/part2/canondata/result.json b/yql/essentials/tests/sql/minirun/part2/canondata/result.json
index bcfbc3c1fdd..7ff7cd2f25d 100644
--- a/yql/essentials/tests/sql/minirun/part2/canondata/result.json
+++ b/yql/essentials/tests/sql/minirun/part2/canondata/result.json
@@ -681,6 +681,20 @@
"uri": "https://{canondata_backend}/1946324/e7201814e6e6593b8222695568ac22e9db8f99bc/resource.tar.gz#test.test_expr-longint_builtins-default.txt-Results_/results.txt"
}
],
+ "test.test[expr-nth_no_tagged_no_cache-default.txt-Debug]": [
+ {
+ "checksum": "3a01e0ed4889c9e3359e70a4fbab6918",
+ "size": 1150,
+ "uri": "https://{canondata_backend}/1814674/efe8c7ac8f2ea327318cb7a3ddfef73523f9ca53/resource.tar.gz#test.test_expr-nth_no_tagged_no_cache-default.txt-Debug_/opt.yql"
+ }
+ ],
+ "test.test[expr-nth_no_tagged_no_cache-default.txt-Results]": [
+ {
+ "checksum": "2255f4b90375f9348060f9605926c2c3",
+ "size": 4329,
+ "uri": "https://{canondata_backend}/1814674/efe8c7ac8f2ea327318cb7a3ddfef73523f9ca53/resource.tar.gz#test.test_expr-nth_no_tagged_no_cache-default.txt-Results_/results.txt"
+ }
+ ],
"test.test[expr-partial_columns_in_mem_aggr-default.txt-Debug]": [
{
"checksum": "f6b313886299912210c39d23bbc3c44b",
diff --git a/yql/essentials/tests/sql/minirun/part3/canondata/result.json b/yql/essentials/tests/sql/minirun/part3/canondata/result.json
index 255e1ee8db5..1374b8323ee 100644
--- a/yql/essentials/tests/sql/minirun/part3/canondata/result.json
+++ b/yql/essentials/tests/sql/minirun/part3/canondata/result.json
@@ -561,6 +561,20 @@
"uri": "https://{canondata_backend}/1942671/d3336f0bb6dbe9e9fd1f3cf5e74ebe4602d13132/resource.tar.gz#test.test_expr-list_from_range-default.txt-Results_/results.txt"
}
],
+ "test.test[expr-nth_no_optional_no_tagged_no_cache-default.txt-Debug]": [
+ {
+ "checksum": "1aa9af53a28b769543e515e500c6c797",
+ "size": 1036,
+ "uri": "https://{canondata_backend}/1942173/4d031afb3e8d48927da6c14d5eb6c4d18097c5f4/resource.tar.gz#test.test_expr-nth_no_optional_no_tagged_no_cache-default.txt-Debug_/opt.yql"
+ }
+ ],
+ "test.test[expr-nth_no_optional_no_tagged_no_cache-default.txt-Results]": [
+ {
+ "checksum": "70128e5a26530fdd99dbf079173a4b35",
+ "size": 3782,
+ "uri": "https://{canondata_backend}/1942173/4d031afb3e8d48927da6c14d5eb6c4d18097c5f4/resource.tar.gz#test.test_expr-nth_no_optional_no_tagged_no_cache-default.txt-Results_/results.txt"
+ }
+ ],
"test.test[expr-opt_list_map-default.txt-Debug]": [
{
"checksum": "5aed4a678e424baaa9f7fba738a457ff",
diff --git a/yql/essentials/tests/sql/minirun/part4/canondata/result.json b/yql/essentials/tests/sql/minirun/part4/canondata/result.json
index 860fc33ae76..de4f5eeeb08 100644
--- a/yql/essentials/tests/sql/minirun/part4/canondata/result.json
+++ b/yql/essentials/tests/sql/minirun/part4/canondata/result.json
@@ -636,6 +636,20 @@
"uri": "https://{canondata_backend}/1942671/f9fe8b5ff2967f43b60e0f5b3fa5c2c4eff69207/resource.tar.gz#test.test_expr-list_top_sort-default.txt-Results_/results.txt"
}
],
+ "test.test[expr-nth_no_tagged-default.txt-Debug]": [
+ {
+ "checksum": "2c4ad1d970316f96ebc28632ab698bee",
+ "size": 754,
+ "uri": "https://{canondata_backend}/1817427/efdcc8940db1bbb79de10bdec85748b9b022445e/resource.tar.gz#test.test_expr-nth_no_tagged-default.txt-Debug_/opt.yql"
+ }
+ ],
+ "test.test[expr-nth_no_tagged-default.txt-Results]": [
+ {
+ "checksum": "a6bb73c2dd1a49393d3b4b3e5b42f2f0",
+ "size": 2553,
+ "uri": "https://{canondata_backend}/1925842/421e1f73672cfe3018278a1db28d854870c0151d/resource.tar.gz#test.test_expr-nth_no_tagged-default.txt-Results_/results.txt"
+ }
+ ],
"test.test[expr-table_path-default.txt-Debug]": [
{
"checksum": "390c0d1fae8cdf69553f72184fc15801",
diff --git a/yql/essentials/tests/sql/minirun/part5/canondata/result.json b/yql/essentials/tests/sql/minirun/part5/canondata/result.json
index 04dfb913bfe..011770fbbfd 100644
--- a/yql/essentials/tests/sql/minirun/part5/canondata/result.json
+++ b/yql/essentials/tests/sql/minirun/part5/canondata/result.json
@@ -943,6 +943,20 @@
"uri": "file://test.test_expr-list_flat_map_deprecated_opt-default.txt-Results_/extracted"
}
],
+ "test.test[expr-nth_no_optional_no_tagged-default.txt-Debug]": [
+ {
+ "checksum": "906aa3574e44e5c27a0d9c18e7c2e1db",
+ "size": 644,
+ "uri": "https://{canondata_backend}/1817427/2dc878bbecb1d83cab619d3beae95487eda85171/resource.tar.gz#test.test_expr-nth_no_optional_no_tagged-default.txt-Debug_/opt.yql"
+ }
+ ],
+ "test.test[expr-nth_no_optional_no_tagged-default.txt-Results]": [
+ {
+ "checksum": "295a6801944097dc841de77aafed57e1",
+ "size": 2182,
+ "uri": "https://{canondata_backend}/1775059/86ecd2107b9bc58125a7e8e8ec2bba0d1ab4dae8/resource.tar.gz#test.test_expr-nth_no_optional_no_tagged-default.txt-Results_/results.txt"
+ }
+ ],
"test.test[expr-struct_builtins-default.txt-Debug]": [
{
"checksum": "46958300093332035cd00204e3c0d29f",
diff --git a/yql/essentials/tests/sql/minirun/part7/canondata/result.json b/yql/essentials/tests/sql/minirun/part7/canondata/result.json
index 061272da90f..9acd8da8d20 100644
--- a/yql/essentials/tests/sql/minirun/part7/canondata/result.json
+++ b/yql/essentials/tests/sql/minirun/part7/canondata/result.json
@@ -569,6 +569,34 @@
"uri": "https://{canondata_backend}/1942525/5b75160303fccf854ef8bcd60aae18ec7c47ceda/resource.tar.gz#test.test_expr-struct_slice-default.txt-Results_/results.txt"
}
],
+ "test.test[expr-tagged_nth_no_cache-default.txt-Debug]": [
+ {
+ "checksum": "6a942f415a1c17abec5997d0e2bc9a1b",
+ "size": 1320,
+ "uri": "https://{canondata_backend}/1814674/0fd635549c290a101879f0575638429cb3c65923/resource.tar.gz#test.test_expr-tagged_nth_no_cache-default.txt-Debug_/opt.yql"
+ }
+ ],
+ "test.test[expr-tagged_nth_no_cache-default.txt-Results]": [
+ {
+ "checksum": "2721519b95805a4ee69143b2629825aa",
+ "size": 6108,
+ "uri": "https://{canondata_backend}/1814674/0fd635549c290a101879f0575638429cb3c65923/resource.tar.gz#test.test_expr-tagged_nth_no_cache-default.txt-Results_/results.txt"
+ }
+ ],
+ "test.test[expr-tagged_nth_no_optional_no_cache-default.txt-Debug]": [
+ {
+ "checksum": "3658a9b32a026300586d7d70ccdb24d8",
+ "size": 1116,
+ "uri": "https://{canondata_backend}/1814674/0fd635549c290a101879f0575638429cb3c65923/resource.tar.gz#test.test_expr-tagged_nth_no_optional_no_cache-default.txt-Debug_/opt.yql"
+ }
+ ],
+ "test.test[expr-tagged_nth_no_optional_no_cache-default.txt-Results]": [
+ {
+ "checksum": "1b04197e3e8e4296edcf805c0daa42df",
+ "size": 4681,
+ "uri": "https://{canondata_backend}/1814674/0fd635549c290a101879f0575638429cb3c65923/resource.tar.gz#test.test_expr-tagged_nth_no_optional_no_cache-default.txt-Results_/results.txt"
+ }
+ ],
"test.test[expr-uuid-default.txt-Debug]": [
{
"checksum": "c7b5816b36ef8c082dad802bab80b466",
diff --git a/yql/essentials/tests/sql/sql2yql/canondata/result.json b/yql/essentials/tests/sql/sql2yql/canondata/result.json
index 7710d0c54b8..e5f020fc976 100644
--- a/yql/essentials/tests/sql/sql2yql/canondata/result.json
+++ b/yql/essentials/tests/sql/sql2yql/canondata/result.json
@@ -3394,6 +3394,34 @@
"uri": "https://{canondata_backend}/1942173/99e88108149e222741552e7e6cddef041d6a2846/resource.tar.gz#test_sql2yql.test_expr-minmax_for_complex_types_/sql.yql"
}
],
+ "test_sql2yql.test[expr-nth_no_optional_no_tagged]": [
+ {
+ "checksum": "36232aa724068d894eeca9410ed12929",
+ "size": 2106,
+ "uri": "https://{canondata_backend}/1784826/00cd6cd2ba7605aef48f862f0ad2c01f28cb09a0/resource.tar.gz#test_sql2yql.test_expr-nth_no_optional_no_tagged_/sql.yql"
+ }
+ ],
+ "test_sql2yql.test[expr-nth_no_optional_no_tagged_no_cache]": [
+ {
+ "checksum": "9458795820ac9991b7a29c0b6f321332",
+ "size": 4594,
+ "uri": "https://{canondata_backend}/1880306/ceb9f028cc97a068c8b4060a3d97985d50af7310/resource.tar.gz#test_sql2yql.test_expr-nth_no_optional_no_tagged_no_cache_/sql.yql"
+ }
+ ],
+ "test_sql2yql.test[expr-nth_no_tagged]": [
+ {
+ "checksum": "2f8a7a89dfa82ce26e4cd0be03fa57f1",
+ "size": 2139,
+ "uri": "https://{canondata_backend}/1784826/00cd6cd2ba7605aef48f862f0ad2c01f28cb09a0/resource.tar.gz#test_sql2yql.test_expr-nth_no_tagged_/sql.yql"
+ }
+ ],
+ "test_sql2yql.test[expr-nth_no_tagged_no_cache]": [
+ {
+ "checksum": "bcc91b82a8c0d29fc1c832895d5a0be0",
+ "size": 4627,
+ "uri": "https://{canondata_backend}/1880306/ceb9f028cc97a068c8b4060a3d97985d50af7310/resource.tar.gz#test_sql2yql.test_expr-nth_no_tagged_no_cache_/sql.yql"
+ }
+ ],
"test_sql2yql.test[expr-opt_list_map]": [
{
"checksum": "cbe8c7680e62a2d67eaa35c727e9895e",
@@ -3534,6 +3562,34 @@
"uri": "https://{canondata_backend}/1923547/26d32eb789592629a387bffbe3c29af93fc60786/resource.tar.gz#test_sql2yql.test_expr-tablename_/sql.yql"
}
],
+ "test_sql2yql.test[expr-tagged_nth]": [
+ {
+ "checksum": "5880af1da4ebf2cf9a0bf32565bbaf41",
+ "size": 2219,
+ "uri": "https://{canondata_backend}/1784826/00cd6cd2ba7605aef48f862f0ad2c01f28cb09a0/resource.tar.gz#test_sql2yql.test_expr-tagged_nth_/sql.yql"
+ }
+ ],
+ "test_sql2yql.test[expr-tagged_nth_no_cache]": [
+ {
+ "checksum": "77bf5801970db30bf78bdae7353dc6b6",
+ "size": 4707,
+ "uri": "https://{canondata_backend}/1880306/ceb9f028cc97a068c8b4060a3d97985d50af7310/resource.tar.gz#test_sql2yql.test_expr-tagged_nth_no_cache_/sql.yql"
+ }
+ ],
+ "test_sql2yql.test[expr-tagged_nth_no_optional]": [
+ {
+ "checksum": "d6e13d2443925261e815f63f98a1816b",
+ "size": 2186,
+ "uri": "https://{canondata_backend}/1784826/00cd6cd2ba7605aef48f862f0ad2c01f28cb09a0/resource.tar.gz#test_sql2yql.test_expr-tagged_nth_no_optional_/sql.yql"
+ }
+ ],
+ "test_sql2yql.test[expr-tagged_nth_no_optional_no_cache]": [
+ {
+ "checksum": "23eca92c148f9e2f55012169bff06ab9",
+ "size": 4674,
+ "uri": "https://{canondata_backend}/1880306/ceb9f028cc97a068c8b4060a3d97985d50af7310/resource.tar.gz#test_sql2yql.test_expr-tagged_nth_no_optional_no_cache_/sql.yql"
+ }
+ ],
"test_sql2yql.test[expr-to_dict_from_nothing]": [
{
"checksum": "f8aa8ee9953a55c7169e04fca1c319c3",
@@ -10502,6 +10558,26 @@
"uri": "file://test_sql_format.test_expr-minmax_for_complex_types_/formatted.sql"
}
],
+ "test_sql_format.test[expr-nth_no_optional_no_tagged]": [
+ {
+ "uri": "file://test_sql_format.test_expr-nth_no_optional_no_tagged_/formatted.sql"
+ }
+ ],
+ "test_sql_format.test[expr-nth_no_optional_no_tagged_no_cache]": [
+ {
+ "uri": "file://test_sql_format.test_expr-nth_no_optional_no_tagged_no_cache_/formatted.sql"
+ }
+ ],
+ "test_sql_format.test[expr-nth_no_tagged]": [
+ {
+ "uri": "file://test_sql_format.test_expr-nth_no_tagged_/formatted.sql"
+ }
+ ],
+ "test_sql_format.test[expr-nth_no_tagged_no_cache]": [
+ {
+ "uri": "file://test_sql_format.test_expr-nth_no_tagged_no_cache_/formatted.sql"
+ }
+ ],
"test_sql_format.test[expr-opt_list_map]": [
{
"uri": "file://test_sql_format.test_expr-opt_list_map_/formatted.sql"
@@ -10602,6 +10678,26 @@
"uri": "file://test_sql_format.test_expr-tablename_/formatted.sql"
}
],
+ "test_sql_format.test[expr-tagged_nth]": [
+ {
+ "uri": "file://test_sql_format.test_expr-tagged_nth_/formatted.sql"
+ }
+ ],
+ "test_sql_format.test[expr-tagged_nth_no_cache]": [
+ {
+ "uri": "file://test_sql_format.test_expr-tagged_nth_no_cache_/formatted.sql"
+ }
+ ],
+ "test_sql_format.test[expr-tagged_nth_no_optional]": [
+ {
+ "uri": "file://test_sql_format.test_expr-tagged_nth_no_optional_/formatted.sql"
+ }
+ ],
+ "test_sql_format.test[expr-tagged_nth_no_optional_no_cache]": [
+ {
+ "uri": "file://test_sql_format.test_expr-tagged_nth_no_optional_no_cache_/formatted.sql"
+ }
+ ],
"test_sql_format.test[expr-to_dict_from_nothing]": [
{
"uri": "file://test_sql_format.test_expr-to_dict_from_nothing_/formatted.sql"
diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_optional_no_tagged_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_optional_no_tagged_/formatted.sql
new file mode 100644
index 00000000000..a3b290439c6
--- /dev/null
+++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_optional_no_tagged_/formatted.sql
@@ -0,0 +1,25 @@
+/* postgres can not */
+PRAGMA EmitAggApply;
+PRAGMA EmitTableSource;
+
+$data = [
+ <|
+ x: (
+ 1,
+ just(2),
+ NULL,
+ Nothing(Int32?),
+ Nothing(pgint4)
+ )
+ |>
+];
+
+SELECT
+ x.0,
+ x.1,
+ x.2,
+ x.3,
+ x.4
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_optional_no_tagged_no_cache_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_optional_no_tagged_no_cache_/formatted.sql
new file mode 100644
index 00000000000..e490268ee27
--- /dev/null
+++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_optional_no_tagged_no_cache_/formatted.sql
@@ -0,0 +1,45 @@
+/* postgres can not */
+PRAGMA EmitAggApply;
+PRAGMA EmitTableSource;
+
+$data = [
+ <|
+ x: (
+ 1,
+ just(2),
+ NULL,
+ Nothing(Int32?),
+ Nothing(pgint4)
+ )
+ |>
+];
+
+SELECT
+ x.0,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.1,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.2,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.3,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.4,
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_tagged_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_tagged_/formatted.sql
new file mode 100644
index 00000000000..36e30098b80
--- /dev/null
+++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_tagged_/formatted.sql
@@ -0,0 +1,28 @@
+/* postgres can not */
+PRAGMA EmitAggApply;
+PRAGMA EmitTableSource;
+
+$data = [
+ <|
+ x: Just(
+ (
+ 1,
+ just(2),
+ NULL,
+ Nothing(Int32?),
+ Nothing(pgint4)
+ )
+ )
+ |>,
+ <|x: NULL|>
+];
+
+SELECT
+ x.0,
+ x.1,
+ x.2,
+ x.3,
+ x.4
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_tagged_no_cache_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_tagged_no_cache_/formatted.sql
new file mode 100644
index 00000000000..0b645e0ac77
--- /dev/null
+++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-nth_no_tagged_no_cache_/formatted.sql
@@ -0,0 +1,48 @@
+/* postgres can not */
+PRAGMA EmitAggApply;
+PRAGMA EmitTableSource;
+
+$data = [
+ <|
+ x: Just(
+ (
+ 1,
+ just(2),
+ NULL,
+ Nothing(Int32?),
+ Nothing(pgint4)
+ )
+ )
+ |>,
+ <|x: NULL|>
+];
+
+SELECT
+ x.0,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.1,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.2,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.3,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.4,
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_/formatted.sql
new file mode 100644
index 00000000000..8d7eebd72e4
--- /dev/null
+++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_/formatted.sql
@@ -0,0 +1,28 @@
+/* postgres can not */
+PRAGMA EmitAggApply;
+PRAGMA EmitTableSource;
+
+$data = [
+ <|
+ x: Just(
+ (
+ AsTagged(1, 'A'),
+ AsTagged(just(2), 'B'),
+ AsTagged(NULL, 'C'),
+ AsTagged(Nothing(Int32?), 'D'),
+ AsTagged(Nothing(pgint4), 'E')
+ )
+ )
+ |>,
+ <|x: NULL|>
+];
+
+SELECT
+ x.0,
+ x.1,
+ x.2,
+ x.3,
+ x.4
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_no_cache_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_no_cache_/formatted.sql
new file mode 100644
index 00000000000..83e9e501e47
--- /dev/null
+++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_no_cache_/formatted.sql
@@ -0,0 +1,48 @@
+/* postgres can not */
+PRAGMA EmitAggApply;
+PRAGMA EmitTableSource;
+
+$data = [
+ <|
+ x: Just(
+ (
+ AsTagged(1, 'A'),
+ AsTagged(just(2), 'B'),
+ AsTagged(NULL, 'C'),
+ AsTagged(Nothing(Int32?), 'D'),
+ AsTagged(Nothing(pgint4), 'E')
+ )
+ )
+ |>,
+ <|x: NULL|>
+];
+
+SELECT
+ x.0,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.1,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.2,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.3,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.4,
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_no_optional_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_no_optional_/formatted.sql
new file mode 100644
index 00000000000..177c0737d74
--- /dev/null
+++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_no_optional_/formatted.sql
@@ -0,0 +1,25 @@
+/* postgres can not */
+PRAGMA EmitAggApply;
+PRAGMA EmitTableSource;
+
+$data = [
+ <|
+ x: (
+ AsTagged(1, 'A'),
+ AsTagged(just(2), 'B'),
+ AsTagged(NULL, 'C'),
+ AsTagged(Nothing(Int32?), 'D'),
+ AsTagged(Nothing(pgint4), 'E')
+ )
+ |>
+];
+
+SELECT
+ x.0,
+ x.1,
+ x.2,
+ x.3,
+ x.4
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_no_optional_no_cache_/formatted.sql b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_no_optional_no_cache_/formatted.sql
new file mode 100644
index 00000000000..2fb520082de
--- /dev/null
+++ b/yql/essentials/tests/sql/sql2yql/canondata/test_sql_format.test_expr-tagged_nth_no_optional_no_cache_/formatted.sql
@@ -0,0 +1,45 @@
+/* postgres can not */
+PRAGMA EmitAggApply;
+PRAGMA EmitTableSource;
+
+$data = [
+ <|
+ x: (
+ AsTagged(1, 'A'),
+ AsTagged(just(2), 'B'),
+ AsTagged(NULL, 'C'),
+ AsTagged(Nothing(Int32?), 'D'),
+ AsTagged(Nothing(pgint4), 'E')
+ )
+ |>
+];
+
+SELECT
+ x.0,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.1,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.2,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.3,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.4,
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/suites/expr/nth_no_optional_no_tagged.yql b/yql/essentials/tests/sql/suites/expr/nth_no_optional_no_tagged.yql
new file mode 100644
index 00000000000..a41c326b395
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/expr/nth_no_optional_no_tagged.yql
@@ -0,0 +1,25 @@
+/* postgres can not */
+pragma EmitAggApply;
+pragma EmitTableSource;
+
+$data = [
+ <|
+ x: (
+ 1,
+ just(2),
+ NULL,
+ Nothing(Int32?),
+ Nothing(pgint4)
+ )
+ |>
+];
+
+SELECT
+ x.0,
+ x.1,
+ x.2,
+ x.3,
+ x.4
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/suites/expr/nth_no_optional_no_tagged_no_cache.yql b/yql/essentials/tests/sql/suites/expr/nth_no_optional_no_tagged_no_cache.yql
new file mode 100644
index 00000000000..6854c668c55
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/expr/nth_no_optional_no_tagged_no_cache.yql
@@ -0,0 +1,45 @@
+/* postgres can not */
+pragma EmitAggApply;
+pragma EmitTableSource;
+
+$data = [
+ <|
+ x: (
+ 1,
+ just(2),
+ NULL,
+ Nothing(Int32?),
+ Nothing(pgint4)
+ )
+ |>
+];
+
+SELECT
+ x.0,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.1,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.2,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.3,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.4,
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/suites/expr/nth_no_tagged.yql b/yql/essentials/tests/sql/suites/expr/nth_no_tagged.yql
new file mode 100644
index 00000000000..3f3137b6f28
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/expr/nth_no_tagged.yql
@@ -0,0 +1,28 @@
+/* postgres can not */
+pragma EmitAggApply;
+pragma EmitTableSource;
+
+$data = [
+ <|
+ x: Just(
+ (
+ 1,
+ just(2),
+ NULL,
+ Nothing(Int32?),
+ Nothing(pgint4)
+ )
+ )
+ |>,
+ <|x: NULL|>
+];
+
+SELECT
+ x.0,
+ x.1,
+ x.2,
+ x.3,
+ x.4
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/suites/expr/nth_no_tagged_no_cache.yql b/yql/essentials/tests/sql/suites/expr/nth_no_tagged_no_cache.yql
new file mode 100644
index 00000000000..ede2ce839ae
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/expr/nth_no_tagged_no_cache.yql
@@ -0,0 +1,48 @@
+/* postgres can not */
+pragma EmitAggApply;
+pragma EmitTableSource;
+
+$data = [
+ <|
+ x: Just(
+ (
+ 1,
+ just(2),
+ NULL,
+ Nothing(Int32?),
+ Nothing(pgint4)
+ )
+ )
+ |>,
+ <|x: NULL|>
+];
+
+SELECT
+ x.0,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.1,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.2,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.3,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.4,
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/suites/expr/tagged_nth.yql b/yql/essentials/tests/sql/suites/expr/tagged_nth.yql
new file mode 100644
index 00000000000..ab05dc9b0cb
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/expr/tagged_nth.yql
@@ -0,0 +1,28 @@
+/* postgres can not */
+pragma EmitAggApply;
+pragma EmitTableSource;
+
+$data = [
+ <|
+ x: Just(
+ (
+ AsTagged(1, 'A'),
+ AsTagged(just(2), 'B'),
+ AsTagged(NULL, 'C'),
+ AsTagged(Nothing(Int32?), 'D'),
+ AsTagged(Nothing(pgint4), 'E')
+ )
+ )
+ |>,
+ <|x: NULL|>
+];
+
+SELECT
+ x.0,
+ x.1,
+ x.2,
+ x.3,
+ x.4
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/suites/expr/tagged_nth_no_cache.yql b/yql/essentials/tests/sql/suites/expr/tagged_nth_no_cache.yql
new file mode 100644
index 00000000000..0e7b8185e5d
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/expr/tagged_nth_no_cache.yql
@@ -0,0 +1,49 @@
+/* postgres can not */
+pragma EmitAggApply;
+pragma EmitTableSource;
+
+$data = [
+ <|
+ x: Just(
+ (
+ AsTagged(1, 'A'),
+ AsTagged(just(2), 'B'),
+ AsTagged(NULL, 'C'),
+ AsTagged(Nothing(Int32?), 'D'),
+ AsTagged(Nothing(pgint4), 'E')
+ )
+ )
+ |>,
+ <|x: NULL|>
+];
+
+SELECT
+ x.0,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.1,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.2,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.3,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.4,
+FROM
+ AS_TABLE($data)
+;
+
diff --git a/yql/essentials/tests/sql/suites/expr/tagged_nth_no_optional.yql b/yql/essentials/tests/sql/suites/expr/tagged_nth_no_optional.yql
new file mode 100644
index 00000000000..678d6b2e44f
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/expr/tagged_nth_no_optional.yql
@@ -0,0 +1,25 @@
+/* postgres can not */
+pragma EmitAggApply;
+pragma EmitTableSource;
+
+$data = [
+ <|
+ x: (
+ AsTagged(1, 'A'),
+ AsTagged(just(2), 'B'),
+ AsTagged(NULL, 'C'),
+ AsTagged(Nothing(Int32?), 'D'),
+ AsTagged(Nothing(pgint4), 'E')
+ )
+ |>
+];
+
+SELECT
+ x.0,
+ x.1,
+ x.2,
+ x.3,
+ x.4
+FROM
+ AS_TABLE($data)
+;
diff --git a/yql/essentials/tests/sql/suites/expr/tagged_nth_no_optional_no_cache.yql b/yql/essentials/tests/sql/suites/expr/tagged_nth_no_optional_no_cache.yql
new file mode 100644
index 00000000000..cb0e7470e5b
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/expr/tagged_nth_no_optional_no_cache.yql
@@ -0,0 +1,45 @@
+/* postgres can not */
+pragma EmitAggApply;
+pragma EmitTableSource;
+
+$data = [
+ <|
+ x: (
+ AsTagged(1, 'A'),
+ AsTagged(just(2), 'B'),
+ AsTagged(NULL, 'C'),
+ AsTagged(Nothing(Int32?), 'D'),
+ AsTagged(Nothing(pgint4), 'E')
+ )
+ |>
+];
+
+SELECT
+ x.0,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.1,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.2,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.3,
+FROM
+ AS_TABLE($data)
+;
+
+SELECT
+ x.4,
+FROM
+ AS_TABLE($data)
+;
diff --git a/yt/yql/tests/sql/suites/expr/tagged_runtime.sql b/yt/yql/tests/sql/suites/expr/tagged_runtime.sql
index 8d185b767e2..0985a81cfc1 100644
--- a/yt/yql/tests/sql/suites/expr/tagged_runtime.sql
+++ b/yt/yql/tests/sql/suites/expr/tagged_runtime.sql
@@ -4,9 +4,8 @@ insert into @tmp
select Just((
AsTagged(1,"A"),
AsTagged(just(2),"B"),
- AsTagged(null,"C"),
AsTagged(Nothing(Int32?),"D"),
AsTagged(Nothing(pgint4?),"E")
)) as x;
commit;
-select x.0, x.1, x.2, x.3, x.4 from @tmp
+select x.0, x.1, x.2, x.3 from @tmp
diff --git a/yt/yql/tests/sql/suites/expr/tagged_runtime_null.sql b/yt/yql/tests/sql/suites/expr/tagged_runtime_null.sql
new file mode 100644
index 00000000000..360ef6270cf
--- /dev/null
+++ b/yt/yql/tests/sql/suites/expr/tagged_runtime_null.sql
@@ -0,0 +1,10 @@
+/* postgres can not */
+/* dqfile can not */ /* See details in YQL-20113#68ac0bd952cebb2ea9576cb3 */
+
+use plato;
+insert into @tmp
+select Just((
+ AsTagged(null,"C"),
+ )) as x;
+commit;
+select x.0 from @tmp