aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Neporada <neporada@gmail.com>2022-06-20 14:49:19 +0300
committerAndrey Neporada <neporada@gmail.com>2022-06-20 14:49:19 +0300
commit60e87c9bacff23b2622ba61fe642adabc7d4641d (patch)
tree28362727c324368aa405c22721e0e1f2a19dc779
parent1d8096cb186a7cd8bb3553b1a8670e8f09da875a (diff)
downloadydb-60e87c9bacff23b2622ba61fe642adabc7d4641d.tar.gz
[YQL-15009] Fix default_value validation in MULTI_AGGREGATE_BY case
ref:08c3966d3b243bd08f8b6df2bdc1245c347e35df
-rw-r--r--ydb/library/yql/core/type_ann/type_ann_list.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/ydb/library/yql/core/type_ann/type_ann_list.cpp b/ydb/library/yql/core/type_ann/type_ann_list.cpp
index 02f63e85ca..743a7a872d 100644
--- a/ydb/library/yql/core/type_ann/type_ann_list.cpp
+++ b/ydb/library/yql/core/type_ann/type_ann_list.cpp
@@ -591,12 +591,8 @@ namespace {
const TTypeAnnotationNode& finishType, TStringBuf finishName, TExprNode::TPtr& output, TContext& ctx)
{
auto defaultValue = input->Child(defaultValueIndex);
- if (!defaultValue->IsCallable({"Null", "EmptyList"})) {
+ if (!defaultValue->IsCallable("Null")) {
if (defaultValue->IsLambda()) {
- if (!EnsureMinArgsCount(defaultValue->Head(), 0, ctx.Expr)) {
- return IGraphTransformer::TStatus::Error;
- }
-
if (!EnsureMaxArgsCount(defaultValue->Head(), 1, ctx.Expr)) {
return IGraphTransformer::TStatus::Error;
}
@@ -616,12 +612,15 @@ namespace {
}
auto finishItemType = RemoveOptionalType(&finishType);
- if (finishItemType->GetKind() != ETypeAnnotationKind::Null && finishItemType->GetKind() != ETypeAnnotationKind::EmptyList
- && !IsSameAnnotation(*finishItemType, *defaultValue->GetTypeAnn())) {
- ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(defaultValue->Pos()),
- TStringBuilder() << "Mismatch of default value type and " << finishName
- << " type: " << *defaultValue->GetTypeAnn() << " != " << finishType));
- return IGraphTransformer::TStatus::Error;
+ if (finishItemType->GetKind() != ETypeAnnotationKind::Null) {
+ auto arg = ctx.Expr.NewArgument(defaultValue->Pos(), "arg");
+ auto status = TrySilentConvertTo(arg, *defaultValue->GetTypeAnn(), finishType, ctx.Expr);
+ if (status == IGraphTransformer::TStatus::Error) {
+ ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(defaultValue->Pos()),
+ TStringBuilder() << "Uncompatible types of default value and " << finishName
+ << " : " << *defaultValue->GetTypeAnn() << " != " << finishType));
+ return status;
+ }
}
}