62 bool (*)(
const Analyzer::ColumnVar*,
const Analyzer::ColumnVar*)>
65 return colvar_set.size();
73 for (
const auto& column :
tuple_) {
74 column->collect_rte_idx(rte_idx_set);
79 std::vector<std::shared_ptr<Expr>> tuple_deep_copy;
80 for (
const auto& column :
tuple_) {
81 const auto column_deep_copy =
83 CHECK(column_deep_copy);
84 tuple_deep_copy.push_back(column_deep_copy);
86 return makeExpr<ExpressionTuple>(tuple_deep_copy);
131 std::list<std::shared_ptr<Analyzer::Expr>> new_value_list;
133 new_value_list.push_back(p->deep_copy());
135 return makeExpr<InValues>(
arg->deep_copy(), new_value_list);
143 return makeExpr<KeyForStringExpr>(
arg->deep_copy());
147 return makeExpr<SampleRatioExpr>(
arg->deep_copy());
151 return makeExpr<CardinalityExpr>(
arg->deep_copy());
155 return makeExpr<LikeExpr>(
arg->deep_copy(),
163 return makeExpr<RegexpExpr>(
arg->deep_copy(),
176 return makeExpr<LikelihoodExpr>(
arg->deep_copy(),
likelihood);
180 return makeExpr<AggExpr>(
185 std::list<std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>
188 new_list.emplace_back(p.first->deep_copy(), p.second->deep_copy());
193 else_expr ==
nullptr ?
nullptr : else_expr->deep_copy());
201 return makeExpr<DateaddExpr>(
206 return makeExpr<DatediffExpr>(
211 return makeExpr<DatetruncExpr>(
216 return makeExpr<OffsetInFragment>();
220 return makeExpr<WindowFunction>(
225 return makeExpr<Analyzer::ArrayExpr>(
247 *new_left_type = left_type;
248 *new_right_type = right_type;
251 throw std::runtime_error(
252 "non-boolean operands cannot be used in logic operations.");
256 if (left_type != right_type) {
259 *new_left_type = common_type;
261 *new_right_type = common_type;
268 throw std::runtime_error(
"Cannont compare between TIMESTAMP and TIME.");
275 *new_right_type = *new_left_type;
297 throw std::runtime_error(
"Cannont compare between TIME and TIMESTAMP.");
300 throw std::runtime_error(
"Cannont compare between TIME and DATE.");
325 *new_right_type = *new_left_type;
333 *new_right_type = *new_left_type;
337 throw std::runtime_error(
"Cannont compare between DATE and TIME.");
347 *new_left_type = right_type;
349 *new_right_type = right_type;
351 *new_left_type = left_type;
352 *new_right_type = left_type;
355 *new_left_type = left_type;
356 *new_right_type = right_type;
360 *new_left_type = common_type;
361 *new_right_type = common_type;
363 throw std::runtime_error(
"Cannot compare between " + left_type.
get_type_name() +
368 }
else if (op ==
kMINUS &&
371 *new_left_type = left_type;
372 *new_right_type = right_type;
373 result_type = left_type;
377 throw std::runtime_error(
"non-numeric operands in arithmetic operations.");
380 throw std::runtime_error(
"non-integer operands in modulo operation.");
399 *new_left_type = common_type;
401 *new_right_type = common_type;
407 result_type = common_type;
409 throw std::runtime_error(
"invalid binary operator type.");
469 std::string timeinterval_op_error{
470 "Operator type not supported for time interval arithmetic: "};
473 throw std::runtime_error(timeinterval_op_error + type2.
get_type_name());
479 throw std::runtime_error(timeinterval_op_error + type1.
get_type_name());
694 return shared_from_this();
708 return shared_from_this();
715 return shared_from_this();
723 if (has_non_literal_operands && new_type_info.
is_string() &&
727 throw std::runtime_error(
728 "Implict casts of TEXT ENCODING NONE to TEXT ENCODED DICT are not allowed "
729 "for non-literal arguments. Consider adding an explicit conversion to a "
730 "dictionary-encoded text type with ENCODE_TEXT(<none-encoded text arg>).");
732 throw std::runtime_error(
733 "Internal error: Cannot apply transient dictionary encoding "
734 "to non-literal expression.");
742 template <
typename T>
744 static_assert(std::is_floating_point_v<T>);
754 template <
typename FLOAT_TYPE,
typename INT_TYPE>
756 static_assert(std::is_integral_v<INT_TYPE> && std::is_floating_point_v<FLOAT_TYPE>);
758 std::numeric_limits<INT_TYPE>::digits - std::numeric_limits<FLOAT_TYPE>::digits;
759 if constexpr (0 < dd) {
760 return static_cast<FLOAT_TYPE
>(std::numeric_limits<INT_TYPE>::max() - (1ll << dd));
762 return static_cast<FLOAT_TYPE
>(std::numeric_limits<INT_TYPE>::max());
766 template <
typename TO,
typename FROM>
768 static_assert(std::is_integral_v<TO> && std::is_integral_v<FROM>);
769 static_assert(
sizeof(TO) <
sizeof(FROM));
770 if (from < static_cast<FROM>(std::numeric_limits<TO>::min()) ||
771 static_cast<FROM>(std::numeric_limits<TO>::max()) < from) {
772 throw std::runtime_error(
"Overflow or underflow");
774 return static_cast<TO
>(from);
777 template <
typename T>
779 static_assert(std::is_integral_v<T>);
780 constexpr
size_t max_scale = std::numeric_limits<uint64_t>::digits10;
781 constexpr
auto pow10 = shared::powersOf<uint64_t, max_scale + 1>(10);
783 if constexpr (
sizeof(
T) <
sizeof(int64_t)) {
784 return safeNarrow<T>(
n);
788 }
else if (max_scale < scale) {
791 uint64_t
const u = std::abs(n);
792 uint64_t
const pow = pow10[scale];
793 uint64_t div = u / pow;
794 uint64_t rem = u % pow;
795 div += pow / 2 <= rem;
796 if constexpr (
sizeof(
T) <
sizeof(int64_t)) {
797 return safeNarrow<T>(
static_cast<int64_t
>(n < 0 ? -div : div));
799 return n < 0 ? -div : div;
803 template <
typename TO,
typename FROM>
805 static_assert(std::is_integral_v<TO> && std::is_floating_point_v<FROM>);
806 constexpr FROM max_float = maxRound<FROM, TO>();
807 FROM
const n = std::round(from);
808 if (n < static_cast<FROM>(std::numeric_limits<TO>::min()) || max_float < n) {
809 throw std::runtime_error(
"Overflow or underflow");
811 return static_cast<TO
>(
n);
815 template <
typename T>
817 static_assert(std::is_arithmetic_v<T>);
818 constexpr
size_t max_scale = std::numeric_limits<int64_t>::digits10;
819 constexpr
auto pow10 = shared::powersOf<int64_t, max_scale + 1>(10);
820 if constexpr (std::is_integral_v<T>) {
822 if (scale < pow10.size()) {
824 if (!__builtin_mul_overflow(from, pow10[scale], &retval)) {
829 return from * pow10[scale];
832 }
else if constexpr (std::is_floating_point_v<T>) {
833 if (scale < pow10.size()) {
834 return safeRound<int64_t>(from * pow10[scale]);
840 throw std::runtime_error(
"Overflow or underflow");
1017 switch (new_type_info.
get_type()) {
1053 switch (new_type_info.
get_type()) {
1074 for (
int i = 0; i < new_type_info.
get_scale(); i++) {
1083 switch (new_type_info.
get_type()) {
1106 for (
int i = 0; i < new_type_info.
get_scale(); i++) {
1123 static_cast<size_t>(new_type_info.
get_dimension()) < s->length()) {
1190 return constval.
arrayval ==
nullptr;
1257 throw std::runtime_error(
"Invalid array cast.");
1259 c->do_cast(new_sub_ti);
1334 return shared_from_this();
1346 const auto is_integral_type =
1353 return shared_from_this();
1384 std::list<std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>
1387 new_expr_pair_list.emplace_back(
1388 std::make_pair(p.first, p.second->deep_copy()->add_cast(ti)));
1395 expr_pair_list = new_expr_pair_list;
1398 return shared_from_this();
1410 if (rte->get_rangevar() ==
name) {
1423 const std::list<std::shared_ptr<Analyzer::Expr>>& groupby)
const {
1424 if (!groupby.empty()) {
1425 for (
auto e : groupby) {
1426 auto c = std::dynamic_pointer_cast<
ColumnVar>(e);
1432 throw std::runtime_error(
1433 "expressions in the SELECT or HAVING clause must be an aggregate function or an "
1435 "over GROUP BY columns.");
1439 const std::list<std::shared_ptr<Analyzer::Expr>>& groupby)
const {
1441 throw std::runtime_error(
"Internal error: invalid VAR in GROUP BY or HAVING.");
1446 const std::list<std::shared_ptr<Analyzer::Expr>>& groupby)
const {
1447 operand->check_group_by(groupby);
1451 const std::list<std::shared_ptr<Analyzer::Expr>>& groupby)
const {
1459 bool expr_is(
const std::shared_ptr<Analyzer::Expr>& expr) {
1460 return std::dynamic_pointer_cast<
T>(expr) !=
nullptr;
1466 const std::shared_ptr<Analyzer::Expr> cast_operand,
1467 const std::shared_ptr<Analyzer::Expr> const_operand) {
1468 if (expr_is<UOper>(cast_operand) && expr_is<Constant>(const_operand)) {
1469 auto u_expr = std::dynamic_pointer_cast<
UOper>(cast_operand);
1470 if (u_expr->get_optype() !=
kCAST) {
1473 if (!(expr_is<Analyzer::ColumnVar>(u_expr->get_own_operand()) &&
1474 !expr_is<Analyzer::Var>(u_expr->get_own_operand()))) {
1478 if (ti.is_time() && u_expr->get_operand()->get_type_info().is_time()) {
1481 }
else if (ti.is_integer() && u_expr->get_operand()->get_type_info().is_integer()) {
1497 auto cv = std::dynamic_pointer_cast<
ColumnVar>(uo->get_own_operand());
1504 auto cv = std::dynamic_pointer_cast<
ColumnVar>(uo->get_own_operand());
1533 std::list<const Expr*>& join_predicates,
1534 std::list<const Expr*>& const_predicates)
const {
1536 scan_predicates.push_back(
this);
1541 std::list<const Expr*>& join_predicates,
1542 std::list<const Expr*>& const_predicates)
const {
1543 std::set<int> rte_idx_set;
1544 operand->collect_rte_idx(rte_idx_set);
1545 if (rte_idx_set.size() > 1) {
1546 join_predicates.push_back(
this);
1547 }
else if (rte_idx_set.size() == 1) {
1548 scan_predicates.push_back(
this);
1550 const_predicates.push_back(
this);
1555 std::list<const Expr*>& join_predicates,
1556 std::list<const Expr*>& const_predicates)
const {
1558 left_operand->group_predicates(scan_predicates, join_predicates, const_predicates);
1559 right_operand->group_predicates(scan_predicates, join_predicates, const_predicates);
1562 std::set<int> rte_idx_set;
1565 if (rte_idx_set.size() > 1) {
1566 join_predicates.push_back(
this);
1567 }
else if (rte_idx_set.size() == 1) {
1568 scan_predicates.push_back(
this);
1570 const_predicates.push_back(
this);
1586 const std::list<std::shared_ptr<Analyzer::Expr>>& l) {
1590 for (
const auto& v : l) {
1601 const std::list<std::shared_ptr<Analyzer::Expr>>& l)
1605 std::list<const Expr*>& join_predicates,
1606 std::list<const Expr*>& const_predicates)
const {
1607 std::set<int> rte_idx_set;
1608 arg->collect_rte_idx(rte_idx_set);
1609 if (rte_idx_set.size() > 1) {
1610 join_predicates.push_back(
this);
1611 }
else if (rte_idx_set.size() == 1) {
1612 scan_predicates.push_back(
this);
1614 const_predicates.push_back(
this);
1619 const std::vector<int64_t>& l,
1620 const bool not_null)
1624 std::list<const Expr*>& join_predicates,
1625 std::list<const Expr*>& const_predicates)
const {
1626 std::set<int> rte_idx_set;
1627 arg->collect_rte_idx(rte_idx_set);
1628 if (rte_idx_set.size() > 1) {
1629 join_predicates.push_back(
this);
1630 }
else if (rte_idx_set.size() == 1) {
1631 scan_predicates.push_back(
this);
1633 const_predicates.push_back(
this);
1638 std::list<const Expr*>& join_predicates,
1639 std::list<const Expr*>& const_predicates)
const {
1640 std::set<int> rte_idx_set;
1641 arg->collect_rte_idx(rte_idx_set);
1642 if (rte_idx_set.size() > 1) {
1643 join_predicates.push_back(
this);
1644 }
else if (rte_idx_set.size() == 1) {
1645 scan_predicates.push_back(
this);
1647 const_predicates.push_back(
this);
1652 std::list<const Expr*>& join_predicates,
1653 std::list<const Expr*>& const_predicates)
const {
1654 std::set<int> rte_idx_set;
1655 arg->collect_rte_idx(rte_idx_set);
1656 if (rte_idx_set.size() > 1) {
1657 join_predicates.push_back(
this);
1658 }
else if (rte_idx_set.size() == 1) {
1659 scan_predicates.push_back(
this);
1661 const_predicates.push_back(
this);
1666 std::list<const Expr*>& join_predicates,
1667 std::list<const Expr*>& const_predicates)
const {
1668 std::set<int> rte_idx_set;
1669 for (
const auto& arg :
args_) {
1670 arg->collect_rte_idx(rte_idx_set);
1672 if (rte_idx_set.size() > 1) {
1673 join_predicates.push_back(
this);
1674 }
else if (rte_idx_set.size() == 1) {
1675 scan_predicates.push_back(
this);
1677 const_predicates.push_back(
this);
1682 std::list<const Expr*>& join_predicates,
1683 std::list<const Expr*>& const_predicates)
const {
1684 std::set<int> rte_idx_set;
1685 arg->collect_rte_idx(rte_idx_set);
1686 if (rte_idx_set.size() > 1) {
1687 join_predicates.push_back(
this);
1688 }
else if (rte_idx_set.size() == 1) {
1689 scan_predicates.push_back(
this);
1691 const_predicates.push_back(
this);
1696 std::list<const Expr*>& join_predicates,
1697 std::list<const Expr*>& const_predicates)
const {
1698 std::set<int> rte_idx_set;
1699 arg->collect_rte_idx(rte_idx_set);
1700 if (rte_idx_set.size() > 1) {
1701 join_predicates.push_back(
this);
1702 }
else if (rte_idx_set.size() == 1) {
1703 scan_predicates.push_back(
this);
1705 const_predicates.push_back(
this);
1710 std::list<const Expr*>& join_predicates,
1711 std::list<const Expr*>& const_predicates)
const {
1712 std::set<int> rte_idx_set;
1713 arg->collect_rte_idx(rte_idx_set);
1714 if (rte_idx_set.size() > 1) {
1715 join_predicates.push_back(
this);
1716 }
else if (rte_idx_set.size() == 1) {
1717 scan_predicates.push_back(
this);
1719 const_predicates.push_back(
this);
1724 std::list<const Expr*>& join_predicates,
1725 std::list<const Expr*>& const_predicates)
const {
1726 std::set<int> rte_idx_set;
1728 if (rte_idx_set.size() > 1) {
1729 join_predicates.push_back(
this);
1730 }
else if (rte_idx_set.size() == 1) {
1731 scan_predicates.push_back(
this);
1733 const_predicates.push_back(
this);
1738 std::list<const Expr*>& join_predicates,
1739 std::list<const Expr*>& const_predicates)
const {
1740 std::set<int> rte_idx_set;
1741 arg->collect_rte_idx(rte_idx_set);
1742 if (rte_idx_set.size() > 1) {
1743 join_predicates.push_back(
this);
1744 }
else if (rte_idx_set.size() == 1) {
1745 scan_predicates.push_back(
this);
1747 const_predicates.push_back(
this);
1752 std::list<const Expr*>& join_predicates,
1753 std::list<const Expr*>& const_predicates)
const {
1754 std::set<int> rte_idx_set;
1755 arg->collect_rte_idx(rte_idx_set);
1756 if (rte_idx_set.size() > 1) {
1757 join_predicates.push_back(
this);
1758 }
else if (rte_idx_set.size() == 1) {
1759 scan_predicates.push_back(
this);
1761 const_predicates.push_back(
this);
1766 std::list<const Expr*>& join_predicates,
1767 std::list<const Expr*>& const_predicates)
const {
1768 std::set<int> rte_idx_set;
1770 p.first->collect_rte_idx(rte_idx_set);
1771 p.second->collect_rte_idx(rte_idx_set);
1774 else_expr->collect_rte_idx(rte_idx_set);
1776 if (rte_idx_set.size() > 1) {
1777 join_predicates.push_back(
this);
1778 }
else if (rte_idx_set.size() == 1) {
1779 scan_predicates.push_back(
this);
1781 const_predicates.push_back(
this);
1786 std::list<const Expr*>& join_predicates,
1787 std::list<const Expr*>& const_predicates)
const {
1788 std::set<int> rte_idx_set;
1790 if (rte_idx_set.size() > 1) {
1791 join_predicates.push_back(
this);
1792 }
else if (rte_idx_set.size() == 1) {
1793 scan_predicates.push_back(
this);
1795 const_predicates.push_back(
this);
1800 std::list<const Expr*>& join_predicates,
1801 std::list<const Expr*>& const_predicates)
const {
1802 std::set<int> rte_idx_set;
1803 number_->collect_rte_idx(rte_idx_set);
1804 datetime_->collect_rte_idx(rte_idx_set);
1805 if (rte_idx_set.size() > 1) {
1806 join_predicates.push_back(
this);
1807 }
else if (rte_idx_set.size() == 1) {
1808 scan_predicates.push_back(
this);
1810 const_predicates.push_back(
this);
1815 std::list<const Expr*>& join_predicates,
1816 std::list<const Expr*>& const_predicates)
const {
1817 std::set<int> rte_idx_set;
1818 start_->collect_rte_idx(rte_idx_set);
1819 end_->collect_rte_idx(rte_idx_set);
1820 if (rte_idx_set.size() > 1) {
1821 join_predicates.push_back(
this);
1822 }
else if (rte_idx_set.size() == 1) {
1823 scan_predicates.push_back(
this);
1825 const_predicates.push_back(
this);
1830 std::list<const Expr*>& join_predicates,
1831 std::list<const Expr*>& const_predicates)
const {
1832 std::set<int> rte_idx_set;
1834 if (rte_idx_set.size() > 1) {
1835 join_predicates.push_back(
this);
1836 }
else if (rte_idx_set.size() == 1) {
1837 scan_predicates.push_back(
this);
1839 const_predicates.push_back(
this);
1844 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
1845 for (
auto tle : tlist) {
1846 const Expr* e = tle->get_expr();
1848 if (colvar !=
nullptr) {
1854 throw std::runtime_error(
"Internal error: cannot find ColumnVar in targetlist.");
1858 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
1860 for (
auto tle : tlist) {
1861 const Expr* e = tle->get_expr();
1863 if (colvar ==
nullptr) {
1864 throw std::runtime_error(
1865 "Internal Error: targetlist in rewrite_with_child_targetlist is not all "
1878 throw std::runtime_error(
"Internal error: cannot find ColumnVar in child targetlist.");
1882 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
1884 for (
auto tle : tlist) {
1885 const Expr* e = tle->get_expr();
1886 if (
typeid(*e) !=
typeid(
AggExpr)) {
1888 if (colvar ==
nullptr) {
1889 throw std::runtime_error(
1890 "Internal Error: targetlist in rewrite_agg_to_var is not all columns and "
1904 throw std::runtime_error(
1905 "Internal error: cannot find ColumnVar from having clause in targetlist.");
1909 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
1911 for (
auto tle : tlist) {
1912 const Expr* e = tle->get_expr();
1918 throw std::runtime_error(
1919 "Internal error: cannot find Var from having clause in targetlist.");
1923 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
1924 std::vector<std::shared_ptr<Analyzer::Expr>> rewritten_args;
1925 for (
const auto& arg :
args_) {
1926 rewritten_args.emplace_back(arg->rewrite_with_targetlist(tlist));
1928 return makeExpr<StringOper>(
kind_, rewritten_args);
1932 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
1933 std::vector<std::shared_ptr<Analyzer::Expr>> rewritten_args;
1934 for (
const auto& arg :
args_) {
1935 rewritten_args.emplace_back(arg->rewrite_with_child_targetlist(tlist));
1937 return makeExpr<StringOper>(
kind_, rewritten_args);
1941 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
1942 std::vector<std::shared_ptr<Analyzer::Expr>> rewritten_args;
1943 for (
const auto& arg :
args_) {
1944 rewritten_args.emplace_back(arg->rewrite_agg_to_var(tlist));
1946 return makeExpr<StringOper>(
kind_, rewritten_args);
1950 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
1951 std::list<std::shared_ptr<Analyzer::Expr>> new_value_list;
1953 new_value_list.push_back(v->deep_copy());
1955 return makeExpr<InValues>(
arg->rewrite_with_targetlist(tlist), new_value_list);
1959 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
1960 std::list<std::shared_ptr<Analyzer::Expr>> new_value_list;
1962 new_value_list.push_back(v->deep_copy());
1964 return makeExpr<InValues>(
arg->rewrite_with_child_targetlist(tlist), new_value_list);
1968 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
1969 std::list<std::shared_ptr<Analyzer::Expr>> new_value_list;
1971 new_value_list.push_back(v->rewrite_agg_to_var(tlist));
1973 return makeExpr<InValues>(
arg->rewrite_agg_to_var(tlist), new_value_list);
1977 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
1978 for (
auto tle : tlist) {
1979 const Expr* e = tle->get_expr();
1980 if (
typeid(*e) ==
typeid(
AggExpr)) {
1982 if (*
this == *agg) {
1987 throw std::runtime_error(
"Internal error: cannot find AggExpr in targetlist.");
1991 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
1994 arg ?
arg->rewrite_with_child_targetlist(tlist) :
nullptr,
2000 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2002 for (
auto tle : tlist) {
2003 const Expr* e = tle->get_expr();
2004 if (
typeid(*e) ==
typeid(
AggExpr)) {
2006 if (*
this == *agg_expr) {
2012 throw std::runtime_error(
2013 "Internal error: cannot find AggExpr from having clause in targetlist.");
2017 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2018 std::list<std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>
2021 epair_list.emplace_back(p.first->rewrite_with_targetlist(tlist),
2022 p.second->rewrite_with_targetlist(tlist));
2024 return makeExpr<CaseExpr>(
2032 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2033 return makeExpr<ExtractExpr>(
2038 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2041 number_->rewrite_with_targetlist(tlist),
2042 datetime_->rewrite_with_targetlist(tlist));
2046 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2047 return makeExpr<DatediffExpr>(
type_info,
2049 start_->rewrite_with_targetlist(tlist),
2050 end_->rewrite_with_targetlist(tlist));
2054 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2055 return makeExpr<DatetruncExpr>(
2060 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2061 std::list<std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>
2064 epair_list.emplace_back(p.first->rewrite_with_child_targetlist(tlist),
2065 p.second->rewrite_with_child_targetlist(tlist));
2067 return makeExpr<CaseExpr>(
2075 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2076 return makeExpr<ExtractExpr>(
2081 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2084 number_->rewrite_with_child_targetlist(tlist),
2085 datetime_->rewrite_with_child_targetlist(tlist));
2089 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2090 return makeExpr<DatediffExpr>(
type_info,
2092 start_->rewrite_with_child_targetlist(tlist),
2093 end_->rewrite_with_child_targetlist(tlist));
2097 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2098 return makeExpr<DatetruncExpr>(
2103 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2104 std::list<std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>
2107 epair_list.emplace_back(p.first->rewrite_agg_to_var(tlist),
2108 p.second->rewrite_agg_to_var(tlist));
2117 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2118 return makeExpr<ExtractExpr>(
2123 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2126 number_->rewrite_agg_to_var(tlist),
2131 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2132 return makeExpr<DatediffExpr>(
type_info,
2134 start_->rewrite_agg_to_var(tlist),
2135 end_->rewrite_agg_to_var(tlist));
2139 const std::vector<std::shared_ptr<TargetEntry>>& tlist)
const {
2140 return makeExpr<DatetruncExpr>(
2145 if (
typeid(rhs) !=
typeid(
ColumnVar) &&
typeid(rhs) !=
typeid(
Var)) {
2153 const Var* v =
dynamic_cast<const Var*
>(
this);
2157 const Var* rv =
dynamic_cast<const Var*
>(&rhs);
2158 if (rv ==
nullptr) {
2170 const auto& rhs_tuple_cols = rhs_tuple->
getTuple();
2208 throw std::runtime_error(
"Unrecognized type for Constant Datum equality: " +
2216 if (
typeid(rhs) !=
typeid(
Constant)) {
2233 if (
typeid(rhs) !=
typeid(
UOper)) {
2236 const UOper& rhs_uo =
dynamic_cast<const UOper&
>(rhs);
2241 if (
typeid(rhs) !=
typeid(
BinOper)) {
2306 if (
typeid(rhs) !=
typeid(
LikeExpr)) {
2377 if (
typeid(rhs) !=
typeid(
InValues)) {
2398 if (
typeid(rhs) !=
typeid(
AggExpr)) {
2408 if (
arg ==
nullptr || rhs_ae.
get_arg() ==
nullptr) {
2415 if (
typeid(rhs) !=
typeid(
CaseExpr)) {
2428 if (!(*p.first == *it->first) || !(*p.second == *it->second)) {
2476 const auto rhs_window =
dynamic_cast<const WindowFunction*
>(&rhs);
2480 if (
kind_ != rhs_window->kind_ ||
args_.size() != rhs_window->args_.size() ||
2482 order_keys_.size() != rhs_window->order_keys_.size()) {
2498 if (!(lhs_expr == rhs_expr)) {
2511 const auto rhs_geo =
dynamic_cast<const GeoUOper*
>(&rhs);
2515 if (
op_ != rhs_geo->getOp() ||
ti0_ != rhs_geo->getTypeInfo0() ||
2516 args0_.size() != rhs_geo->getArgs0().size()) {
2523 const auto rhs_geo =
dynamic_cast<const GeoBinOper*
>(&rhs);
2527 if (
op_ != rhs_geo->getOp() ||
ti0_ != rhs_geo->getTypeInfo0() ||
2528 args0_.size() != rhs_geo->getArgs0().size()) {
2531 if (
ti1_ != rhs_geo->getTypeInfo1() ||
args1_.size() != rhs_geo->getArgs1().size()) {
2545 std::string str{
"< "};
2546 for (
const auto& column :
tuple_) {
2547 str += column->toString();
2561 std::string str{
"(Const "};
2602 return "(" + op +
operand->toString() +
") ";
2656 std::string str{
"("};
2672 return "(RangeOper " + lhs +
" " +
left_operand_->toString() +
" , " +
2677 return "(Subquery ) ";
2681 std::string str{
"(IN "};
2682 str +=
arg->toString();
2685 bool shorted_value_list_str =
false;
2687 str += e->toString();
2690 shorted_value_list_str =
true;
2694 if (shorted_value_list_str) {
2696 str +=
"Total # values: ";
2708 if (!dynamic_cast<const InIntegerSet*>(&rhs)) {
2711 const auto& rhs_in_integer_set =
static_cast<const InIntegerSet&
>(rhs);
2712 return *
arg == *rhs_in_integer_set.arg &&
value_list == rhs_in_integer_set.value_list;
2716 std::string str{
"(IN_INTEGER_SET "};
2717 str +=
arg->toString();
2720 bool shorted_value_list_str =
false;
2725 shorted_value_list_str =
true;
2729 if (shorted_value_list_str) {
2731 str +=
"Total # values: ";
2741 str +=
"CHAR_LENGTH(";
2745 str +=
arg->toString();
2751 std::string str{
"KEY_FOR_STRING("};
2752 str +=
arg->toString();
2758 std::string str{
"SAMPLE_RATIO("};
2759 str +=
arg->toString();
2765 std::string str{
"CARDINALITY("};
2766 str +=
arg->toString();
2772 std::string str{
"(LIKE "};
2773 str +=
arg->toString();
2783 std::string str{
"(REGEXP "};
2784 str +=
arg->toString();
2794 std::string str{
"(WIDTH_BUCKET "};
2803 std::string str{
"(LIKELIHOOD "};
2804 str +=
arg->toString();
2827 agg =
"APPROX_COUNT_DISTINCT";
2830 agg =
"APPROX_PERCENTILE";
2833 agg =
"SINGLE_VALUE";
2839 std::string str{
"(" + agg};
2844 str +=
arg->toString();
2852 std::string str{
"CASE "};
2855 str += p.first->toString();
2857 str += p.second->toString();
2874 " DATETIME " +
datetime_->toString() +
") ";
2879 end_->toString() +
") ";
2887 return "(OffsetInFragment) ";
2892 for (
const auto& arg :
args_) {
2893 result +=
" " + arg->toString();
2895 return result +
") ";
2899 std::string str{
"ARRAY["};
2903 str += (*iter)->toString();
2929 std::string
result = fn +
"(";
2930 for (
const auto& arg :
args0_) {
2931 result +=
" " + arg->toString();
2933 return result +
" ) ";
2940 fn =
"ST_Intersection";
2943 fn =
"ST_Difference";
2955 std::string
result = fn +
"(";
2957 for (
const auto& arg :
args0_) {
2958 result +=
" " + arg->toString();
2960 for (
const auto& arg :
args1_) {
2961 result +=
" " + arg->toString();
2963 return result +
" ) ";
2967 std::string str{
"(" +
resname +
" "};
2968 str +=
expr->toString();
2982 str +=
" nulls first";
2990 for (
auto e : expr_list) {
2995 expr_list.push_back(
this);
3016 std::list<const Expr*>& expr_list)
const {
3021 arg->find_expr(
f, expr_list);
3023 e->find_expr(
f, expr_list);
3028 std::list<const Expr*>& expr_list)
const {
3033 arg->find_expr(
f, expr_list);
3037 std::list<const Expr*>& expr_list)
const {
3042 arg->find_expr(
f, expr_list);
3046 std::list<const Expr*>& expr_list)
const {
3051 arg->find_expr(
f, expr_list);
3055 std::list<const Expr*>& expr_list)
const {
3060 for (
const auto& arg :
args_) {
3061 arg->find_expr(
f, expr_list);
3066 std::list<const Expr*>& expr_list)
const {
3071 arg->find_expr(
f, expr_list);
3075 std::list<const Expr*>& expr_list)
const {
3080 arg->find_expr(
f, expr_list);
3088 std::list<const Expr*>& expr_list)
const {
3093 arg->find_expr(
f, expr_list);
3101 std::list<const Expr*>& expr_list)
const {
3113 std::list<const Expr*>& expr_list)
const {
3118 arg->find_expr(
f, expr_list);
3126 if (
arg !=
nullptr) {
3127 arg->find_expr(
f, expr_list);
3132 std::list<const Expr*>& expr_list)
const {
3138 p.first->find_expr(
f, expr_list);
3139 p.second->find_expr(
f, expr_list);
3147 std::list<const Expr*>& expr_list)
const {
3156 std::list<const Expr*>& expr_list)
const {
3166 std::list<const Expr*>& expr_list)
const {
3171 start_->find_expr(
f, expr_list);
3172 end_->find_expr(
f, expr_list);
3176 std::list<const Expr*>& expr_list)
const {
3186 p.first->collect_rte_idx(rte_idx_set);
3187 p.second->collect_rte_idx(rte_idx_set);
3190 else_expr->collect_rte_idx(rte_idx_set);
3199 number_->collect_rte_idx(rte_idx_set);
3200 datetime_->collect_rte_idx(rte_idx_set);
3204 start_->collect_rte_idx(rte_idx_set);
3205 end_->collect_rte_idx(rte_idx_set);
3215 expr->collect_rte_idx(rte_idx_set);
3220 for (
const auto& arg :
args_) {
3221 arg->collect_rte_idx(rte_idx_set);
3226 for (
unsigned i = 0; i <
getArity(); i++) {
3227 const auto expr =
getArg(i);
3228 expr->collect_rte_idx(rte_idx_set);
3234 bool include_agg)
const {
3236 p.first->collect_column_var(colvar_set, include_agg);
3237 p.second->collect_column_var(colvar_set, include_agg);
3240 else_expr->collect_column_var(colvar_set, include_agg);
3246 bool include_agg)
const {
3247 from_expr_->collect_column_var(colvar_set, include_agg);
3252 bool include_agg)
const {
3253 number_->collect_column_var(colvar_set, include_agg);
3254 datetime_->collect_column_var(colvar_set, include_agg);
3259 bool include_agg)
const {
3260 start_->collect_column_var(colvar_set, include_agg);
3261 end_->collect_column_var(colvar_set, include_agg);
3266 bool include_agg)
const {
3267 from_expr_->collect_column_var(colvar_set, include_agg);
3272 bool include_agg)
const {
3275 expr->collect_column_var(colvar_set, include_agg);
3281 bool include_agg)
const {
3282 for (
const auto& arg :
args_) {
3283 arg->collect_column_var(colvar_set, include_agg);
3289 bool include_agg)
const {
3290 for (
unsigned i = 0; i <
getArity(); i++) {
3291 const auto expr =
getArg(i);
3292 expr->collect_column_var(colvar_set, include_agg);
3297 const std::list<std::shared_ptr<Analyzer::Expr>>& groupby)
const {
3299 p.first->check_group_by(groupby);
3300 p.second->check_group_by(groupby);
3308 const std::list<std::shared_ptr<Analyzer::Expr>>& groupby)
const {
3313 const std::list<std::shared_ptr<Analyzer::Expr>>& groupby)
const {
3314 number_->check_group_by(groupby);
3319 const std::list<std::shared_ptr<Analyzer::Expr>>& groupby)
const {
3320 start_->check_group_by(groupby);
3321 end_->check_group_by(groupby);
3325 const std::list<std::shared_ptr<Analyzer::Expr>>& groupby)
const {
3331 const auto c = std::dynamic_pointer_cast<
const Constant>(p.second);
3335 const auto v = std::dynamic_pointer_cast<
const ColumnVar>(p.second);
3339 const auto cast = std::dynamic_pointer_cast<
const UOper>(p.second);
3340 if (cast !=
nullptr && cast->get_optype() ==
kCAST) {
3346 const auto v = std::dynamic_pointer_cast<
const ColumnVar>(p.second);
3353 p.second->get_domain(domain_set);
3354 if (domain_set.empty()) {
3369 const auto cast = std::dynamic_pointer_cast<
const UOper>(
else_expr);
3370 if (cast !=
nullptr && cast->get_optype() ==
kCAST) {
3389 std::vector<std::shared_ptr<Analyzer::Expr>> args_copy;
3390 for (
const auto& arg :
args_) {
3391 args_copy.emplace_back(arg->deep_copy());
3393 std::vector<std::shared_ptr<Analyzer::Expr>> chained_string_op_exprs_copy;
3395 chained_string_op_exprs_copy.emplace_back(chained_string_op_expr->deep_copy());
3397 return makeExpr<Analyzer::StringOper>(
3398 kind_, std::move(args_copy), std::move(chained_string_op_exprs_copy));
3402 return makeExpr<Analyzer::LowerStringOper>(
3407 return makeExpr<Analyzer::UpperStringOper>(
3412 return makeExpr<Analyzer::InitCapStringOper>(
3417 return makeExpr<Analyzer::ReverseStringOper>(
3422 return makeExpr<Analyzer::RepeatStringOper>(
3427 return makeExpr<Analyzer::PadStringOper>(
3432 return makeExpr<Analyzer::TrimStringOper>(
3437 return makeExpr<Analyzer::SubstringStringOper>(
3442 return makeExpr<Analyzer::ReplaceStringOper>(
3447 return makeExpr<Analyzer::OverlayStringOper>(
3452 return makeExpr<Analyzer::ConcatStringOper>(
3457 return makeExpr<Analyzer::SplitPartStringOper>(
3462 return makeExpr<Analyzer::RegexpReplaceStringOper>(
3467 return makeExpr<Analyzer::RegexpSubstrStringOper>(
3472 std::vector<std::shared_ptr<Analyzer::Expr>> args_copy;
3473 for (
size_t i = 0; i <
getArity(); ++i) {
3480 const auto rhs_string_oper =
dynamic_cast<const StringOper*
>(&rhs);
3482 if (!rhs_string_oper) {
3486 if (
get_kind() != rhs_string_oper->get_kind()) {
3489 if (
getArity() != rhs_string_oper->getArity()) {
3493 for (
size_t i = 0; i <
getArity(); ++i) {
3494 if (!(*
getArg(i) == *(rhs_string_oper->getArg(i)))) {
3499 rhs_string_oper->chained_string_op_exprs_.size()) {
3504 *(rhs_string_oper->chained_string_op_exprs_[i]))) {
3515 const auto rhs_func_oper =
dynamic_cast<const FunctionOper*
>(&rhs);
3516 if (!rhs_func_oper) {
3519 if (
getName() != rhs_func_oper->getName()) {
3522 if (
getArity() != rhs_func_oper->getArity()) {
3525 for (
size_t i = 0; i <
getArity(); ++i) {
3526 if (!(*
getArg(i) == *(rhs_func_oper->getArg(i)))) {
3535 for (
const auto& arg :
args_) {
3536 str += arg->toString();
3543 std::string str{
"(" +
name_ +
" "};
3544 for (
const auto& arg :
args_) {
3545 str += arg->toString();
3552 std::vector<std::shared_ptr<Analyzer::Expr>> args_copy;
3553 for (
size_t i = 0; i <
getArity(); ++i) {
3556 return makeExpr<Analyzer::FunctionOperWithCustomTypeHandling>(
3564 const auto rhs_func_oper =
3566 if (!rhs_func_oper) {
3569 if (
getName() != rhs_func_oper->getName()) {
3572 if (
getArity() != rhs_func_oper->getArity()) {
3575 for (
size_t i = 0; i <
getArity(); ++i) {
3576 if (!(*
getArg(i) == *(rhs_func_oper->getArg(i)))) {
3585 auto copied_expr = bound_expr->
deep_copy();
3588 auto casted_constant = std::dynamic_pointer_cast<
const Analyzer::Constant>(casted_expr);
3589 CHECK(casted_constant);
3590 return casted_constant->get_constval().doubleval;
3594 auto const_partition_count_expr =
3596 if (!const_partition_count_expr) {
3600 switch (const_partition_count_expr->get_type_info().get_type()) {
3602 return d.tinyintval;
3604 return d.smallintval;
3608 auto bi = d.bigintval;
3609 if (bi < 1 || bi > INT32_MAX) {
3647 :
GeoExpr(ti), geo_(std::move(geo)) {
3650 throw std::runtime_error(
"Conflicting types for geo data " +
geo_->getWktString() +
3661 std::string str{
"(GeoConstant "};
3663 str +=
geo_->getWktString();
3670 return geo_->getWktString();
3696 const size_t index)
const {
3700 CHECK_LE(index,
size_t(num_phys_coords));
3703 std::vector<double> coords;
3704 std::vector<double> bounds;
3705 std::vector<int> ring_sizes;
3706 std::vector<int> poly_rings;
3709 geo_->getWktString(), ti, coords, bounds, ring_sizes, poly_rings);
3737 throw std::runtime_error(
"Failed to transform constant geometry: " +
toString());
3743 return makeExpr<GeoConstant>(std::move(
geo_), cast_type_info);
3747 const std::string&
name,
3748 const std::vector<std::shared_ptr<Analyzer::Expr>>&
args,
3749 const std::optional<int>& output_srid_override)
3753 , output_srid_override_(output_srid_override) {}
3756 std::vector<std::shared_ptr<Analyzer::Expr>>
args;
3757 for (
size_t i = 0; i <
args_.size(); i++) {
3764 for (
size_t i = 0; i <
size(); i++) {
3766 expr->collect_rte_idx(rte_idx_set);
3772 bool include_agg)
const {
3773 for (
size_t i = 0; i <
size(); i++) {
3775 expr->collect_column_var(colvar_set, include_agg);
3780 std::string str{
"(" +
name_ +
" "};
3781 for (
const auto& arg :
args_) {
3782 str += arg->toString();
3799 for (
size_t i = 0; i <
size(); i++) {
3808 return args_.size();
3813 return args_[index].get();
3818 std::vector<std::shared_ptr<Analyzer::Expr>>
args;
3819 for (
size_t i = 0; i <
args_.size(); i++) {
3826 return makeExpr<UOper>(new_type_info,
false,
kCAST, new_expr);
3831 std::vector<std::shared_ptr<Analyzer::Expr>>
args;
3832 for (
size_t i = 0; i <
args_.size(); i++) {
3835 return makeExpr<GeoTransformOperator>(
3840 std::string str{
"(" +
name_ +
" "};
3841 for (
const auto& arg :
args_) {
3842 str += arg->toString();
3861 for (
size_t i = 0; i <
size(); i++) {
3878 bool (*)(
const Analyzer::ColumnVar*,
const Analyzer::ColumnVar*)>
3879 colvar_set(comparator);
3881 if (colvar_set.size() != 1UL) {
3884 auto col_expr_ptr = *colvar_set.begin();
3885 CHECK(col_expr_ptr);
3886 return col_expr_ptr->get_type_info().is_dict_encoded_string();
3890 std::vector<size_t> literal_arg_indexes;
3891 const auto num_args =
args_.size();
3892 for (
size_t idx = 0; idx < num_args; ++idx) {
3893 if (dynamic_cast<const Constant*>(
args_[idx].
get())) {
3894 literal_arg_indexes.emplace_back(idx);
3897 return literal_arg_indexes;
3905 for (
size_t idx = 0; idx < num_args; ++idx) {
3907 if (constant_arg_expr) {
3908 literal_arg_map.emplace(
3910 std::make_pair(constant_arg_expr->get_type_info().get_type(),
3911 constant_arg_expr->get_constval())));
3914 return literal_arg_map;
3918 const std::vector<std::shared_ptr<Analyzer::Expr>>
args) {
3923 if (dynamic_cast<const Analyzer::Constant*>(
args[0].
get())) {
3924 return args[0]->get_type_info();
3940 const size_t min_args,
3941 const std::vector<OperandTypeFamily>& expected_type_families,
3942 const std::vector<std::string>& arg_names,
3943 const bool dict_encoded_cols_only,
3944 const bool cols_first_arg_only)
const {
3945 std::ostringstream oss;
3948 throw std::runtime_error(oss.str());
3950 const size_t num_args =
args_.size();
3951 CHECK_EQ(expected_type_families.size(), arg_names.size());
3952 if (num_args < min_args || num_args > expected_type_families.size()) {
3954 oss <<
"Expected " << expected_type_families.size() <<
" arguments, but received "
3957 for (
size_t arg_idx = 0; arg_idx < num_args; ++arg_idx) {
3958 const auto& expected_type_family = expected_type_families[arg_idx];
3962 auto arg_ti =
args_[arg_idx]->get_type_info();
3964 const bool is_arg_constant =
3966 const bool is_arg_column_var =
3968 const bool is_arg_string_oper =
3970 if (!(is_arg_constant || is_arg_column_var || is_arg_string_oper)) {
3972 <<
"Currently only constant, column, or other string operator arguments "
3973 <<
"are allowed as inputs.";
3974 throw std::runtime_error(oss.str());
3976 auto decasted_arg_ti = decasted_arg->get_type_info();
3981 if (arg_ti != decasted_arg_ti &&
3982 ((arg_ti.is_string() && !decasted_arg_ti.is_string()) ||
3983 (arg_ti.is_integer() && decasted_arg_ti.is_string()))) {
3984 arg_ti = decasted_arg_ti;
3987 if (cols_first_arg_only && !is_arg_constant && arg_idx >= 1UL) {
3989 <<
"Currently only column inputs allowed for the primary argument, "
3990 <<
"but a column input was received for argument " << arg_idx + 1 <<
".";
3991 throw std::runtime_error(oss.str());
3993 switch (expected_type_family) {
3995 if (!arg_ti.is_string()) {
3997 <<
"Expected text type for argument " << arg_idx + 1 <<
" ("
3998 << arg_names[arg_idx] <<
").";
3999 throw std::runtime_error(oss.str());
4002 if (dict_encoded_cols_only &&
4003 (!is_arg_constant && !arg_ti.is_dict_encoded_string())) {
4005 <<
"Currently only text-encoded dictionary-encoded column inputs are "
4006 <<
"allowed, but a none-encoded text column argument was received.";
4007 throw std::runtime_error(oss.str());
4015 <<
"Expected integer type for argument " << arg_idx + 1 <<
" ("
4016 << arg_names[arg_idx] <<
").";
4017 throw std::runtime_error(oss.str());
4020 if (!is_arg_constant) {
4022 <<
"Currently only text-encoded dictionary column inputs are "
4023 <<
"allowed, but an integer-type column was provided.";
4024 throw std::runtime_error(oss.str());
4034 const std::vector<std::shared_ptr<Analyzer::Expr>>& operands) {
4035 if (operands.size() != 2UL) {
4036 std::ostringstream oss;
4037 oss <<
"Concat operator expects two arguments, but was provided " << operands.size()
4039 throw std::runtime_error(oss.str());
4041 if (operands[1].
get()->get_type_info().is_dict_encoded_string() &&
4042 !(operands[0].get()->get_type_info().is_dict_encoded_string())) {
4049 const std::vector<std::shared_ptr<Analyzer::Expr>>& operands) {
4052 return {operands[1], operands[0]};
4061 throw std::runtime_error(
"Invalid pad type supplied to PAD operator");
4068 const std::vector<std::shared_ptr<Analyzer::Expr>>&
args) {
4069 auto get_trim_type_if_exists = [&
args]() {
4074 if (!trim_type_arg) {
4077 const auto trim_type_str =
to_upper(*trim_type_arg->get_constval().stringval);
4078 if (trim_type_str ==
"BOTH") {
4081 if (trim_type_str ==
"LEADING") {
4084 if (trim_type_str ==
"TRAILING") {
4091 ? get_trim_type_if_exists()
4092 : trim_op_kind_maybe;
4094 return trim_op_kind;
4098 const std::vector<std::shared_ptr<Analyzer::Expr>>& operands,
4100 if (operands.size() < 2UL) {
4101 throw std::runtime_error(
"Trim operator expects 2 arguments.");
4113 if (dynamic_cast<const Analyzer::Constant*>(operands[0].
get()) &&
4115 return {operands[1], operands[0]};
4120 return {operands[2], operands[1]};
4126 const std::vector<std::shared_ptr<Analyzer::Expr>>& rhs) {
4127 if (lhs.size() != rhs.size()) {
4130 for (
size_t i = 0; i < lhs.size(); ++i) {
4131 if (!(*lhs[i] == *rhs[i])) {
4138 std::shared_ptr<Analyzer::Expr>
remove_cast(
const std::shared_ptr<Analyzer::Expr>& expr) {
4140 if (!uoper || uoper->get_optype() !=
kCAST) {
4148 if (!uoper || uoper->get_optype() !=
kCAST) {
4151 return uoper->get_operand();
std::shared_ptr< Analyzer::Expr > arg
std::shared_ptr< Analyzer::Expr > deep_copy() const override
std::shared_ptr< Analyzer::Expr > arg
Defines data structures for the semantic analysis phase of query processing.
InIntegerSet(const std::shared_ptr< const Analyzer::Expr > a, const std::vector< int64_t > &values, const bool not_null)
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
HOST DEVICE SQLTypes get_subtype() const
void set_compression(EncodingType c)
T roundDecimal(int64_t n, unsigned scale)
std::string toString() const override
double power10(unsigned const x)
float get_likelihood() const
std::shared_ptr< Analyzer::Expr > expr
std::string toString() const override
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
InValues(std::shared_ptr< Analyzer::Expr > a, const std::list< std::shared_ptr< Analyzer::Expr >> &l)
static bool simple_predicate_has_simple_cast(const std::shared_ptr< Analyzer::Expr > cast_operand, const std::shared_ptr< Analyzer::Expr > const_operand)
const Expr * get_partition_count() const
bool operator==(const Expr &rhs) const override
std::string toString() const override
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
GeoConstant(std::unique_ptr< Geospatial::GeoBase > &&geo, const SQLTypeInfo &ti)
void get_domain(DomainSet &domain_set) const override
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
std::string toString() const final
bool operator==(const Expr &rhs) const override
const Expr * get_else_expr() const
std::shared_ptr< Analyzer::Expr > deep_copy() const override
bool operator==(const Expr &rhs) const override
std::shared_ptr< Analyzer::Expr > deep_copy() const override
bool operator==(const Expr &rhs) const override
bool Datum_equal(const SQLTypeInfo &ti, Datum val1, Datum val2)
std::string DatumToString(Datum d, const SQLTypeInfo &ti)
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
bool operator==(const Expr &rhs) const override
const Expr * get_escape_expr() const
std::shared_ptr< Analyzer::Expr > arg
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
std::shared_ptr< Analyzer::Expr > decompress()
std::optional< int > output_srid_override_
std::shared_ptr< Analyzer::Expr > remove_cast(const std::shared_ptr< Analyzer::Expr > &expr)
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
bool is_null_value(const SQLTypeInfo &ti, const Datum &constval)
static bool colvar_comp(const ColumnVar *l, const ColumnVar *r)
void add_rte(RangeTableEntry *rte)
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
std::shared_ptr< Analyzer::Expr > operand
std::shared_ptr< Analyzer::Expr > deep_copy() const override
std::shared_ptr< Analyzer::Expr > arg
std::list< std::pair< std::shared_ptr< Analyzer::Expr >, std::shared_ptr< Analyzer::Expr > > > expr_pair_list
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
bool operator==(const Expr &rhs) const override
std::shared_ptr< Analyzer::Expr > deep_copy() const override
void collect_rte_idx(std::set< int > &rte_idx_set) const final
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
bool operator==(const Expr &rhs) const override
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
virtual void add_unique(std::list< const Expr * > &expr_list) const
std::shared_ptr< Analyzer::Expr > right_operand
std::shared_ptr< Analyzer::Expr > escape_expr
bool operator==(Expr const &rhs) const override
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
void collect_rte_idx(std::set< int > &rte_idx_set) const override
std::shared_ptr< Analyzer::Expr > deep_copy() const override
std::shared_ptr< Analyzer::Expr > deep_copy() const override
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
const Expr * get_escape_expr() const
HOST DEVICE int get_scale() const
const Expr * get_right_operand() const
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
void collect_rte_idx(std::set< int > &rte_idx_set) const override
std::string toString() const override
std::map< size_t, std::pair< SQLTypes, Datum >> LiteralArgMap
std::shared_ptr< Analyzer::Expr > deep_copy() const override
std::string get_compression_name() const
std::shared_ptr< Analyzer::Expr > arg
std::shared_ptr< Analyzer::Expr > deep_copy() const override
const std::vector< std::shared_ptr< Analyzer::Expr > > args0_
std::shared_ptr< Analyzer::Expr > like_expr
const std::vector< std::shared_ptr< Analyzer::Expr > > args0_
std::string toString() const override
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
std::shared_ptr< Analyzer::Expr > deep_copy() const override
const std::shared_ptr< const Analyzer::Expr > arg
const std::shared_ptr< Analyzer::Expr > get_own_operand() const
std::shared_ptr< Analyzer::Expr > deep_copy() const override
std::shared_ptr< Analyzer::Expr > deep_copy() const override
void cast_from_string(const SQLTypeInfo &new_type_info)
std::shared_ptr< Analyzer::Expr > deep_copy() const override
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
std::string toString() const override
std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info) override
std::shared_ptr< Analyzer::Expr > ExpressionPtr
const Geospatial::GeoBase::GeoOp op_
const Expr * get_arg() const
const std::vector< std::shared_ptr< Analyzer::Expr > > order_keys_
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
bool operator==(const Expr &rhs) const override
bool operator==(const Expr &rhs) const override
DatetruncField get_field() const
static SqlStringOpKind get_and_validate_trim_op_kind(const SqlStringOpKind trim_op_kind_maybe, const std::vector< std::shared_ptr< Analyzer::Expr >> &args)
const Expr * get_arg() const
bool is_expr_nullable(const Analyzer::Expr *expr)
std::shared_ptr< Analyzer::Expr > upper_bound_
Constants for Builtin SQL Types supported by OmniSci.
std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info) override
std::shared_ptr< Analyzer::Expr > arg
bool operator==(const Expr &rhs) const override
std::shared_ptr< Analyzer::Expr > deep_copy() const override
std::shared_ptr< Analyzer::Expr > deep_copy() const override
const std::vector< std::shared_ptr< Analyzer::Expr > > args_
const std::vector< std::shared_ptr< Analyzer::Expr > > partition_keys_
static std::vector< std::shared_ptr< Analyzer::Expr > > normalize_operands(const std::vector< std::shared_ptr< Analyzer::Expr >> &operands)
std::shared_ptr< Analyzer::Expr > deep_copy() const override
void collect_rte_idx(std::set< int > &rte_idx_set) const override
bool operator==(const Expr &rhs) const override
HOST DEVICE SQLTypes get_type() const
std::unique_ptr< Geospatial::GeoBase > geo_
std::shared_ptr< Analyzer::Expr > partition_count_
std::string toString() const override
constexpr int64_t get_datetime_scaled_epoch(const ScalingType direction, const int64_t epoch, const int32_t dimen)
std::string toString() const override
std::list< const Expr * > DomainSet
virtual void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const
const Expr * get_arg() const
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
TO safeRound(FROM const from)
std::string toString() const override
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
double get_bound_val(const Analyzer::Expr *bound_expr) const
static SQLTypeInfo get_return_type(const std::vector< std::shared_ptr< Analyzer::Expr >> args)
bool operator==(const Expr &rhs) const override
int get_rte_idx(const std::string &range_var_name) const
void cast_string(const SQLTypeInfo &new_type_info)
const std::vector< std::shared_ptr< Analyzer::Expr > > args_
std::string toString() const override
std::vector< std::shared_ptr< Analyzer::Expr > > chained_string_op_exprs_
std::shared_ptr< Analyzer::Expr > deep_copy() const override
std::string toString() const override
std::shared_ptr< Analyzer::Expr > deep_copy() const override
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
bool operator==(const Expr &rhs) const override
bool g_enable_string_functions
std::string toString() const override
std::vector< size_t > getLiteralArgIndexes() const
std::string toString() const override
std::string toString() const override
bool get_calc_encoded_length() const
bool operator==(const Expr &rhs) const override
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
std::string toString() const override
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
const Geospatial::GeoBase::GeoOp op_
std::string toString() const override
SQLOps get_optype() const
std::shared_ptr< Analyzer::Expr > left_operand
This file contains the class specification and related data structures for Catalog.
void check_operand_types(const size_t min_args, const std::vector< OperandTypeFamily > &expected_type_families, const std::vector< std::string > &arg_names, const bool dict_encoded_cols_only=true, const bool cols_first_arg_only=true) const
bool operator==(const Expr &rhs) const override
void set_input_srid(int d)
const std::vector< std::shared_ptr< Analyzer::Expr > > args1_
std::shared_ptr< Analyzer::Constant > arg1
std::string toString() const
std::shared_ptr< Analyzer::Expr > deep_copy() const override
std::shared_ptr< Analyzer::Expr > normalize_simple_predicate(int &rte_idx) const override
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
std::shared_ptr< Analyzer::Expr > deep_copy() const override
std::shared_ptr< Analyzer::Expr > deep_copy() const override
static SQLTypeInfo common_string_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
std::shared_ptr< Analyzer::Expr > right_operand_
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
std::shared_ptr< Analyzer::Expr > deep_copy() const override
static SqlStringOpKind validate_trim_op_kind(const SqlStringOpKind trim_op_kind)
bool hasSingleDictEncodedColInput() const
returns whether we have one and only one column involved in this StringOper and all its descendents...
std::shared_ptr< Analyzer::Expr > deep_copy() const final
LiteralArgMap getLiteralArgs() const
std::string toString() const override
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
const DatetruncField field_
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
const std::vector< std::shared_ptr< Analyzer::Expr > > & getTuple() const
void collect_rte_idx(std::set< int > &rte_idx_set) const override
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
bool is_castable(const SQLTypeInfo &new_type_info) const
void collect_rte_idx(std::set< int > &rte_idx_set) const override
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
std::shared_ptr< Analyzer::Expr > lower_bound_
std::string toString() const override
const DateaddField field_
std::shared_ptr< Analyzer::Expr > deep_copy() const override
std::shared_ptr< Analyzer::Expr > from_expr_
bool expr_list_match(const std::vector< std::shared_ptr< Analyzer::Expr >> &lhs, const std::vector< std::shared_ptr< Analyzer::Expr >> &rhs)
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
bool operator==(const Expr &rhs) const override
std::shared_ptr< Analyzer::Expr > deep_copy() const override
std::string toString() const override
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
const std::shared_ptr< Analyzer::Expr > end_
std::string toString() const override
WhichRow get_which_row() const
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
bool operator==(const Expr &rhs) const override
const std::shared_ptr< Analyzer::Expr > number_
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
bool is_timeinterval() const
std::shared_ptr< Analyzer::Expr > deep_copy() const override
std::shared_ptr< Analyzer::Expr > deep_copy() const override
bool operator==(const Expr &rhs) const override
const std::string & getName() const
std::string toString() const override
static SQLTypeInfo common_numeric_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
void collect_rte_idx(std::set< int > &rte_idx_set) const override
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
TO safeNarrow(FROM const from)
bool operator==(const Expr &rhs) const override
const std::shared_ptr< Analyzer::Expr > start_
constexpr FLOAT_TYPE maxRound()
std::string toString() const
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Datum StringToDatum(std::string_view s, SQLTypeInfo &ti)
bool get_is_distinct() const
std::shared_ptr< Analyzer::Constant > convert_rings(const std::vector< int > &rings)
static std::vector< std::shared_ptr< Analyzer::Expr > > normalize_operands(const std::vector< std::shared_ptr< Analyzer::Expr >> &operands, const SqlStringOpKind string_op_kind)
bool operator==(const Expr &rhs) const override
const std::vector< OrderEntry > collation_
const Expr * get_start_expr() const
void do_cast(const SQLTypeInfo &new_type_info)
std::string toString() const override
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
bool operator==(const Expr &rhs) const override
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override