diff options
author | pilik <96681992+pashandor789@users.noreply.github.com> | 2024-04-20 19:44:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-20 19:44:45 +0300 |
commit | 26ae4876650e5ff653bf42dd1300858441a254ad (patch) | |
tree | 630f5dd5fff82cf95a11d38078d69a7f9a394bde | |
parent | 2046d65b9bc42a724c28a0441e61fa44127726df (diff) | |
download | ydb-26ae4876650e5ff653bf42dd1300858441a254ad.tar.gz |
[DPHyp] Fix non-returnable std::bitset<128> impl (#3941)
Co-authored-by: Pavel Ivanov <pudge1000-7@mr-nvme-testing-11.search.yandex.net>
-rw-r--r-- | ydb/core/kqp/ut/join/kqp_join_order_ut.cpp | 65 | ||||
-rw-r--r-- | ydb/library/yql/dq/opt/dq_opt_dphyp_solver.h | 6 | ||||
-rw-r--r-- | ydb/library/yql/dq/opt/dq_opt_join_cost_based.cpp | 2 |
3 files changed, 69 insertions, 4 deletions
diff --git a/ydb/core/kqp/ut/join/kqp_join_order_ut.cpp b/ydb/core/kqp/ut/join/kqp_join_order_ut.cpp index 96a43569ff..a3167ef544 100644 --- a/ydb/core/kqp/ut/join/kqp_join_order_ut.cpp +++ b/ydb/core/kqp/ut/join/kqp_join_order_ut.cpp @@ -744,8 +744,73 @@ static TKikimrRunner GetKikimrWithJoinSettings(){ return TKikimrRunner(settings); } +class TChainConstructor { +public: + TChainConstructor(size_t chainSize) + : Kikimr_(GetKikimrWithJoinSettings()) + , TableClient_(Kikimr_.GetTableClient()) + , Session_(TableClient_.CreateSession().GetValueSync().GetSession()) + , ChainSize_(chainSize) + {} + + void CreateTables() { + for (size_t i = 0; i < ChainSize_; ++i) { + TString tableName; + + tableName + .append("/Root/table_").append(ToString(i));; + + TString createTable; + createTable + += "CREATE TABLE `" + tableName + "` (id" + + ToString(i) + " Int32, " + + "PRIMARY KEY (id" + ToString(i) + "));"; + + std::cout << createTable << std::endl; + auto res = Session_.ExecuteSchemeQuery(createTable).GetValueSync(); + std::cout << res.GetIssues().ToString() << std::endl; + UNIT_ASSERT(res.IsSuccess()); + } + } + + void JoinTables() { + TString joinRequest; + + joinRequest.append("SELECT * FROM `/Root/table_0` as t0 "); + + for (size_t i = 1; i < ChainSize_; ++i) { + TString table = "/Root/table_" + ToString(i); + + TString prevAliasTable = "t" + ToString(i - 1); + TString aliasTable = "t" + ToString(i); + + joinRequest + += "INNER JOIN `" + table + "`" + " AS " + aliasTable + " ON " + + aliasTable + ".id" + ToString(i) + "=" + prevAliasTable + ".id" + + ToString(i-1) + " "; + } + + auto result = Session_.ExecuteDataQuery(joinRequest, TTxControl::BeginTx().CommitTx()).ExtractValueSync(); + + std::cout << result.GetIssues().ToString() << std::endl; + std::cout << joinRequest << std::endl; + UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::SUCCESS); + } + +private: + TKikimrRunner Kikimr_; + NYdb::NTable::TTableClient TableClient_; + TSession Session_; + size_t ChainSize_; +}; Y_UNIT_TEST_SUITE(KqpJoinOrder) { + Y_UNIT_TEST(Chain65Nodes) { + TChainConstructor chain(65); + chain.CreateTables(); + chain.JoinTables(); + } + Y_UNIT_TEST(FiveWayJoin) { auto kikimr = GetKikimrWithJoinSettings(); diff --git a/ydb/library/yql/dq/opt/dq_opt_dphyp_solver.h b/ydb/library/yql/dq/opt/dq_opt_dphyp_solver.h index da042c3740..54ceda2179 100644 --- a/ydb/library/yql/dq/opt/dq_opt_dphyp_solver.h +++ b/ydb/library/yql/dq/opt/dq_opt_dphyp_solver.h @@ -6,7 +6,7 @@ namespace NYql::NDq { -#ifdef DEBUG +#ifndef NDEBUG struct pair_hash { template <class T1, class T2> std::size_t operator () (const std::pair<T1,T2> &p) const { @@ -97,7 +97,7 @@ private: size_t NNodes_; IProviderContext& Pctx_; // Provider specific contexts? // FIXME: This is a temporary structure that needs to be extended to multiple providers. - #ifdef DEBUG + #ifndef NDEBUG THashMap<std::pair<TNodeSet, TNodeSet>, bool, pair_hash> CheckTable_; #endif private: @@ -470,7 +470,7 @@ template<typename TNodeSet> void TDPHypSolver<TNodeSet>::EmitCsgCmp(const TNodeS DpTable_[joined] = bestJoin; } - #ifdef DEBUG + #ifndef NDEBUG auto pair = std::make_pair(s1, s2); Y_ENSURE (!CheckTable_.contains(pair), "Check table already contains pair S1|S2"); CheckTable_[ std::pair<TNodeSet,TNodeSet>(s1, s2) ] = true; diff --git a/ydb/library/yql/dq/opt/dq_opt_join_cost_based.cpp b/ydb/library/yql/dq/opt/dq_opt_join_cost_based.cpp index 809c88611f..4f1c66a01c 100644 --- a/ydb/library/yql/dq/opt/dq_opt_join_cost_based.cpp +++ b/ydb/library/yql/dq/opt/dq_opt_join_cost_based.cpp @@ -223,7 +223,7 @@ public: } if (64 < relsCount && relsCount <= 128) { - JoinSearchImpl<TNodeSet128>(joinTree); + return JoinSearchImpl<TNodeSet128>(joinTree); } ComputeStatistics(joinTree, this->Pctx); |