320804 {
320805 auto &initial_or = bindings[0].get().Cast<BoundConjunctionExpression>();
320806
320807
320808
320809
320810
320811 expression_set_t candidate_set;
320812 AddExpressionSet(*initial_or.children[0], candidate_set);
320813
320814
320815
320816 for (
idx_t i = 1; i < initial_or.children.size(); i++) {
320817 expression_set_t next_set;
320818 AddExpressionSet(*initial_or.children[i], next_set);
320819 expression_set_t intersect_result;
320820 for (auto &expr : candidate_set) {
320821 if (next_set.find(expr) != next_set.end()) {
320822 intersect_result.insert(expr);
320823 }
320824 }
320825 candidate_set = intersect_result;
320826 }
320827 if (candidate_set.empty()) {
320828
320829 return nullptr;
320830 }
320831
320832
320833 auto new_root = make_uniq<BoundConjunctionExpression>(ExpressionType::CONJUNCTION_AND);
320834 for (auto &expr : candidate_set) {
320835 D_ASSERT(initial_or.children.size() > 0);
320836
320837
320838 auto result = ExtractExpression(initial_or, 0, expr.get());
320839
320840 for (
idx_t i = 1; i < initial_or.children.size(); i++) {
320841 ExtractExpression(initial_or, i, *result);
320842 }
320843
320844 new_root->children.push_back(std::move(result));
320845 }
320846
320847
320848
320849
320850
320851
320852
320853
320854 for (
idx_t i = 0; i < initial_or.children.size(); i++) {
320855 if (!initial_or.children[i]) {
320856 if (new_root->children.size() <= 1) {
320857 return std::move(new_root->children[0]);
320858 } else {
320859 return std::move(new_root);
320860 }
320861 }
320862 }
320863
320864 if (initial_or.children.size() == 1) {
320865
320866 new_root->children.push_back(std::move(initial_or.children[0]));
320867 } else if (initial_or.children.size() > 1) {
320868
320869 auto new_or = make_uniq<BoundConjunctionExpression>(ExpressionType::CONJUNCTION_OR);
320870 for (auto &child : initial_or.children) {
320871 new_or->children.push_back(std::move(child));
320872 }
320873 new_root->children.push_back(std::move(new_or));
320874 }
320875
320876 if (new_root->children.size() == 1) {
320877 return std::move(new_root->children[0]);
320878 }
320879 return std::move(new_root);
320880}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237