aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authora-romanov <Anton.Romanov@ydb.tech>2023-06-28 18:05:02 +0300
committera-romanov <Anton.Romanov@ydb.tech>2023-06-28 18:05:02 +0300
commit3066bdd79a8303e4776ec824d33cc6b845acab21 (patch)
tree237b32464a30e900cf7feb5554c561f3a0440819
parentcbc2a9337558aababc76098ae1a8ecaa6e0256f2 (diff)
downloadydb-3066bdd79a8303e4776ec824d33cc6b845acab21.tar.gz
YQL-8971 Drop bad optimizer.
Патамушта вот: https://a.yandex-team.ru/review/4079202/details
-rw-r--r--ydb/library/yql/core/common_opt/yql_co_simple1.cpp97
1 files changed, 0 insertions, 97 deletions
diff --git a/ydb/library/yql/core/common_opt/yql_co_simple1.cpp b/ydb/library/yql/core/common_opt/yql_co_simple1.cpp
index 2b2c580a51..f616897514 100644
--- a/ydb/library/yql/core/common_opt/yql_co_simple1.cpp
+++ b/ydb/library/yql/core/common_opt/yql_co_simple1.cpp
@@ -411,97 +411,6 @@ TExprNode::TPtr HandleEmptyListInJoin(const TExprNode::TPtr& node, TExprContext&
return node;
}
-TExprNode::TPtr UpdateJoinTreeUniqueRecursive(const TExprNode::TPtr& joinTree, const TJoinLabels& labels, const TVector<const TDistinctConstraintNode*>& unique, TExprContext& ctx) {
- TExprNode::TPtr res = joinTree;
-
- TEquiJoinLinkSettings linkSettings = GetEquiJoinLinkSettings(*joinTree->Child(5));
- bool updateSettings = false;
- if (auto left = joinTree->ChildPtr(1); !left->IsAtom()) {
- left = UpdateJoinTreeUniqueRecursive(left, labels, unique, ctx);
- if (left != joinTree->ChildPtr(1)) {
- res = ctx.ChangeChild(*res, 1, std::move(left));
- }
- } else if (linkSettings.LeftHints.find("unique") == linkSettings.LeftHints.end()) {
- if (auto label = labels.FindInput(left->Content())) {
- if (auto ndx = labels.FindInputIndex(left->Content())) {
- if (auto u = unique[*ndx]) {
- auto keys = joinTree->Child(3);
- std::unordered_set<std::string_view> keySet;
- for (ui32 i = 0; i < keys->ChildrenSize(); i += 2) {
- keySet.insert((*label)->MemberName(keys->Child(i)->Content(), keys->Child(i + 1)->Content()));
- }
- for (const auto& set : u->GetAllSets()) {
- if (std::all_of(set.cbegin(), set.cend(), [&keySet](const TConstraintNode::TPathType& path) { return !path.empty() && keySet.contains(path.front()); })) {
- linkSettings.LeftHints.insert("unique");
- updateSettings = true;
- break;
- }
- }
- }
- }
- }
- }
-
- if (auto right = joinTree->ChildPtr(2); !right->IsAtom()) {
- right = UpdateJoinTreeUniqueRecursive(right, labels, unique, ctx);
- if (right != joinTree->ChildPtr(2)) {
- res = ctx.ChangeChild(*res, 2, std::move(right));
- }
- } else if (linkSettings.RightHints.find("unique") == linkSettings.RightHints.end()) {
- if (auto label = labels.FindInput(right->Content())) {
- if (auto ndx = labels.FindInputIndex(right->Content())) {
- if (auto u = unique[*ndx]) {
- auto keys = joinTree->Child(4);
- std::unordered_set<std::string_view> keySet;
- for (ui32 i = 0; i < keys->ChildrenSize(); i += 2) {
- keySet.insert((*label)->MemberName(keys->Child(i)->Content(), keys->Child(i + 1)->Content()));
- }
- for (const auto& set : u->GetAllSets()) {
- if (std::all_of(set.cbegin(), set.cend(), [&keySet](const TConstraintNode::TPathType& path) { return !path.empty() && keySet.contains(path.front()); })) {
- linkSettings.RightHints.insert("unique");
- updateSettings = true;
- break;
- }
- }
- }
- }
- }
- }
-
- if (updateSettings) {
- res = ctx.ChangeChild(*res, 5, BuildEquiJoinLinkSettings(linkSettings, ctx));
- }
-
- return res;
-}
-
-
-TExprNode::TPtr HandleUniqueListInJoin(const TExprNode::TPtr& node, TExprContext& ctx, const TTypeAnnotationContext& typeCtx) {
- if (!typeCtx.IsConstraintCheckEnabled<TDistinctConstraintNode>()) {
- return node;
- }
-
- TJoinLabels labels;
- TVector<const TDistinctConstraintNode*> unique;
- unique.reserve(node->ChildrenSize() - 2);
- for (ui32 i = 0; i < node->ChildrenSize() - 2; ++i) {
- auto err = labels.Add(ctx, *node->Child(i)->Child(1),
- node->Child(i)->Head().GetTypeAnn()->Cast<TListExprType>()->GetItemType()->Cast<TStructExprType>());
- if (err) {
- ctx.AddError(*err);
- return nullptr;
- }
- unique.push_back(node->Child(i)->Head().GetConstraint<TDistinctConstraintNode>());
- }
-
- auto joinTree = UpdateJoinTreeUniqueRecursive(node->ChildPtr(node->ChildrenSize() - 2), labels, unique, ctx);
- if (joinTree != node->ChildPtr(node->ChildrenSize() - 2)) {
- return ctx.ChangeChild(*node, node->ChildrenSize() - 2, std::move(joinTree));
- }
-
- return node;
-}
-
bool IsDataType(const TTypeAnnotationNode& type) {
return type.GetKind() == ETypeAnnotationKind::Data;
}
@@ -4617,12 +4526,6 @@ void RegisterCoSimpleCallables1(TCallableOptimizerMap& map) {
return ret;
}
- ret = HandleUniqueListInJoin(node, ctx, *optCtx.Types);
- if (ret != node) {
- YQL_CLOG(DEBUG, Core) << "HandleUniqueListInJoin";
- return ret;
- }
-
if (const auto indexes = GetUselessSortedJoinInputs(TCoEquiJoin(node)); !indexes.empty()) {
YQL_CLOG(DEBUG, Core) << "Suppress order on " << indexes.size() << ' ' << node->Content() << " inputs.";
auto children = node->ChildrenList();