27 if (!crt_bin || !prev_bin) {
33 crt_bin->get_optype() != prev_bin->get_optype()) {
38 const auto prev_inner = std::dynamic_pointer_cast<Analyzer::ColumnVar>(
41 const auto crt_outer_rte_set = visitor.
visit(crt_bin->get_left_operand());
42 const auto prev_outer_rte_set = visitor.
visit(prev_bin->get_left_operand());
44 if (crt_outer_rte_set.size() != 1 || prev_outer_rte_set.size() != 1 ||
45 crt_outer_rte_set != prev_outer_rte_set) {
48 if (!crt_inner || !prev_inner ||
49 crt_inner->get_table_id() != prev_inner->get_table_id() ||
50 crt_inner->get_rte_idx() != prev_inner->get_rte_idx()) {
57 const std::vector<std::shared_ptr<Analyzer::Expr>>& crt_coalesced_quals) {
58 std::list<std::shared_ptr<Analyzer::Expr>> join_quals;
59 std::vector<std::shared_ptr<Analyzer::Expr>> lhs_tuple;
60 std::vector<std::shared_ptr<Analyzer::Expr>> rhs_tuple;
62 for (
const auto& qual : crt_coalesced_quals) {
65 not_null = not_null && qual_binary->get_type_info().get_notnull();
66 const auto lhs_col =
remove_cast(qual_binary->get_own_left_operand());
67 const auto rhs_col =
remove_cast(qual_binary->get_own_right_operand());
68 const auto lhs_ti = lhs_col->get_type_info();
74 lhs_tuple.push_back(lhs_col);
75 rhs_tuple.push_back(rhs_col);
77 join_quals.push_back(qual);
80 CHECK(!crt_coalesced_quals.empty());
81 const auto first_qual =
84 CHECK_EQ(lhs_tuple.size(), rhs_tuple.size());
85 if (lhs_tuple.size() > 0) {
86 join_quals.push_front(std::make_shared<Analyzer::BinOper>(
89 first_qual->get_optype(),
91 lhs_tuple.size() > 1 ? std::make_shared<Analyzer::ExpressionTuple>(lhs_tuple)
93 rhs_tuple.size() > 1 ? std::make_shared<Analyzer::ExpressionTuple>(rhs_tuple)
94 : rhs_tuple.front()));
102 const std::vector<std::shared_ptr<Analyzer::Expr>>& crt_coalesced_quals) {
103 if (crt_coalesced_quals.size() == 1) {
104 return {crt_coalesced_quals.front()};
112 const std::list<std::shared_ptr<Analyzer::Expr>>& join_quals) {
113 if (join_quals.empty()) {
116 std::list<std::shared_ptr<Analyzer::Expr>> coalesced_quals;
117 std::vector<std::shared_ptr<Analyzer::Expr>> crt_coalesced_quals;
118 for (
const auto& simple_join_qual : join_quals) {
119 if (crt_coalesced_quals.empty()) {
120 crt_coalesced_quals.push_back(simple_join_qual);
124 !
can_combine_with(simple_join_qual.get(), crt_coalesced_quals.back().get())) {
125 coalesced_quals.splice(coalesced_quals.end(),
127 crt_coalesced_quals.clear();
129 crt_coalesced_quals.push_back(simple_join_qual);
131 if (!crt_coalesced_quals.empty()) {
132 coalesced_quals.splice(coalesced_quals.end(),
135 return coalesced_quals;
139 const std::shared_ptr<Analyzer::BinOper>& join_qual) {
140 std::vector<std::shared_ptr<Analyzer::Expr>> singleton_qual_list;
141 singleton_qual_list.push_back(join_qual);
Defines data structures for the semantic analysis phase of query processing.
std::shared_ptr< Analyzer::Expr > remove_cast(const std::shared_ptr< Analyzer::Expr > &expr)
#define IS_EQUIVALENCE(X)
std::list< std::shared_ptr< Analyzer::Expr > > coalesce_singleton_equi_join(const std::shared_ptr< Analyzer::BinOper > &join_qual)
T visit(const Analyzer::Expr *expr) const
std::list< std::shared_ptr< Analyzer::Expr > > make_composite_equals(const std::vector< std::shared_ptr< Analyzer::Expr >> &crt_coalesced_quals)
bool can_combine_with(const Analyzer::Expr *crt, const Analyzer::Expr *prev)
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
const size_t g_maximum_conditions_to_coalesce
std::list< std::shared_ptr< Analyzer::Expr > > make_composite_equals_impl(const std::vector< std::shared_ptr< Analyzer::Expr >> &crt_coalesced_quals)
std::list< std::shared_ptr< Analyzer::Expr > > combine_equi_join_conditions(const std::list< std::shared_ptr< Analyzer::Expr >> &join_quals)