aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authora-romanov <Anton.Romanov@ydb.tech>2023-02-22 18:29:10 +0300
committera-romanov <Anton.Romanov@ydb.tech>2023-02-22 18:29:10 +0300
commit1cc651a983645fff1a09285fc5c1d03adab74b90 (patch)
tree76f33f3f62dbc9cfe8497a3bd44a9fbdb3cda193
parentcb72ea5e70afde62df86253b424ae15fd5200c21 (diff)
downloadydb-1cc651a983645fff1a09285fc5c1d03adab74b90.tar.gz
Drop IfPresent before Cast.
-rw-r--r--ydb/library/yql/core/yql_opt_utils.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/ydb/library/yql/core/yql_opt_utils.cpp b/ydb/library/yql/core/yql_opt_utils.cpp
index 91037dab18..c078253f5a 100644
--- a/ydb/library/yql/core/yql_opt_utils.cpp
+++ b/ydb/library/yql/core/yql_opt_utils.cpp
@@ -1224,6 +1224,12 @@ TExprNode::TPtr OptimizeIfPresent(const TExprNode::TPtr& node, TExprContext& ctx
.Seal().Build();
}
+ if (lambda.Tail().IsCallable({"SafeCast", "StrictCast"}) && node->Tail().IsCallable("Nothing") && &lambda.Tail().Head() == &lambda.Head().Head() &&
+ ETypeAnnotationKind::Optional != node->Head().GetTypeAnn()->Cast<TOptionalExprType>()->GetItemType()->GetKind()) {
+ YQL_CLOG(DEBUG, Core) << "Drop " << node->Content() << " with " << lambda.Tail().Content() << " and " << node->Tail().Content();
+ return ctx.ChangeChild(lambda.Tail(), 0U, node->HeadPtr());
+ }
+
if constexpr (Cannonize) {
if (node->Tail().IsCallable("Nothing") && node->Tail().GetTypeAnn()->GetKind() != ETypeAnnotationKind::Pg) {
YQL_CLOG(DEBUG, Core) << node->Content() << " with else " << node->Tail().Content();