diff options
author | udovichenko-r <rvu@ydb.tech> | 2022-08-26 20:53:22 +0300 |
---|---|---|
committer | udovichenko-r <rvu@ydb.tech> | 2022-08-26 20:53:22 +0300 |
commit | b0c9cc1d3129b79b0c09132622a795ab6a9319f3 (patch) | |
tree | 870ccff7da31121a46008a9d6a15539f52bfcd7c | |
parent | e30ada84abf7af2b7eaa1e97aede8ec386d25bb8 (diff) | |
download | ydb-b0c9cc1d3129b79b0c09132622a795ab6a9319f3.tar.gz |
[constraints] Handle case when first item has only Empty constraint
4 files changed, 47 insertions, 32 deletions
diff --git a/contrib/restricted/boost/boost/spirit/home/qi/auxiliary/attr.hpp b/contrib/restricted/boost/boost/spirit/home/qi/auxiliary/attr.hpp index 8b240835330..d284d3b6e58 100644 --- a/contrib/restricted/boost/boost/spirit/home/qi/auxiliary/attr.hpp +++ b/contrib/restricted/boost/boost/spirit/home/qi/auxiliary/attr.hpp @@ -75,6 +75,7 @@ namespace boost { namespace spirit { namespace qi // silence MSVC warning C4512: assignment operator could not be generated BOOST_DELETED_FUNCTION(attr_parser& operator= (attr_parser const&)); + attr_parser(const attr_parser&) = default; }; /////////////////////////////////////////////////////////////////////////// diff --git a/contrib/restricted/boost/boost/spirit/home/qi/detail/alternative_function.hpp b/contrib/restricted/boost/boost/spirit/home/qi/detail/alternative_function.hpp index dcb5af3d0ae..de4a35e6961 100644 --- a/contrib/restricted/boost/boost/spirit/home/qi/detail/alternative_function.hpp +++ b/contrib/restricted/boost/boost/spirit/home/qi/detail/alternative_function.hpp @@ -178,6 +178,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail // silence MSVC warning C4512: assignment operator could not be generated BOOST_DELETED_FUNCTION(alternative_function& operator= (alternative_function const&)); + alternative_function(const alternative_function&) = default; }; template <typename Iterator, typename Context, typename Skipper> diff --git a/contrib/restricted/boost/boost/spirit/home/qi/directive/omit.hpp b/contrib/restricted/boost/boost/spirit/home/qi/directive/omit.hpp index 6946f563476..2463507e8aa 100644 --- a/contrib/restricted/boost/boost/spirit/home/qi/directive/omit.hpp +++ b/contrib/restricted/boost/boost/spirit/home/qi/directive/omit.hpp @@ -72,6 +72,7 @@ namespace boost { namespace spirit { namespace qi // silence MSVC warning C4512: assignment operator could not be generated BOOST_DELETED_FUNCTION(omit_directive& operator= (omit_directive const&)); + omit_directive(const omit_directive&) = default; }; /////////////////////////////////////////////////////////////////////////// diff --git a/ydb/library/yql/ast/yql_constraint.cpp b/ydb/library/yql/ast/yql_constraint.cpp index 74adceb1535..34e66650dcf 100644 --- a/ydb/library/yql/ast/yql_constraint.cpp +++ b/ydb/library/yql/ast/yql_constraint.cpp @@ -268,17 +268,22 @@ const TSortedConstraintNode* TSortedConstraintNode::MakeCommon(const TVector<con return nullptr; } - const auto sort = constraints.front()->GetConstraint<TSortedConstraintNode>(); - if (constraints.size() == 1 || !sort) { - return sort; + if (constraints.size() == 1) { + return constraints.front()->GetConstraint<TSortedConstraintNode>(); } - auto commonPrefixLength = sort->GetContent().size(); - for (size_t i = 1; i < constraints.size() && commonPrefixLength > 0; ++i) { + size_t commonPrefixLength = 0; + const TSortedConstraintNode* sort = nullptr; + for (size_t i = 0; i < constraints.size(); ++i) { if (const auto nextSort = constraints[i]->GetConstraint<TSortedConstraintNode>()) { - commonPrefixLength = std::min(commonPrefixLength, nextSort->GetCommonPrefixLength(*sort)); + if (sort) { + commonPrefixLength = std::min(commonPrefixLength, nextSort->GetCommonPrefixLength(*sort)); + } else { + sort = nextSort; + commonPrefixLength = sort->GetContent().size(); + } } else if (!constraints[i]->GetConstraint<TEmptyConstraintNode>()) { - commonPrefixLength = 0; + return nullptr; } } if (commonPrefixLength) { @@ -638,41 +643,48 @@ const TPassthroughConstraintNode* TPassthroughConstraintNode::MakeCommon(const T return nullptr; } - auto part = constraints.front()->GetConstraint<TPassthroughConstraintNode>(); - if (constraints.size() == 1 || !part) { - return part; + if (constraints.size() == 1) { + return constraints.front()->GetConstraint<TPassthroughConstraintNode>(); } - auto mapping = part->GetColumnMapping(); - if (const auto self = mapping.find(nullptr); mapping.cend() != self) - mapping.emplace(part, std::move(mapping.extract(self).mapped())); - - for (size_t i = 1; i < constraints.size() && !mapping.empty(); ++i) { - part = constraints[i]->GetConstraint<TPassthroughConstraintNode>(); + bool first = true; + TPassthroughConstraintNode::TMapType mapping; + for (size_t i = 0; i < constraints.size(); ++i) { + auto part = constraints[i]->GetConstraint<TPassthroughConstraintNode>(); if (!part) { if (constraints[i]->GetConstraint<TEmptyConstraintNode>()) { continue; } return nullptr; } - - for (const auto& nextMapping : part->GetColumnMapping()) { - if (const auto it = mapping.find(nextMapping.first ? nextMapping.first : part); mapping.cend() != it) { - TPassthroughConstraintNode::TPartType result; - std::set_intersection( - it->second.cbegin(), it->second.cend(), - nextMapping.second.cbegin(), nextMapping.second.cend(), - std::back_inserter(result), - [] (const TPassthroughConstraintNode::TPartType::value_type& c1, const TPassthroughConstraintNode::TPartType::value_type& c2) { - return c1 < c2; - } - ); - if (result.empty()) - mapping.erase(it); - else - it->second = std::move(result); + if (first) { + mapping = part->GetColumnMapping(); + if (const auto self = mapping.find(nullptr); mapping.cend() != self) { + mapping.emplace(part, std::move(mapping.extract(self).mapped())); + } + first = false; + } else { + for (const auto& nextMapping : part->GetColumnMapping()) { + if (const auto it = mapping.find(nextMapping.first ? nextMapping.first : part); mapping.cend() != it) { + TPassthroughConstraintNode::TPartType result; + std::set_intersection( + it->second.cbegin(), it->second.cend(), + nextMapping.second.cbegin(), nextMapping.second.cend(), + std::back_inserter(result), + [] (const TPassthroughConstraintNode::TPartType::value_type& c1, const TPassthroughConstraintNode::TPartType::value_type& c2) { + return c1 < c2; + } + ); + if (result.empty()) + mapping.erase(it); + else + it->second = std::move(result); + } } } + if (mapping.empty()) { + break; + } } return mapping.empty() ? nullptr : ctx.MakeConstraint<TPassthroughConstraintNode>(std::move(mapping)); |