diff options
author | aneporada <aneporada@ydb.tech> | 2022-09-16 17:47:04 +0300 |
---|---|---|
committer | aneporada <aneporada@ydb.tech> | 2022-09-16 17:47:04 +0300 |
commit | 87fb451e04f222b71e139fbc397eba5f0f050425 (patch) | |
tree | e7d232f4fb8ed1aae572c314d22f9c8550ce6b6a | |
parent | afdecb0e4f540b92a669eca4ff54e6b2ca899830 (diff) | |
download | ydb-87fb451e04f222b71e139fbc397eba5f0f050425.tar.gz |
[] Fix casting structs/tuples with PG types
-rw-r--r-- | ydb/library/yql/core/yql_expr_type_annotation.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ydb/library/yql/core/yql_expr_type_annotation.cpp b/ydb/library/yql/core/yql_expr_type_annotation.cpp index 0ff7c4abae7..26c28fe8a9b 100644 --- a/ydb/library/yql/core/yql_expr_type_annotation.cpp +++ b/ydb/library/yql/core/yql_expr_type_annotation.cpp @@ -681,6 +681,7 @@ IGraphTransformer::TStatus TryConvertToImpl(TExprContext& ctx, TExprNode::TPtr& for (auto i = from->GetSize(); i < to->GetSize(); ++i) { switch (const auto newType = to->GetItems()[i]; newType->GetKind()) { case ETypeAnnotationKind::Optional: + case ETypeAnnotationKind::Pg: valueTransforms.push_back(ctx.NewCallable(node->Pos(), "Nothing", {ExpandType(node->Pos(), *newType, ctx)})); continue; case ETypeAnnotationKind::Null: @@ -721,6 +722,7 @@ IGraphTransformer::TStatus TryConvertToImpl(TExprContext& ctx, TExprNode::TPtr& for (auto i = from->GetSize(); i < to->GetSize(); ++i) { switch (const auto newType = to->GetItems()[i]; newType->GetKind()) { case ETypeAnnotationKind::Optional: + case ETypeAnnotationKind::Pg: valueTransforms.push_back(ctx.NewCallable(node->Pos(), "Nothing", {ExpandType(node->Pos(), *newType, ctx)})); continue; case ETypeAnnotationKind::Null: @@ -1010,12 +1012,12 @@ NUdf::TCastResultOptions CastResult(const TTupleExprType* source, const TTupleEx NUdf::TCastResultOptions result = NUdf::ECastOptions::Complete; for (size_t i = 0U; i < std::max(sItems.size(), tItems.size()); ++i) { if (i >= sItems.size()) { - if (AllOrAnyElements && tItems[i]->GetKind() != ETypeAnnotationKind::Optional && tItems[i]->GetKind() != ETypeAnnotationKind::Null) { + if (AllOrAnyElements && !tItems[i]->IsOptionalOrNull()) { return NUdf::ECastOptions::Impossible; } } else if (i >= tItems.size()) { if (sItems[i]->GetKind() != ETypeAnnotationKind::Null) { - if (sItems[i]->GetKind() == ETypeAnnotationKind::Optional) { + if (sItems[i]->IsOptionalOrNull()) { result |= Strong ? NUdf::ECastOptions::MayFail : NUdf::ECastOptions::MayLoseData; } else { if (Strong && AllOrAnyElements) { @@ -1046,12 +1048,12 @@ NUdf::TCastResultOptions CastResult(const TStructExprType* source, const TStruct bool hasCommon = false; for (const auto& field : fields) { if (!field.second.front()) { - if (AllOrAnyMembers && field.second.back()->GetKind() != ETypeAnnotationKind::Optional && field.second.back()->GetKind() != ETypeAnnotationKind::Null) { + if (AllOrAnyMembers && !field.second.back()->IsOptionalOrNull()) { return NUdf::ECastOptions::Impossible; } } else if (!field.second.back()) { if (field.second.front()->GetKind() != ETypeAnnotationKind::Null) { - if (field.second.front()->GetKind() == ETypeAnnotationKind::Optional) { + if (field.second.front()->IsOptionalOrNull()) { result |= Strong ? NUdf::ECastOptions::MayFail : NUdf::ECastOptions::MayLoseData; } else { if (Strong && AllOrAnyMembers) { |