Browse Source

Cleaned up code that removes aliases from attributes (#7745)

Pavel Velikhov 7 months ago
parent
commit
bbad9a4ad7

+ 3 - 3
ydb/core/kqp/ut/join/kqp_join_order_ut.cpp

@@ -253,9 +253,9 @@ Y_UNIT_TEST_SUITE(KqpJoinOrder) {
         ExecuteJoinOrderTestDataQueryWithStats("queries/four_way_join_with_preds_and_equiv.sql", "stats/basic.json", StreamLookupJoin);
     }
 
-    //Y_UNIT_TEST_TWIN(FourWayJoinWithPredsAndEquivAndLeft, StreamLookupJoin) {
-    //    ExecuteJoinOrderTestDataQueryWithStats("queries/four_way_join_with_preds_and_equiv_and_left.sql", "stats/basic.json", StreamLookupJoin);
-    //}
+    Y_UNIT_TEST_TWIN(FourWayJoinWithPredsAndEquivAndLeft, StreamLookupJoin) {
+        ExecuteJoinOrderTestDataQueryWithStats("queries/four_way_join_with_preds_and_equiv_and_left.sql", "stats/basic.json", StreamLookupJoin);
+    }
 
     Y_UNIT_TEST_TWIN(TestJoinHint, StreamLookupJoin) {
         CheckJoinCardinality("queries/test_join_hint.sql", "stats/basic.json", "InnerJoin (Grace)", 10e6, StreamLookupJoin);

+ 4 - 10
ydb/library/yql/dq/opt/dq_opt_join_hypergraph.h

@@ -67,18 +67,12 @@ public:
                 auto leftKey = left.AttributeName;
                 auto rightKey = right.AttributeName;
 
-                for (size_t i = leftKey.size() - 1; i > 0; --i) {
-                    if (leftKey[i] == '.') {
-                        leftKey = leftKey.substr(i + 1);
-                        break;
-                    }
+                if (auto idx = leftKey.find_last_of('.') != TString::npos) {
+                    leftKey =  leftKey.substr(idx+1);
                 }
 
-                for (size_t i = rightKey.size() - 1; i > 0; --i) {
-                    if (rightKey[i] == '.') {
-                        rightKey = rightKey.substr(i + 1);
-                        break;
-                    }
+                if (auto idx = rightKey.find_last_of('.') != TString::npos) {
+                    rightKey =  rightKey.substr(idx+1);
                 }
 
                 LeftJoinKeys.emplace_back(leftKey);

+ 2 - 4
ydb/library/yql/dq/opt/dq_opt_stat.cpp

@@ -24,10 +24,8 @@ namespace {
 
 
     TString RemoveAliases(TString attributeName) {
-        for (size_t i = attributeName.size() - 1; i>0; i--) {
-            if (attributeName[i]=='.') {
-                return attributeName.substr(i+1);
-            }
+        if (auto idx = attributeName.find_last_of('.') != TString::npos) {
+            return attributeName.substr(idx+1);
         }
         return attributeName;
     }

+ 2 - 4
ydb/library/yql/providers/dq/planner/execution_planner.cpp

@@ -42,10 +42,8 @@ using namespace Yql::DqsProto;
 
 namespace {
     TString RemoveAliases(TString attributeName) {
-        for (size_t i = attributeName.size() - 1; i>0; i--) {
-            if (attributeName[i]=='.') {
-                return attributeName.substr(i+1);
-            }
+        if (auto idx = attributeName.find_last_of('.') != TString::npos) {
+            return attributeName.substr(idx+1);
         }
         return attributeName;
     }