From 6fd8e67feb6dc4e0273cdfccc8446a106902ca98 Mon Sep 17 00:00:00 2001 From: Pavel Velikhov Date: Thu, 2 Jul 2026 20:56:08 +0300 Subject: Improve constant folding of UDFs (#45316) Co-authored-by: Velikhov Pavel --- ydb/core/kqp/opt/cbo/solver/kqp_opt_stat.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ydb/core/kqp/opt/cbo/solver/kqp_opt_stat.cpp b/ydb/core/kqp/opt/cbo/solver/kqp_opt_stat.cpp index 1b03b0ecc7b..2c09a8211fb 100644 --- a/ydb/core/kqp/opt/cbo/solver/kqp_opt_stat.cpp +++ b/ydb/core/kqp/opt/cbo/solver/kqp_opt_stat.cpp @@ -90,7 +90,8 @@ namespace { if (!TCoApply::Match(input.Get())) { return false; } - if (input->ChildrenSize() != 2) { + + if (input->ChildrenSize() != 2 && input->ChildrenSize() != 3) { return false; } if (input->Child(0)->IsCallable("Udf")) { @@ -102,10 +103,12 @@ namespace { } } if (withParams) { - return IsConstantExprWithParams(input->Child(1)); + return IsConstantExprWithParams(input->Child(1)) || IsConstantUdf(input->Child(1)); } else { - return IsConstantExpr(input->Child(1)); + return IsConstantExpr(input->Child(1)) || IsConstantUdf(input->Child(1)); } + } else if (TCoApply::Match(input->Child(1))){ + return IsConstantUdf(input->ChildPtr(1)); } return false; } -- cgit v1.3