Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion ydb/library/yql/dq/opt/dq_opt_peephole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,29 @@ NNodes::TExprBase DqPeepholeRewriteReplicate(const NNodes::TExprBase& node, TExp

TVector<TExprBase> branches;
branches.reserve(dqReplicate.Args().Count() - 1);
const auto inputKind = dqReplicate.Arg(0).Ref().GetTypeAnn()->GetKind();
YQL_ENSURE(inputKind == ETypeAnnotationKind::Stream || inputKind == ETypeAnnotationKind::Flow);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Разве может быть что-то другое по типизации?


auto inputIndex = NDq::BuildAtomList("0", dqReplicate.Pos(), ctx);
for (size_t i = 1; i < dqReplicate.Args().Count(); ++i) {
branches.emplace_back(inputIndex);
branches.emplace_back(ctx.DeepCopyLambda(dqReplicate.Args().Get(i).Ref()));
const auto lambdaOutputKind = dqReplicate.Arg(i).Ref().GetTypeAnn()->GetKind();
YQL_ENSURE(lambdaOutputKind == ETypeAnnotationKind::Stream || lambdaOutputKind == ETypeAnnotationKind::Flow);
if (lambdaOutputKind != inputKind) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как вообще могли получаться в DqReplicate лямбды с разными типами? Типизация DqReplicate не проверяет что ли это? Если нет, то нужно там править и править оптимизаторы, которые это порождают

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не проверяет и не было очевидно что должна проверять

branches.emplace_back(ctx.Builder(dqReplicate.Arg(i).Pos())
.Lambda()
.Param("arg")
.Callable(lambdaOutputKind == ETypeAnnotationKind::Stream ? "ToFlow" : "FromFlow")
.Apply(0, dqReplicate.Arg(i).Ptr())
.With(0, "arg")
.Seal()
.Seal()
.Seal()
.Build()
);
} else {
branches.emplace_back(ctx.DeepCopyLambda(dqReplicate.Arg(i).Ref()));
}
}

return Build<TCoSwitch>(ctx, dqReplicate.Pos())
Expand Down