Skip to content

Commit 9d02ffb

Browse files
zverevgenydorooleg
authored andcommitted
handle JsonExists pushdown simularily to JsonValue (ydb-platform#15151)
1 parent 5c601a9 commit 9d02ffb

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

ydb/core/kqp/opt/physical/kqp_opt_phy_olap_filter.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,15 @@ TMaybeNode<TExprBase> YqlApplyPushdown(const TExprBase& apply, const TExprNode&
204204
.Done();
205205
}
206206

207+
TMaybeNode<TExprBase> JsonExistsPushdown(const TCoJsonExists& jsonExists, TExprContext& ctx, TPositionHandle pos)
208+
{
209+
auto columnName = jsonExists.Json().Cast<TCoMember>().Name();
210+
return Build<TKqpOlapJsonExists>(ctx, pos)
211+
.Column(columnName)
212+
.Path(jsonExists.JsonPath().Cast<TCoUtf8>())
213+
.Done();
214+
}
215+
207216
std::vector<TExprBase> ConvertComparisonNode(const TExprBase& nodeIn, const TExprNode& argument, TExprContext& ctx, TPositionHandle pos)
208217
{
209218
std::vector<TExprBase> out;
@@ -249,6 +258,10 @@ std::vector<TExprBase> ConvertComparisonNode(const TExprBase& nodeIn, const TExp
249258
return builder.Done();
250259
}
251260

261+
if (auto maybeJsonExists = node.Maybe<TCoJsonExists>()) {
262+
return JsonExistsPushdown(maybeJsonExists.Cast(), ctx, pos);
263+
}
264+
252265
if (const auto maybeJust = node.Maybe<TCoJust>()) {
253266
if (const auto params = ConvertComparisonNode(maybeJust.Cast().Input(), argument, ctx, pos); 1U == params.size()) {
254267
return Build<TKqpOlapFilterUnaryOp>(ctx, node.Pos())
@@ -515,15 +528,6 @@ TMaybeNode<TExprBase> ExistsPushdown(const TCoExists& exists, TExprContext& ctx,
515528
.Done();
516529
}
517530

518-
TMaybeNode<TExprBase> JsonExistsPushdown(const TCoJsonExists& jsonExists, TExprContext& ctx, TPositionHandle pos)
519-
{
520-
auto columnName = jsonExists.Json().Cast<TCoMember>().Name();
521-
return Build<TKqpOlapJsonExists>(ctx, pos)
522-
.Column(columnName)
523-
.Path(jsonExists.JsonPath().Cast<TCoUtf8>())
524-
.Done();
525-
}
526-
527531
TMaybeNode<TExprBase> SafeCastPredicatePushdown(const TCoFlatMap& inputFlatmap, const TExprNode& argument, TExprContext& ctx, TPositionHandle pos)
528532
{
529533
/*
@@ -572,10 +576,7 @@ TMaybeNode<TExprBase> CoalescePushdown(const TCoCoalesce& coalesce, const TExprN
572576
return SafeCastPredicatePushdown(maybeFlatmap.Cast(), argument, ctx, pos);
573577
} else if (auto maybePredicate = predicate.Maybe<TCoCompare>()) {
574578
return SimplePredicatePushdown(maybePredicate.Cast(), argument, ctx, pos);
575-
} else if (auto maybeJsonExists = predicate.Maybe<TCoJsonExists>()) {
576-
return JsonExistsPushdown(maybeJsonExists.Cast(), ctx, pos);
577579
}
578-
579580
return NullNode;
580581
}
581582

0 commit comments

Comments
 (0)