aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authora-romanov <Anton.Romanov@ydb.tech>2023-07-21 13:07:24 +0300
committera-romanov <Anton.Romanov@ydb.tech>2023-07-21 13:07:24 +0300
commit432e25fdf8ca8de82d63eb6663b62a5fba924cd0 (patch)
tree168736d7567bbdfc728350e5a88dbec0b4905ed9
parentf23ee396c023ff431442b8322dd075ac8b8dff63 (diff)
downloadydb-432e25fdf8ca8de82d63eb6663b62a5fba924cd0.tar.gz
YQL-13180 Fix If type annotation.
-rw-r--r--ydb/library/yql/core/type_ann/type_ann_core.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/ydb/library/yql/core/type_ann/type_ann_core.cpp b/ydb/library/yql/core/type_ann/type_ann_core.cpp
index d7d4a84b650..ea31c5b8c1c 100644
--- a/ydb/library/yql/core/type_ann/type_ann_core.cpp
+++ b/ydb/library/yql/core/type_ann/type_ann_core.cpp
@@ -5804,7 +5804,7 @@ template <NKikimr::NUdf::EDataSlot DataSlot>
const auto elseNode = input->Child(2);
const auto thenType = thenNode->GetTypeAnn();
const auto elseType = elseNode->GetTypeAnn();
- if (IsStrict) {
+ if constexpr (IsStrict) {
if (IsSameAnnotation(*thenType, *elseType)) {
output = ctx.Expr.RenameNode(*input, "If");
return IGraphTransformer::TStatus::Repeat;
@@ -5813,20 +5813,14 @@ template <NKikimr::NUdf::EDataSlot DataSlot>
*thenType << ", else type: " << *elseType));
return IGraphTransformer::TStatus::Error;
}
- }
+ } else if (const auto commonType = CommonType<false>(input->Pos(), thenType, elseType, ctx.Expr)) {
+ if (const auto status = TryConvertTo(input->ChildRef(1), *commonType, ctx.Expr).Combine(TryConvertTo(input->TailRef(), *commonType, ctx.Expr)); status != IGraphTransformer::TStatus::Ok)
+ return status;
- const TTypeAnnotationNode* commonType = nullptr;
- if (SilentInferCommonType(input->ChildRef(1), input->ChildRef(2), ctx.Expr, commonType) == IGraphTransformer::TStatus::Error) {
- ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(input->Pos()), TStringBuilder() << "Uncompatible types of branches, then type: " <<
- *thenType << ", else type: " << *elseType));
+ input->SetTypeAnn(commonType);
+ } else
return IGraphTransformer::TStatus::Error;
- }
-
- if (thenNode != input->Child(1) || elseNode != input->Child(2)) {
- return IGraphTransformer::TStatus::Repeat;
- }
- input->SetTypeAnn(commonType);
return IGraphTransformer::TStatus::Ok;
}