diff --git a/ydb/core/kqp/opt/physical/kqp_opt_phy_olap_filter.cpp b/ydb/core/kqp/opt/physical/kqp_opt_phy_olap_filter.cpp index a99530252656..98a90b683045 100644 --- a/ydb/core/kqp/opt/physical/kqp_opt_phy_olap_filter.cpp +++ b/ydb/core/kqp/opt/physical/kqp_opt_phy_olap_filter.cpp @@ -204,6 +204,15 @@ TMaybeNode YqlApplyPushdown(const TExprBase& apply, const TExprNode& .Done(); } +TMaybeNode JsonExistsPushdown(const TCoJsonExists& jsonExists, TExprContext& ctx, TPositionHandle pos) +{ + auto columnName = jsonExists.Json().Cast().Name(); + return Build(ctx, pos) + .Column(columnName) + .Path(jsonExists.JsonPath().Cast()) + .Done(); +} + std::vector ConvertComparisonNode(const TExprBase& nodeIn, const TExprNode& argument, TExprContext& ctx, TPositionHandle pos) { std::vector out; @@ -249,6 +258,10 @@ std::vector ConvertComparisonNode(const TExprBase& nodeIn, const TExp return builder.Done(); } + if (auto maybeJsonExists = node.Maybe()) { + return JsonExistsPushdown(maybeJsonExists.Cast(), ctx, pos); + } + if (const auto maybeJust = node.Maybe()) { if (const auto params = ConvertComparisonNode(maybeJust.Cast().Input(), argument, ctx, pos); 1U == params.size()) { return Build(ctx, node.Pos()) @@ -515,15 +528,6 @@ TMaybeNode ExistsPushdown(const TCoExists& exists, TExprContext& ctx, .Done(); } -TMaybeNode JsonExistsPushdown(const TCoJsonExists& jsonExists, TExprContext& ctx, TPositionHandle pos) -{ - auto columnName = jsonExists.Json().Cast().Name(); - return Build(ctx, pos) - .Column(columnName) - .Path(jsonExists.JsonPath().Cast()) - .Done(); -} - TMaybeNode SafeCastPredicatePushdown(const TCoFlatMap& inputFlatmap, const TExprNode& argument, TExprContext& ctx, TPositionHandle pos) { /* @@ -572,10 +576,7 @@ TMaybeNode CoalescePushdown(const TCoCoalesce& coalesce, const TExprN return SafeCastPredicatePushdown(maybeFlatmap.Cast(), argument, ctx, pos); } else if (auto maybePredicate = predicate.Maybe()) { return SimplePredicatePushdown(maybePredicate.Cast(), argument, ctx, pos); - } else if (auto maybeJsonExists = predicate.Maybe()) { - return JsonExistsPushdown(maybeJsonExists.Cast(), ctx, pos); } - return NullNode; }