summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvvvv <[email protected]>2022-03-30 23:22:54 +0300
committervvvv <[email protected]>2022-03-30 23:22:54 +0300
commite67b8c4a78521b34b3645171936ceb21938374f5 (patch)
tree48b6327da5b325e4782eacbaa775bdeaba305df7
parent859572f7b489b0198236b3c1509da1cc0c308db3 (diff)
YQL-13710 AggrEqual
ref:44f205cbe780d123815a2a531fe4a6f9769eac7e
-rw-r--r--ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp b/ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp
index 6d87825f552..89450ca99de 100644
--- a/ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp
+++ b/ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp
@@ -4743,6 +4743,39 @@ TExprNode::TPtr SqlEqualTuples(const TExprNode& node, TExprContext& ctx) {
}
template <bool Equals>
+TExprNode::TPtr AggrEqualPg(const TExprNode& node, TExprContext& ctx) {
+ YQL_CLOG(DEBUG, CorePeepHole) << "Expand '" << node.Content() << "' over Pg.";
+ auto ret = ctx.Builder(node.Pos())
+ .Callable("If")
+ .Callable(0, "Exists")
+ .Add(0, node.ChildPtr(0))
+ .Seal()
+ .Callable(1, "Coalesce")
+ .Callable(0,"FromPg")
+ .Callable(0, "PgOp")
+ .Atom(0, "<>")
+ .Add(1, node.ChildPtr(0))
+ .Add(2, node.ChildPtr(1))
+ .Seal()
+ .Seal()
+ .Callable(1, "Bool")
+ .Atom(0, "true")
+ .Seal()
+ .Seal()
+ .Callable(2, "Exists")
+ .Add(0, node.ChildPtr(1))
+ .Seal()
+ .Seal()
+ .Build();
+
+ if (Equals) {
+ ret = ctx.NewCallable(node.Pos(), "Not", { ret });
+ }
+
+ return ret;
+}
+
+template <bool Equals>
TExprNode::TPtr AggrEqualTuples(const TExprNode& node, TExprContext& ctx) {
YQL_CLOG(DEBUG, CorePeepHole) << "Expand '" << node.Content() << "' over Tuples.";
@@ -5656,6 +5689,8 @@ TExprNode::TPtr ExpandAggrEqual(const TExprNode::TPtr& node, TExprContext& ctx)
return AggrCompareVariants<true, !Equals>(*node, ctx);
case ETypeAnnotationKind::Tagged:
return CompareTagged(*node, ctx);
+ case ETypeAnnotationKind::Pg:
+ return AggrEqualPg<Equals>(*node, ctx);
case ETypeAnnotationKind::Optional:
if (type->Cast<TOptionalExprType>()->GetItemType()->GetKind() != ETypeAnnotationKind::Data)
return AggrEqualOpt<Equals>(*node, ctx);