28 #include <unordered_map>
30 #include <rapidjson/document.h>
31 #include <boost/core/noncopyable.hpp>
32 #include <boost/functional/hash.hpp>
71 using RelAlgInputs = std::vector<std::shared_ptr<const RelAlgNode>>;
103 virtual bool visit(RexLiteral
const*
n, std::string s) {
return v(n, s); }
107 virtual bool visit(RexSubQuery
const*
n, std::string s) {
return v(n, s); }
118 template <
typename T>
119 bool v(
T const*
n, std::string s) {
120 return visitAny(static_cast<RelAlgDagNode const*>(n), s);
126 virtual void accept(Visitor& v, std::string
name)
const = 0;
148 virtual size_t toHash()
const = 0;
151 mutable std::optional<size_t>
hash_;
169 if (v.
visit(
this, std::move(name))) {
202 const unsigned scale,
203 const unsigned precision,
204 const unsigned target_scale,
205 const unsigned target_precision)
221 const unsigned scale,
222 const unsigned precision,
223 const unsigned target_scale,
224 const unsigned target_precision)
238 const unsigned scale,
239 const unsigned precision,
240 const unsigned target_scale,
241 const unsigned target_precision)
255 const unsigned scale,
256 const unsigned precision,
257 const unsigned target_scale,
258 const unsigned target_precision)
280 if (v.
visit(
this, std::move(name))) {
287 const auto ptr = boost::get<T>(&
literal_);
306 std::ostringstream oss;
314 return std::make_unique<RexLiteral>(*this);
322 boost::variant<boost::blank, int64_t, double, std::string, bool>
literal_;
342 std::vector<std::unique_ptr<const RexScalar>>& operands,
347 for (
size_t i = 0; i <
size(); ++i) {
354 if (v.
visit(
this, std::move(name))) {
360 std::vector<std::unique_ptr<const RexScalar>>& operands)
const {
382 if (!config.attributes_only) {
385 ret += operand->toString(config) +
" ";
400 mutable std::vector<std::unique_ptr<const RexScalar>>
operands_;
413 RexCase(std::vector<std::pair<std::unique_ptr<const RexScalar>,
414 std::unique_ptr<const RexScalar>>>& expr_pair_list,
415 std::unique_ptr<const RexScalar>& else_expr)
428 if (v.
visit(
this, std::move(name))) {
449 if (!config.attributes_only) {
450 auto ret =
cat(::
typeName(
this),
"(expr_pair_list=");
452 ret += expr.first->toString(config) +
" " + expr.second->toString(config) +
" ";
467 std::pair<std::unique_ptr<const RexScalar>, std::unique_ptr<const RexScalar>>>
488 std::vector<std::unique_ptr<const RexScalar>>& operands)
const override {
489 return std::unique_ptr<const RexOperator>(
494 for (
size_t i = 0; i <
size(); ++i) {
501 if (v.
visit(
this, std::move(name))) {
510 if (!config.attributes_only) {
513 ret += operand->toString(config) +
" ";
515 return cat(ret,
")");
609 const std::vector<SortField> collation,
626 partition_key->accept(v,
"partition");
631 order_key->accept(v,
"order");
636 if (v.
visit(
this, std::move(name))) {
656 std::unique_ptr<const RexScalar>&& new_partition_key) {
661 void replaceOrderKey(
size_t offset, std::unique_ptr<const RexScalar>&& new_order_key) {
682 const std::vector<SortField>& collation)
const {
683 return std::unique_ptr<const RexOperator>(
697 if (!config.attributes_only) {
700 ret += operand->toString(config) +
" ";
702 ret +=
", partition_keys=";
704 ret += key->toString(config) +
" ";
706 ret +=
", order_keys=";
708 ret += key->toString(config) +
" ";
710 return cat(ret,
")");
745 if (v.
visit(
this, std::move(name))) {
755 std::unique_ptr<RexRef>
deepCopy()
const {
return std::make_unique<RexRef>(
index_); }
775 const std::vector<size_t>& operands)
780 if (v.
visit(
this, std::move(name))) {
855 if (!extracted_query_plan_dag.empty()) {
882 const std::vector<RelAlgNode const*>
getInputs()
const {
883 std::vector<RelAlgNode const*> ret;
885 ret.push_back(
n.get());
900 for (
auto& input_ptr :
inputs_) {
901 if (input_ptr.get() == needle) {
909 std::shared_ptr<const RelAlgNode> input) {
910 for (
auto& input_ptr :
inputs_) {
911 if (input_ptr == old_input) {
930 virtual size_t size()
const = 0;
932 virtual std::shared_ptr<RelAlgNode>
deepCopy()
const = 0;
942 virtual size_t toHash()
const = 0;
947 mutable std::optional<size_t>
hash_;
978 std::shared_ptr<ExecutionResultShPtr>
result,
979 const std::shared_ptr<const RelAlgNode> ra)
996 if (v.
visit(
this, std::move(name))) {
1003 return *(
type_.get());
1012 unsigned getId()
const;
1019 std::unique_ptr<RexSubQuery>
deepCopy()
const;
1030 std::shared_ptr<const RelAlgNode>
ra_;
1051 if (v.
visit(
this, std::move(name))) {
1100 const std::vector<std::string>& field_names,
1110 if (v.
visit(
this, std::move(name))) {
1131 if (!config.attributes_only) {
1139 std::shared_ptr<RelAlgNode>
deepCopy()
const override {
1186 bool const delete_via_select =
false,
1187 bool const varlen_update_required =
false,
1232 template <
typename VALIDATION_FUNCTOR>
1235 if (validator(column_name) ==
false) {
1267 RelProject(std::vector<std::unique_ptr<const RexScalar>>& scalar_exprs,
1268 const std::vector<std::string>& fields,
1269 std::shared_ptr<const RelAlgNode> input)
1283 for (
size_t i = 0; i <
size(); ++i) {
1290 n->accept(v,
"input");
1295 if (v.
visit(
this, std::move(name))) {
1309 if (!dynamic_cast<const RexInput*>(expr.get())) {
1323 std::shared_ptr<RelProject> new_project_node)
const {
1325 new_project_node->setUpdateViaSelectFlag(
true);
1328 new_project_node->setDeleteViaSelectFlag(
true);
1331 new_project_node->setVarlenUpdateRequired(
true);
1375 std::shared_ptr<const RelAlgNode> input)
override {
1380 std::shared_ptr<const RelAlgNode> old_input,
1381 std::shared_ptr<const RelAlgNode> input,
1382 std::optional<std::unordered_map<unsigned, unsigned>> old_to_new_index_map);
1385 std::unique_ptr<const RexScalar> new_input);
1389 if (!config.attributes_only) {
1392 ret += expr->toString(config) +
" ";
1400 std::shared_ptr<RelAlgNode>
deepCopy()
const override {
1401 auto copied_project_node = std::make_shared<RelProject>(*this);
1406 copied_project_node->setPushedDownWindowExpr();
1408 return copied_project_node;
1443 template <
typename EXPR_VISITOR_FUNCTOR>
1445 for (
int i = 0; i < static_cast<int>(
scalar_exprs_.size()); i++) {
1453 std::make_unique<RexFunctionOperator const>(std::string(
"OFFSET_IN_FRAGMENT"),
1456 fields_.emplace_back(
"EXPR$DELETE_OFFSET_IN_FRAGMENT");
1475 std::vector<std::unique_ptr<const RexAgg>>& agg_exprs,
1476 const std::vector<std::string>& fields,
1477 std::shared_ptr<const RelAlgNode> input)
1491 n.get()->accept(v,
"aggregate");
1496 n->accept(v,
"input");
1501 if (v.
visit(
this, std::move(name))) {
1514 fields_ = std::move(new_fields);
1520 std::vector<const RexAgg*>
result;
1522 result.push_back(agg_expr.release());
1531 const std::vector<std::unique_ptr<const RexAgg>>&
getAggExprs()
const {
1535 void setAggExprs(std::vector<std::unique_ptr<const RexAgg>>& agg_exprs) {
1541 if (!config.attributes_only) {
1549 if (!config.skip_input_nodes) {
1552 ret +=
", input node id={";
1554 auto node_id_in_plan = input->getIdInPlanTree();
1555 auto node_id_str = node_id_in_plan ?
std::to_string(*node_id_in_plan)
1557 ret += node_id_str +
" ";
1561 return cat(ret,
")");
1572 std::shared_ptr<RelAlgNode>
deepCopy()
const override {
1573 return std::make_shared<RelAggregate>(*this);
1621 std::shared_ptr<const RelAlgNode> rhs,
1622 std::unique_ptr<const RexScalar>& condition,
1640 n->accept(v,
"input");
1645 if (v.
visit(
this, std::move(name))) {
1661 void replaceInput(std::shared_ptr<const RelAlgNode> old_input,
1662 std::shared_ptr<const RelAlgNode> input)
override;
1666 if (!config.attributes_only) {
1668 if (!config.skip_input_nodes) {
1671 ret +=
", input node id={";
1673 auto node_id_in_plan = input->getIdInPlanTree();
1674 auto node_id_str = node_id_in_plan ?
std::to_string(*node_id_in_plan)
1676 ret += node_id_str +
" ";
1697 std::shared_ptr<RelAlgNode>
deepCopy()
const override {
1698 return std::make_shared<RelJoin>(*this);
1745 const std::vector<const Analyzer::ColumnVar*> lhs_join_cols,
1746 const std::vector<const Analyzer::ColumnVar*> rhs_join_cols,
1747 const std::vector<std::shared_ptr<const Analyzer::Expr>> filter_ops,
1749 const bool nested_loop,
1751 const std::string& op_type,
1752 const std::string& qualifier,
1753 const std::string& op_typeinfo)
1778 n->accept(v,
"input");
1783 if (v.
visit(
this, std::move(name))) {
1790 std::ostringstream oss;
1794 oss <<
" }, outer_join_cond: { ";
1810 const std::vector<std::shared_ptr<const Analyzer::Expr>>
getFilterCond()
const {
1817 size_t size()
const override {
return 0; }
1829 std::shared_ptr<const RelAlgNode> input)
override {
1832 std::shared_ptr<RelAlgNode>
deepCopy()
const override {
1869 std::shared_ptr<const RelAlgNode> input)
1870 :
filter_(std::move(filter)) {
1888 n->accept(v,
"input");
1893 if (v.
visit(
this, std::move(name))) {
1904 filter_ = std::move(condition);
1909 void replaceInput(std::shared_ptr<const RelAlgNode> old_input,
1910 std::shared_ptr<const RelAlgNode> input)
override;
1914 if (!config.attributes_only) {
1917 if (!config.skip_input_nodes) {
1920 ret +=
", input node id={";
1922 auto node_id_in_plan = input->getIdInPlanTree();
1923 auto node_id_str = node_id_in_plan ?
std::to_string(*node_id_in_plan)
1925 ret += node_id_str +
" ";
1929 return cat(ret,
")");
1936 std::shared_ptr<RelAlgNode>
deepCopy()
const override {
1937 return std::make_shared<RelFilter>(*this);
1958 std::vector<std::shared_ptr<const RelJoin>>& original_joins);
1971 n->accept(v,
"input");
1976 if (v.
visit(
this, std::move(name))) {
1990 size_t size()
const override;
1993 std::shared_ptr<RelAlgNode>
deepCopy()
const override;
2030 RelCompound(std::unique_ptr<const RexScalar>& filter_expr,
2031 const std::vector<const Rex*>& target_exprs,
2032 const size_t groupby_count,
2033 const std::vector<const RexAgg*>& agg_exprs,
2034 const std::vector<std::string>& fields,
2035 std::vector<std::unique_ptr<const RexScalar>>& scalar_sources,
2037 bool update_disguised_as_select =
false,
2038 bool delete_disguised_as_select =
false,
2039 bool varlen_update_required =
false,
2044 delete_disguised_as_select,
2045 varlen_update_required,
2046 manipulation_target_table,
2057 CHECK_EQ(fields.size(), target_exprs.size());
2058 for (
auto agg_expr : agg_exprs) {
2081 n->accept(v,
"input");
2086 if (v.
visit(
this, std::move(name))) {
2091 void replaceInput(std::shared_ptr<const RelAlgNode> old_input,
2092 std::shared_ptr<const RelAlgNode> input)
override;
2132 std::shared_ptr<RelAlgNode>
deepCopy()
const override {
2133 return std::make_shared<RelCompound>(*this);
2171 std::vector<std::unique_ptr<const RexScalar>>
2187 std::optional<size_t> limit,
2188 const size_t offset,
2189 std::shared_ptr<const RelAlgNode> input)
2197 n->accept(v,
"input");
2202 if (v.
visit(
this, std::move(name))) {
2241 if (!config.skip_input_nodes) {
2244 ret +=
", input node id={";
2246 auto node_id_in_plan = input->getIdInPlanTree();
2247 auto node_id_str = node_id_in_plan ?
std::to_string(*node_id_in_plan)
2249 ret += node_id_str +
" ";
2253 return cat(ret,
")");
2258 std::shared_ptr<RelAlgNode>
deepCopy()
const override {
2259 return std::make_shared<RelSort>(*this);
2265 std::list<Analyzer::OrderEntry>
result;
2266 for (
size_t i = 0; i <
collation_.size(); ++i) {
2268 result.emplace_back(sort_field.getField() + 1,
2304 throw std::runtime_error(
"Unexpected ModifyOperation enum encountered.");
2308 if (op_string ==
"INSERT") {
2310 }
else if (op_string ==
"DELETE") {
2312 }
else if (op_string ==
"UPDATE") {
2316 throw std::runtime_error(
2317 std::string(
"Unsupported logical modify operation encountered " + op_string));
2330 std::string
const& op_string,
2360 n->accept(v,
"input");
2365 if (v.
visit(
this, std::move(name))) {
2379 size_t size()
const override {
return 0; }
2380 std::shared_ptr<RelAlgNode>
deepCopy()
const override {
2381 return std::make_shared<RelModify>(*this);
2393 ", target_column_list=",
2396 if (!config.skip_input_nodes) {
2399 ret +=
", input node id={";
2401 auto node_id_in_plan = input->getIdInPlanTree();
2402 auto node_id_str = node_id_in_plan ?
std::to_string(*node_id_in_plan)
2404 ret += node_id_str +
" ";
2408 return cat(ret,
")");
2413 CHECK(previous_node !=
nullptr);
2414 auto previous_project_node =
const_cast<RelProject*
>(previous_node);
2416 if (previous_project_node->hasWindowFunctionExpr()) {
2418 throw std::runtime_error(
2419 "UPDATE of a column of multi-fragmented table using window function not "
2420 "currently supported.");
2423 throw std::runtime_error(
2424 "UPDATE of a column of sharded table using window function not "
2425 "currently supported.");
2429 previous_project_node->setUpdateViaSelectFlag(
true);
2435 previous_project_node->setModifiedTableCatalog(&
catalog_);
2437 int target_update_column_expr_start = 0;
2439 CHECK(target_update_column_expr_start >= 0);
2440 CHECK(target_update_column_expr_end >= 0);
2442 bool varlen_update_required =
false;
2444 auto varlen_scan_visitor = [
this,
2445 &varlen_update_required,
2446 target_update_column_expr_start,
2447 target_update_column_expr_end](
int index) {
2448 if (index >= target_update_column_expr_start &&
2449 index <= target_update_column_expr_end) {
2450 auto target_index = index - target_update_column_expr_start;
2457 const auto shard_cd =
2460 if ((column_desc->columnName == shard_cd->columnName)) {
2461 throw std::runtime_error(
"UPDATE of a shard key is currently unsupported.");
2466 if (column_desc->columnType.is_varlen()) {
2467 varlen_update_required =
true;
2469 if (column_desc->columnType.is_geometry()) {
2470 throw std::runtime_error(
"UPDATE of a geo column is unsupported.");
2475 previous_project_node->visitScalarExprs(varlen_scan_visitor);
2476 previous_project_node->setVarlenUpdateRequired(varlen_update_required);
2481 CHECK(previous_node !=
nullptr);
2482 auto previous_project_node =
const_cast<RelProject*
>(previous_node);
2485 previous_project_node->setModifiedTableCatalog(&
catalog_);
2509 std::vector<std::string>& fields,
2510 std::vector<const Rex*> col_inputs,
2511 std::vector<std::unique_ptr<const RexScalar>>& table_func_inputs,
2512 std::vector<std::unique_ptr<const RexScalar>>& target_exprs)
2518 for (
const auto& input : inputs) {
2531 for (
size_t i = 0; i <
size(); ++i) {
2538 n->accept(v,
"input");
2543 if (v.
visit(
this, std::move(name))) {
2548 void replaceInput(std::shared_ptr<const RelAlgNode> old_input,
2549 std::shared_ptr<const RelAlgNode> input)
override;
2594 std::shared_ptr<RelAlgNode>
deepCopy()
const override {
2595 return std::make_shared<RelTableFunction>(*this);
2600 if (!config.attributes_only) {
2602 if (!config.skip_input_nodes) {
2605 ret +=
", input node id={";
2607 auto node_id_in_plan = input->getIdInPlanTree();
2608 auto node_id_str = node_id_in_plan ?
std::to_string(*node_id_in_plan)
2610 ret += node_id_str +
" ";
2615 ", fields=", ::
toString(
fields_),
", col_inputs=...",
", table_func_inputs=");
2616 if (!config.skip_input_nodes) {
2620 ret += expr->toString(config) +
" ";
2623 ret +=
", target_exprs=";
2625 ret += expr->toString(config) +
" ";
2627 return cat(ret,
")");
2647 std::vector<std::unique_ptr<const RexScalar>>
2656 using RowValues = std::vector<std::unique_ptr<const RexScalar>>;
2662 std::vector<RowValues>& values)
2668 for (
size_t row_idx = 0; row_idx <
getNumRows(); ++row_idx) {
2669 for (
size_t col_idx = 0; col_idx <
getRowsSize(); ++col_idx) {
2677 n->accept(v,
"input");
2682 if (v.
visit(
this, std::move(name))) {
2692 for (
const auto& target_meta_info :
tuple_type_) {
2693 ret +=
"(" + target_meta_info.get_resname() +
" " +
2694 target_meta_info.get_type_info().get_type_name() +
")";
2707 const auto& row =
values_[row_idx];
2709 return row[col_idx].get();
2716 return values_.front().size();
2726 std::shared_ptr<RelAlgNode>
deepCopy()
const override {
2727 return std::make_shared<RelLogicalValues>(*this);
2751 n->accept(v,
"input");
2756 if (v.
visit(
this, std::move(name))) {
2761 std::shared_ptr<RelAlgNode>
deepCopy()
const override {
2762 return std::make_shared<RelLogicalUnion>(*this);
2764 size_t size()
const override;
2814 const auto& last_ptr =
nodes_.back();
2843 Hints* hints_delivered,
2845 std::optional<bool> has_global_columnar_output_hint = std::nullopt;
2846 std::optional<bool> has_global_rowwise_output_hint = std::nullopt;
2848 for (
auto it = hints_delivered->begin(); it != hints_delivered->end(); it++) {
2849 auto target = it->second;
2850 auto hint_type = it->first;
2851 switch (hint_type) {
2855 if (target.isGlobalHint()) {
2862 has_global_columnar_output_hint = target.isGlobalHint();
2866 has_global_rowwise_output_hint = target.isGlobalHint();
2870 if (target.getListOptions().size() != 1) {
2871 VLOG(1) <<
"Skip the given query hint \"bbox_intersect_bucket_threshold\" ("
2872 << target.getListOptions()[0]
2873 <<
") : invalid # hint options are given";
2876 double bbox_intersect_bucket_threshold = std::stod(target.getListOptions()[0]);
2877 if (bbox_intersect_bucket_threshold >= 0.0 &&
2878 bbox_intersect_bucket_threshold <= 90.0) {
2881 if (target.isGlobalHint()) {
2884 bbox_intersect_bucket_threshold;
2887 VLOG(1) <<
"Skip the given query hint \"bbox_intersect_bucket_threshold\" ("
2888 << bbox_intersect_bucket_threshold
2889 <<
") : the hint value should be within 0.0 ~ 90.0";
2894 if (target.getListOptions().size() != 1) {
2895 VLOG(1) <<
"Skip the given query hint \"bbox_intersect_max_size\" ("
2896 << target.getListOptions()[0]
2897 <<
") : invalid # hint options are given";
2900 std::stringstream ss(target.getListOptions()[0]);
2901 int bbox_intersect_max_size;
2902 ss >> bbox_intersect_max_size;
2903 if (bbox_intersect_max_size >= 0) {
2906 if (target.isGlobalHint()) {
2911 VLOG(1) <<
"Skip the query hint \"bbox_intersect_max_size\" ("
2912 << bbox_intersect_max_size
2913 <<
") : the hint value should be larger than or equal to zero";
2920 if (target.isGlobalHint()) {
2929 if (target.isGlobalHint()) {
2933 VLOG(1) <<
"Skip auto tuner and hashtable caching for bbox_intersect join.";
2937 if (target.getListOptions().size() != 1) {
2938 VLOG(1) <<
"Skip the given query hint \"bbox_intersect_keys_per_bin\" ("
2939 << target.getListOptions()[0]
2940 <<
") : invalid # hint options are given";
2943 double bbox_intersect_keys_per_bin = std::stod(target.getListOptions()[0]);
2944 if (bbox_intersect_keys_per_bin > 0.0 &&
2945 bbox_intersect_keys_per_bin < std::numeric_limits<double>::max()) {
2948 if (target.isGlobalHint()) {
2953 VLOG(1) <<
"Skip the given query hint \"bbox_intersect_keys_per_bin\" ("
2954 << bbox_intersect_keys_per_bin
2955 <<
") : the hint value should be larger than zero";
2961 VLOG(1) <<
"Skip query hint \'keep_result\' because neither data recycler "
2962 "nor query resultset recycler is enabled";
2966 if (target.isGlobalHint()) {
2975 VLOG(1) <<
"Skip query hint \'keep_table_function_result\' because neither "
2977 "nor query resultset recycler is enabled";
2986 if (target.getListOptions().size() != 1u) {
2987 VLOG(1) <<
"Skip the given query hint \"aggregate_tree_fanout\" ("
2988 << target.getListOptions()[0]
2989 <<
") : invalid # hint options are given";
2992 int aggregate_tree_fanout = std::stoi(target.getListOptions()[0]);
2993 if (aggregate_tree_fanout < 0) {
2994 VLOG(1) <<
"A fan-out of an aggregate tree should be larger than zero";
2995 }
else if (aggregate_tree_fanout > 1024) {
2996 VLOG(1) <<
"Too large fanout is provided (i.e., fanout < 1024)";
3000 if (target.isGlobalHint()) {
3008 CHECK_EQ(1u, target.getListOptions().size());
3009 int cuda_block_size = std::stoi(target.getListOptions()[0]);
3010 if (cuda_block_size <= 0) {
3011 VLOG(1) <<
"CUDA block size should be larger than zero";
3012 }
else if (cuda_block_size > 1024) {
3013 VLOG(1) <<
"CUDA block size should be less or equal to 1024";
3017 if (target.isGlobalHint()) {
3025 CHECK_EQ(1u, target.getListOptions().size());
3026 double cuda_grid_size_multiplier = std::stod(target.getListOptions()[0]);
3027 double min_grid_size_multiplier{0};
3028 double max_grid_size_multiplier{1024};
3029 if (cuda_grid_size_multiplier <= min_grid_size_multiplier) {
3030 VLOG(1) <<
"CUDA grid size multiplier should be larger than zero";
3031 }
else if (cuda_grid_size_multiplier > max_grid_size_multiplier) {
3032 VLOG(1) <<
"CUDA grid size multiplier should be less than 1024";
3036 if (target.isGlobalHint()) {
3046 if (target.isGlobalHint()) {
3054 VLOG(1) <<
"Skip the given query hint \"watchdog\": already enabled";
3058 if (target.isGlobalHint()) {
3067 VLOG(1) <<
"Skip the given query hint \"watchdog_off\": already disabled";
3071 if (target.isGlobalHint()) {
3073 global_query_hint.
watchdog =
false;
3081 VLOG(1) <<
"Skip the given query hint \"dynamic_watchdog\": already enabled";
3085 if (target.isGlobalHint()) {
3095 <<
"Skip the given query hint \"dynamic_watchdog_off\": already disabled";
3099 if (target.isGlobalHint()) {
3108 hints_delivered->end()) {
3109 VLOG(1) <<
"Skip the given query hint \"query_time_limit\" ("
3110 << target.getListOptions()[0]
3111 <<
") : cannot use it with \"dynamic_watchdog_off\" hint";
3114 if (target.getListOptions().size() != 1) {
3115 VLOG(1) <<
"Skip the given query hint \"query_time_limit\" ("
3116 << target.getListOptions()[0]
3117 <<
") : invalid # hint options are given";
3120 double query_time_limit = std::stoi(target.getListOptions()[0]);
3121 if (query_time_limit <= 0) {
3122 VLOG(1) <<
"Skip the given query hint \"query_time_limit\" ("
3123 << target.getListOptions()[0]
3124 <<
") : the hint value should be larger than zero";
3129 if (target.isGlobalHint()) {
3138 if (target.isGlobalHint()) {
3147 if (target.isGlobalHint()) {
3154 CHECK_EQ(1u, target.getListOptions().size());
3155 int loop_size_threshold = std::stoi(target.getListOptions()[0]);
3156 if (loop_size_threshold <= 0) {
3158 <<
"Skip the given query hint \"loop_join_inner_table_max_num_rows\" ("
3159 << target.getListOptions()[0]
3160 <<
") : the hint value should be larger than zero";
3164 if (target.isGlobalHint()) {
3172 CHECK_EQ(1u, target.getListOptions().size());
3173 int max_join_hash_table_size = std::stoi(target.getListOptions()[0]);
3174 if (max_join_hash_table_size <= 0) {
3175 VLOG(1) <<
"Skip the given query hint \"max_join_hashtable_size\" ("
3176 << target.getListOptions()[0]
3177 <<
") : the hint value should be larger than zero";
3181 if (target.isGlobalHint()) {
3191 if (target.isGlobalHint()) {
3200 if (target.isGlobalHint()) {
3207 CHECK_EQ(1u, target.getListOptions().size());
3208 int watchdog_max_projected_rows_per_device =
3209 std::stoi(target.getListOptions()[0]);
3210 if (watchdog_max_projected_rows_per_device <= 0) {
3211 VLOG(1) <<
"Skip the given query hint "
3212 "\"watchdog_max_projected_rows_per_device\" ("
3213 << target.getListOptions()[0]
3214 <<
") : the hint value should be larger than zero";
3218 watchdog_max_projected_rows_per_device;
3219 if (target.isGlobalHint()) {
3223 watchdog_max_projected_rows_per_device;
3229 CHECK_EQ(1u, target.getListOptions().size());
3230 int preflight_count_query_threshold = std::stoi(target.getListOptions()[0]);
3231 if (preflight_count_query_threshold <= 0) {
3232 VLOG(1) <<
"Skip the given query hint \"preflight_count_query_threshold\" ("
3233 << target.getListOptions()[0]
3234 <<
") : the hint value should be larger than zero";
3238 if (target.isGlobalHint()) {
3241 preflight_count_query_threshold;
3249 if (target.isGlobalHint()) {
3256 CHECK_EQ(1u, target.getListOptions().size());
3257 double ndv_groups_estimator_multiplier = std::stod(target.getListOptions()[0]);
3258 if (ndv_groups_estimator_multiplier < 1.0 ||
3259 ndv_groups_estimator_multiplier > 2.0) {
3260 VLOG(1) <<
"Skip the given query hint \"ndv_groups_estimator_multiplier\" ("
3261 << target.getListOptions()[0]
3262 <<
") : the valid hint value range is 1.0 <= "
3263 "ndv_groups_estimator_multiplier <= 2.0";
3267 if (target.isGlobalHint()) {
3270 ndv_groups_estimator_multiplier;
3291 if (has_global_columnar_output_hint.has_value() &&
3292 has_global_rowwise_output_hint.has_value()) {
3294 <<
"Two hints 1) columnar output and 2) rowwise output are enabled together, "
3295 <<
"so skip them and use the runtime configuration "
3296 "\"g_enable_columnar_output\"";
3297 }
else if (has_global_columnar_output_hint.has_value() &&
3298 !has_global_rowwise_output_hint.has_value()) {
3300 VLOG(1) <<
"We already enable columnar output by default "
3301 "(g_enable_columnar_output = true), so skip this columnar output hint";
3305 if (*has_global_columnar_output_hint) {
3310 }
else if (!has_global_columnar_output_hint.has_value() &&
3311 has_global_rowwise_output_hint.has_value()) {
3313 VLOG(1) <<
"We already use the default rowwise output (g_enable_columnar_output "
3314 "= false), so skip this rowwise output hint";
3318 if (*has_global_rowwise_output_hint) {
3328 auto node_key = node->
toHash();
3331 std::unordered_map<unsigned, RegisteredQueryHint> hint_map;
3332 hint_map.emplace(node->
getId(), query_hint);
3335 it->second.emplace(node->
getId(), query_hint);
3342 auto const& registered_query_hint_map = node_it->second;
3343 auto hint_it = registered_query_hint_map.find(node->
getId());
3344 if (hint_it != registered_query_hint_map.end()) {
3345 auto const& registered_query_hint = hint_it->second;
3348 return std::make_optional(registered_query_hint ||
global_hints_);
3350 return std::make_optional(registered_query_hint);
3359 return std::nullopt;
3362 std::unordered_map<size_t, std::unordered_map<unsigned, RegisteredQueryHint>>&
3381 std::vector<std::shared_ptr<RelAlgNode>>
nodes_;
3387 std::unordered_map<size_t, std::unordered_map<unsigned, RegisteredQueryHint>>
3405 return rel_alg_dag.
nodes_;
3413 static std::unordered_map<size_t, std::unordered_map<unsigned, RegisteredQueryHint>>&
3438 static std::unique_ptr<RelAlgDag>
buildDag(
const std::string& query_ra,
3439 const bool optimize_dag);
3451 const rapidjson::Value& query_ast);
3456 static std::unique_ptr<RelAlgDag>
build(
const rapidjson::Value& query_ast,
3458 const bool optimize_dag);
3471 #define HEAVYAI_SPECIALIZE_HASH_VALUE_OF_POINTER(T) \
3473 inline std::size_t hash_value(T const* const& ptr) { \
3474 return ptr ? ptr->toHash() : HASH_NULLPTR; \
3477 inline std::size_t hash_value(T* const& ptr) { \
3478 return ptr ? ptr->toHash() : HASH_NULLPTR; \
3508 #undef HEAVYAI_SPECIALIZE_HASH_VALUE_OF_POINTER
std::vector< std::shared_ptr< const RexScalar > > scalar_exprs_
std::shared_ptr< RelAlgNode > deepCopy() const override
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
const size_t getGroupByCount() const
void setGlobalQueryHints(const RegisteredQueryHint &global_hints)
bool isRowOffsetPreceding() const
bool is_agg(const Analyzer::Expr *expr)
void validate_non_foreign_table_write(const TableDescriptor *table_descriptor)
SortField getCollation(const size_t i) const
std::unique_ptr< const RexScalar > condition_
virtual void accept(Visitor &v, std::string name) const override
friend std::size_t hash_value(RelLeftDeepInnerJoin const &)
RexWindowBound frame_start_bound_
RelCompound(const TableDescriptor *td, const Catalog_Namespace::Catalog *catalog)
const RexScalar * getThen(const size_t idx) const
virtual void acceptChildren(Visitor &v) const override
void setOutputMetainfo(std::vector< TargetMetaInfo > targets_metainfo) const
virtual bool visit(RelScan const *n, std::string s)
bool isNestedLoopQual() const
virtual size_t toHash() const override
std::unique_ptr< const RexScalar > ConstRexScalarPtr
std::vector< std::unique_ptr< const RexScalar > > getExpressionsAndRelease()
virtual void acceptChildren(Visitor &v) const override
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
void setVarlenUpdateRequired(bool required) const
RexLiteral(const bool val, const SQLTypes type, const SQLTypes target_type, const unsigned scale, const unsigned precision, const unsigned target_scale, const unsigned target_precision)
std::vector< std::unique_ptr< const RexScalar > > outer_conditions_per_level_
bool const isFlattened() const
std::unique_ptr< RexSubQuery > deepCopy() const
ConstRexScalarPtrVector getPartitionKeysAndRelease() const
virtual void acceptChildren(Visitor &v) const override
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
void replaceInput(std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input) override
const std::vector< std::shared_ptr< RexSubQuery > > & getSubqueries() const
std::shared_ptr< RelAlgNode > deepCopy() const override
virtual size_t toHash() const override
int getUpdateColumnCount() const
static std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint > > & getQueryHints(RelAlgDag &rel_alg_dag)
std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint > > query_hint_
ColumnNameList target_columns_
bool g_use_query_resultset_cache
bool table_reordering_off
const bool hasHintEnabled(QueryHint candidate_hint) const
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
void replacePartitionKey(size_t offset, std::unique_ptr< const RexScalar > &&new_partition_key)
const Rex * getTargetExpr(const size_t i) const
virtual bool visit(RexInput const *n, std::string s)
virtual size_t toHash() const override
virtual void accept(Visitor &v, std::string name) const override
TableDescriptor const * getTableDescriptor() const
RelAlgNode(RelAlgInputs inputs={})
std::string getOpTypeInfo() const
virtual bool visit(RexAbstractInput const *n, std::string s)
size_t size() const override
friend std::size_t hash_value(RelModify const &)
class for a per-database catalog. also includes metadata for the current database and the current use...
Hints * getDeliveredHints()
RexFunctionOperator()=default
const std::vector< std::shared_ptr< const Analyzer::Expr > > getFilterCond() const
size_t size() const override
std::shared_ptr< RelAlgNode > deepCopy() const override
const ExplainedQueryHint & getHintInfo(QueryHint hint) const
void addHint(const ExplainedQueryHint &hint_explained)
virtual void accept(Visitor &v, std::string name) const override
bool coversOriginalNode(const RelAlgNode *node) const
const RexScalar * getFilterExpr() const
size_t size() const override
virtual void accept(Visitor &v, std::string name) const override
virtual void accept(Visitor &v, std::string name) const override
friend std::size_t hash_value(RelJoin const &)
virtual void accept(Visitor &v, std::string name) const override
virtual bool visit(RexWindowFunctionOperator const *n, std::string s)
std::list< Analyzer::OrderEntry > getOrderEntries() const
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
size_t getOperand(size_t idx) const
virtual size_t toHash() const override
TargetColumnList const & getUpdateColumnNames() const
virtual size_t toHash() const override
std::vector< RexInput > RANodeOutput
const RexScalar * getElse() const
RexOperator(const SQLOps op, std::vector< std::unique_ptr< const RexScalar >> &operands, const SQLTypeInfo &type)
RelSort(const std::vector< SortField > &collation, std::optional< size_t > limit, const size_t offset, std::shared_ptr< const RelAlgNode > input)
virtual void accept(Visitor &v, std::string name) const override
void setPushedDownWindowExpr()
static thread_local unsigned crt_id_
NullSortedPosition nulls_pos_
virtual void accept(Visitor &v, std::string name) const override
void setCondition(std::unique_ptr< const RexScalar > &condition)
void setTargetColumns(ColumnNameList const &target_columns) const
std::string function_name_
const std::string getFieldName(const size_t i) const
std::unique_ptr< RexRef > deepCopy() const
const RexScalar * outer_join_cond_
const Catalog_Namespace::Catalog & getCatalog() const
RelProject(const TableDescriptor *td, const Catalog_Namespace::Catalog *catalog)
RexScalar const * copyAndRedirectSource(RexScalar const *, size_t input_idx) const
std::unique_ptr< const RexScalar > ConstRexScalarPtr
void replaceInput(std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input) override
const RexScalar * getOuterCondition(const size_t nesting_level) const
void replaceInput(std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input) override
double bbox_intersect_keys_per_bin
void setQueryPlanDag(const std::string &extracted_query_plan_dag) const
unsigned getTargetScale() const
virtual void acceptChildren(Visitor &v) const override
void applyDeleteModificationsToInputNode()
bool operator==(const SortField &that) const
std::vector< std::string > TargetColumnList
size_t size() const override
const SQLTypeInfo & getType() const
Hints * getDeliveredHints()
const RexScalar * getOperand(const size_t idx) const
size_t size() const override
std::vector< const Rex * > col_inputs_
const JoinType join_type_
bool hasEquivCollationOf(const RelSort &that) const
const std::vector< SortField > & getCollation() const
virtual bool visit(RexAgg const *n, std::string s)
void resetQueryExecutionState()
SortDirection getSortDir() const
size_t getNumRows() const
std::shared_ptr< RelFilter > original_filter_
const SQLTypeInfo & getType() const
const bool hasHintEnabled(QueryHint candidate_hint) const
void setRelNodeDagId(const size_t id) const
const std::vector< const Analyzer::ColumnVar * > lhs_join_cols_
virtual bool visit(RelTranslatedJoin const *n, std::string s)
void applyUpdateModificationsToInputNode()
virtual size_t toHash() const override
virtual void acceptChildren(Visitor &v) const override
std::string getFieldName(const size_t idx) const
const RexScalar * getCondition() const
RexSubQuery & operator=(const RexSubQuery &)=delete
std::unique_ptr< const RexScalar > else_expr_
friend std::size_t hash_value(RelScan const &)
virtual size_t toHash() const override
std::vector< std::shared_ptr< RelAlgNode > > nodes_
const std::vector< TargetMetaInfo > getTupleType() const
friend std::size_t hash_value(RexFunctionOperator const &)
const std::vector< std::string > & getFields() const
void addManagedInput(std::shared_ptr< const RelAlgNode > input)
virtual void accept(Visitor &v, std::string name) const override
unsigned getScale() const
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
virtual bool visit(RelModify const *n, std::string s)
void invalidateTargetColumns() const
void registerQueryHint(const RelAlgNode *node, const RegisteredQueryHint &query_hint)
std::vector< std::string > fields_
std::vector< std::unique_ptr< const RexAgg > > getAggExprsAndRelease()
void addHint(const ExplainedQueryHint &hint_explained)
std::shared_ptr< RelAlgNode > deepCopy() const override
void setDeleteViaSelectFlag(bool required) const
const RexScalar * getWhen(const size_t idx) const
virtual bool visit(RexFunctionOperator const *n, std::string s)
virtual void acceptChildren(Visitor &v) const override
const RegisteredQueryHint & getGlobalHints() const
void setFields(std::vector< std::string > &&fields)
auto const isProjectForUpdate() const
void setFilterExpr(std::unique_ptr< const RexScalar > &new_expr)
std::optional< bool > dynamic_watchdog
std::vector< const Analyzer::ColumnVar * > getJoinCols(bool lhs) const
void appendInput(std::string new_field_name, std::unique_ptr< const RexScalar > new_input)
double cuda_grid_size_multiplier
const RexScalar * getCondition() const
std::string getOpType() const
bool has_pushed_down_window_expr_
std::string query_plan_dag_
std::shared_ptr< RelAlgNode > deepCopy() const override
#define HEAVYAI_SPECIALIZE_HASH_VALUE_OF_POINTER(T)
bool g_enable_dynamic_watchdog
virtual size_t toHash() const override
void addHint(const ExplainedQueryHint &hint_explained)
virtual void accept(Visitor &v, std::string name) const override
std::vector< ConstRexScalarPtr > ConstRexScalarPtrVector
void forceRowwiseOutput() const
friend std::size_t hash_value(RexWindowFunctionOperator const &)
RelFilter(std::unique_ptr< const RexScalar > &filter)
HOST DEVICE SQLTypes get_type() const
const TableDescriptor * td_
std::optional< size_t > getIdInPlanTree() const
RexLiteral(const std::string &val, const SQLTypes type, const SQLTypes target_type, const unsigned scale, const unsigned precision, const unsigned target_scale, const unsigned target_precision)
virtual size_t getOuterConditionsSize() const
const std::string op_type_
const RexScalar * getOperandAndRelease(const size_t idx) const
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
std::vector< std::shared_ptr< const RelJoin > > original_joins_
virtual size_t toHash() const override
bool g_enable_data_recycler
virtual void accept(Visitor &v, std::string name) const override
const ColumnDescriptor * getShardColumnMetadataForTable(const TableDescriptor *td) const
friend std::size_t hash_value(SortField const &)
virtual bool visit(RelTableFunction const *n, std::string s)
virtual bool visit(RelAggregate const *n, std::string s)
virtual std::shared_ptr< RelAlgNode > deepCopy() const =0
std::shared_ptr< const RexScalar > bound_expr
static std::vector< std::shared_ptr< RexSubQuery > > & getSubqueries(RelAlgDag &rel_alg_dag)
const RaExecutionDesc * context_data_
std::shared_ptr< const RelAlgNode > getAndOwnInput(const size_t idx) const
std::vector< std::string > field_names_
bool isCurrentRow() const
friend std::size_t hash_value(RelFilter const &)
virtual std::unique_ptr< const RexOperator > getDisambiguated(std::vector< std::unique_ptr< const RexScalar >> &operands) const
size_t max_join_hash_table_size
bool hasPushedDownWindowExpr() const
RexWindowFunctionOperator()
std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint > > & getQueryHints()
std::vector< std::shared_ptr< RelAlgNode > > & getNodes()
void clearContextData() const
TableDescriptor const *const getTableDescriptor() const
virtual bool visitAny(RelAlgDagNode const *n, std::string s)
std::shared_ptr< const RelAlgNode > getRootNodeShPtr() const
bool opt_cuda_grid_and_block_size
virtual void acceptChildren(Visitor &v) const override
RexWindowFunctionOperator(const SqlWindowFunctionKind kind, ConstRexScalarPtrVector &operands, ConstRexScalarPtrVector &partition_keys, ConstRexScalarPtrVector &order_keys, const std::vector< SortField > collation, const RexWindowBound &frame_start_bound, const RexWindowBound &frame_end_bound, const bool is_rows, const SQLTypeInfo &ti)
boost::variant< boost::blank, int64_t, double, std::string, bool > literal_
const std::string getFieldName(const size_t i) const
size_t getQueryPlanDagHash() const
virtual void acceptChildren(Visitor &v) const override
const std::string qualifier_
std::vector< SortField > collation_
const RelAlgNode & getRootNode() const
RelLogicalValues()=default
virtual size_t getStepNumber() const
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
size_t getRowsSize() const
size_t getColInputsSize() const
virtual void acceptChildren(Visitor &v) const override
const ExplainedQueryHint & getHintInfo(QueryHint hint) const
void setUpdateViaSelectFlag(bool required) const
This file contains the class specification and related data structures for Catalog.
RelScan(const TableDescriptor *td, const Catalog_Namespace::Catalog &catalog)
const size_t getScalarSourcesSize() const
void setExpressions(std::vector< std::unique_ptr< const RexScalar >> &exprs) const
virtual void accept(Visitor &v, std::string name) const override
std::optional< size_t > id_in_plan_tree_
virtual void acceptChildren(Visitor &v) const override
std::string to_string() const
const RelAlgNode * getRHS() const
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
bool g_enable_columnar_output
virtual bool visit(RelCompound const *n, std::string s)
virtual bool visit(RexCase const *n, std::string s)
auto const isRowwiseOutputForced() const
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
bool is_delete_via_select_
SQLOps getOperator() const
void setExecutionResult(const ExecutionResultShPtr result)
virtual bool visit(RexLiteral const *n, std::string s)
std::shared_ptr< const RelAlgNode > RelAlgNodeInputPtr
friend std::size_t hash_value(RelProject const &)
const RexScalar * getCondition() const
virtual size_t toHash() const override
bool keep_table_function_result
std::shared_ptr< RelAlgNode > deepCopy() const override
const Catalog_Namespace::Catalog * catalog_
virtual size_t toHash() const override
friend std::size_t hash_value(RexAgg const &)
RelLeftDeepInnerJoin()=default
static std::unique_ptr< RelAlgDag > buildDagForSubquery(RelAlgDag &root_dag, const rapidjson::Value &query_ast)
const RexScalar * getTableFuncInputAtAndRelease(const size_t idx)
SqlWindowFunctionKind kind_
RelModify(Catalog_Namespace::Catalog const &cat, TableDescriptor const *const td)
virtual void accept(Visitor &v, std::string name) const override
const SQLTypeInfo & getType() const
const bool hasHintEnabled(const QueryHint candidate_hint) const
ColumnNameList const & getTargetColumns() const
std::vector< std::shared_ptr< RexSubQuery > > subqueries_
bool isUnboundedFollowing() const
std::unique_ptr< const RexOperator > disambiguatedOperands(ConstRexScalarPtrVector &operands, ConstRexScalarPtrVector &partition_keys, ConstRexScalarPtrVector &order_keys, const std::vector< SortField > &collation) const
RexCase(std::vector< std::pair< std::unique_ptr< const RexScalar >, std::unique_ptr< const RexScalar >>> &expr_pair_list, std::unique_ptr< const RexScalar > &else_expr)
NullSortedPosition getNullsPosition() const
const ExplainedQueryHint & getHintInfo(QueryHint hint) const
std::vector< size_t > operands_
Hints * getDeliveredHints()
std::vector< std::string > fields_
virtual void acceptChildren(Visitor &v) const =0
RelScan(const TableDescriptor *td, const std::vector< std::string > &field_names, const Catalog_Namespace::Catalog &catalog)
virtual void acceptChildren(Visitor &v) const override
const RexScalar * getAndReleaseCondition() const
std::unique_ptr< Hints > hints_
double bbox_intersect_bucket_threshold
RexLiteral(const int64_t val, const SQLTypes type, const SQLTypes target_type, const unsigned scale, const unsigned precision, const unsigned target_scale, const unsigned target_precision)
const TableDescriptor * table_descriptor_
std::unique_ptr< Hints > hints_
std::vector< std::shared_ptr< const RelAlgNode >> RelAlgInputs
std::optional< RegisteredQueryHint > getQueryHint(const RelAlgNode *node) const
double ndv_groups_estimator_multiplier
std::vector< std::unique_ptr< const RexScalar > > scalar_exprs_
void registerHint(const QueryHint hint)
virtual void acceptChildren(Visitor &v) const override
virtual bool visit(RexSubQuery const *n, std::string s)
std::shared_ptr< RelAlgNode > deepCopy() const override
size_t size() const override
std::shared_ptr< SQLTypeInfo > type_
size_t size() const override
const RexScalar * getAndReleaseCondition()
std::string getFieldName(const size_t i) const
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
void addHint(const ExplainedQueryHint &hint_explained)
size_t branchCount() const
virtual bool visit(RelProject const *n, std::string s)
RexSubQuery(const std::shared_ptr< const RelAlgNode > ra)
const RelAlgNode * getInput(const size_t idx) const
bool force_rowwise_output_
RelFilter(std::unique_ptr< const RexScalar > &filter, std::shared_ptr< const RelAlgNode > input)
const std::vector< std::shared_ptr< const Analyzer::Expr > > filter_ops_
std::vector< std::shared_ptr< const RelJoin > > getOriginalJoins() const
virtual void accept(Visitor &v, std::string name) const override
bool varlen_update_required_
Catalog_Namespace::Catalog const & catalog_
size_t watchdog_max_projected_rows_per_device
virtual size_t toHash() const override
std::string getQueryPlanDag() const
RelAggregate(const size_t groupby_count, std::vector< std::unique_ptr< const RexAgg >> &agg_exprs, const std::vector< std::string > &fields, std::shared_ptr< const RelAlgNode > input)
std::unique_ptr< const RexScalar > filter_
void setCondition(std::unique_ptr< const RexScalar > &condition)
std::vector< std::unique_ptr< const RexScalar > > operands_
std::optional< size_t > hash_
void setContextData(const RaExecutionDesc *context_data) const
std::vector< std::string > fields_
virtual size_t toHash() const override
size_t query_plan_dag_hash_
std::shared_ptr< RelAlgNode > deepCopy() const override
std::vector< const Rex * > target_exprs_
const ExplainedQueryHint & getHintInfo(QueryHint hint) const
std::optional< size_t > hash_
const RexScalar * getProjectAtAndRelease(const size_t idx) const
const RexWindowBound & getFrameEndBound() const
void visitScalarExprs(EXPR_VISITOR_FUNCTOR visitor_functor) const
std::shared_ptr< ExecutionResultShPtr > result_
std::shared_ptr< RelAlgNode > deepCopy() const override
std::unique_ptr< Hints > hints_
virtual void accept(Visitor &v, std::string name) const override
virtual void accept(Visitor &v, std::string name) const override
std::string getFieldName(const size_t col_idx) const
size_t getTableFuncInputsSize() const
std::unique_ptr< RexLiteral > deepCopy() const
virtual void replaceInput(std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input)
std::string toString() const
static std::string yieldModifyOperationString(ModifyOperation const op)
ModifyOperation getOperation() const
virtual void acceptChildren(Visitor &v) const override
std::vector< TargetMetaInfo > getCompatibleMetainfoTypes() const
void setModifiedTableDescriptor(TableDescriptor const *td) const
void setFields(std::vector< std::string > &&fields)
size_t size() const override
std::shared_ptr< Fragmenter_Namespace::AbstractFragmenter > fragmenter
virtual std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const =0
static std::unique_ptr< RelAlgDag > buildDag(const std::string &query_ra, const bool optimize_dag)
std::string tree_string(const RelAlgNode *ra, const size_t depth)
static ModifyOperation yieldModifyOperationEnum(std::string const &op_string)
virtual void acceptChildren(Visitor &v) const override
void setScalarSources(std::vector< std::unique_ptr< const RexScalar >> &new_sources)
std::vector< RowValues > values_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::vector< TargetMetaInfo > targets_metainfo_
const std::vector< std::unique_ptr< const RexAgg > > & getAggExprs() const
Hints * getDeliveredHints()
void setTableFuncInputs(std::vector< std::unique_ptr< const RexScalar >> &&exprs)
void replaceInput(std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input) override
std::optional< bool > watchdog
bool isEmptyResult() const
const RelAlgNode * getRelAlg() const
size_t size() const override
size_t size() const override
virtual size_t toHash() const override
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
virtual size_t getStepNumber() const
size_t preflight_count_query_threshold
const RexScalar * getProjectAt(const size_t idx) const
virtual bool visit(RelJoin const *n, std::string s)
bool isRowOffsetFollowing() const
const RaExecutionDesc * getContextData() const
virtual size_t toHash() const override
const std::vector< std::string > & getFields() const
bool hasInput(const RelAlgNode *needle) const
const std::vector< std::string > & getFieldNames() const
friend std::size_t hash_value(RelAggregate const &)
const std::vector< std::string > & getFields() const
const std::vector< const Analyzer::ColumnVar * > rhs_join_cols_
static std::unique_ptr< RelAlgDag > build(const rapidjson::Value &query_ast, RelAlgDag *root_dag, const bool optimize_dag)
void setCollation(std::vector< SortField > &&collation)
friend std::size_t hash_value(RexRef const &)
int32_t countRexLiteralArgs() const
std::unique_ptr< Hints > hints_
unsigned target_precision_
const ConstRexScalarPtrVector & getPartitionKeys() const
virtual std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const =0
bool allStringCastsAreToDictionaryEncodedStrings() const
const RelAlgNode * getLHS() const
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
virtual void accept(Visitor &v, std::string name) const =0
virtual void accept(Visitor &v, std::string name) const override
const RexWindowBound & getFrameStartBound() const
std::unique_ptr< Hints > hints_
void addHint(const ExplainedQueryHint &hint_explained)
const RexScalar * getOuterJoinCond() const
bool hasNoFraming() const
void replaceInput(std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input) override
std::vector< RexLiteral > RexLiteralArray
void resetModifyManipulationTarget() const
void registerSubquery(std::shared_ptr< RexSubQuery > subquery)
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
virtual bool visit(RexOperator const *n, std::string s)
virtual void setStepNumber(size_t step) const
std::shared_ptr< const RelAlgNode > ra_
static RelRexToStringConfig defaults()
SortField(const size_t field, const SortDirection sort_dir, const NullSortedPosition nulls_pos)
std::unique_ptr< const RexScalar > filter_expr_
static std::vector< std::shared_ptr< RelAlgNode > > & getNodes(RelAlgDag &rel_alg_dag)
void resetQueryExecutionState()
virtual bool visit(RelFilter const *n, std::string s)
bool hasWindowFunctionExpr() const
std::vector< ConstRexScalarPtr > ConstRexScalarPtrVector
virtual bool visit(RelLogicalUnion const *n, std::string s)
ConstRexScalarPtrVector order_keys_
SqlWindowFunctionKind getKind() const
const size_t getGroupByCount() const
std::unordered_map< QueryHint, ExplainedQueryHint > Hints
size_t collationCount() const
virtual bool visit(RelLeftDeepInnerJoin const *n, std::string s)
RelModify(Catalog_Namespace::Catalog const &cat, TableDescriptor const *const td, bool flattened, ModifyOperation op, TargetColumnList const &target_column_list, RelAlgNodeInputPtr input)
virtual size_t size() const =0
std::vector< SortField > collation_
auto const isDeleteViaSelect() const
bool operator==(const RelSort &that) const
RexWindowBound frame_end_bound_
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
const RelFilter * getOriginalFilter() const
std::shared_ptr< RelAlgNode > deepCopy() const override
JoinType getJoinType() const
RelLogicalValues(const std::vector< TargetMetaInfo > &tuple_type, std::vector< RowValues > &values)
std::string get_type_name() const
std::unique_ptr< const RexOperator > getDisambiguated(std::vector< std::unique_ptr< const RexScalar >> &operands) const override
size_t bbox_intersect_max_size
const std::vector< RelAlgNode const * > getInputs() const
void replaceOrderKey(size_t offset, std::unique_ptr< const RexScalar > &&new_order_key)
friend std::size_t hash_value(RelCompound const &)
const size_t getNumShards() const
std::vector< std::pair< std::unique_ptr< const RexScalar >, std::unique_ptr< const RexScalar > > > expr_pair_list_
std::string typeName(const T *v)
RexFunctionOperator(const std::string &name, ConstRexScalarPtrVector &operands, const SQLTypeInfo &ti)
const std::string getFieldName(const size_t idx) const
virtual size_t toHash() const override
std::unique_ptr< const RexScalar > condition_
void replaceOperands(std::vector< std::unique_ptr< const RexScalar >> &&new_operands)
const Catalog_Namespace::Catalog & getCatalog() const
const RexScalar * getTableFuncInputAt(const size_t idx) const
virtual void accept(Visitor &v, std::string name) const override
std::vector< RexLiteralArray > TupleContentsArray
void eachNode(std::function< void(RelAlgNode const *)> const &) const
bool force_baseline_hash_join
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
unsigned getPrecision() const
const JoinType getJoinType(const size_t nesting_level) const
friend std::size_t hash_value(RelLogicalValues const &)
std::size_t hash_value(RexAbstractInput const &rex_ab_input)
RelTableFunction(const std::string &function_name, RelAlgInputs inputs, std::vector< std::string > &fields, std::vector< const Rex * > col_inputs, std::vector< std::unique_ptr< const RexScalar >> &table_func_inputs, std::vector< std::unique_ptr< const RexScalar >> &target_exprs)
std::string getFunctionName() const
void propagateModifyManipulationTarget(std::shared_ptr< RelProject > new_project_node) const
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
bool bbox_intersect_no_cache
std::optional< bool > use_loop_join
std::vector< const RexAgg * > getAggregatesAndRelease()
virtual void accept(Visitor &v, std::string name) const override
const std::vector< std::string > & getFields() const
std::string getFieldName(const size_t i) const
void setIdInPlanTree(size_t id) const
static void optimizeDag(RelAlgDag &rel_alg_dag)
const RexScalar * getValueAt(const size_t row_idx, const size_t col_idx) const
std::vector< std::string > ColumnNameList
bool g_enable_watchdog false
const RexScalar * getInnerCondition() const
virtual size_t toHash() const override
virtual void accept(Visitor &v, std::string name) const override
ModifyOperation operation_
virtual bool visit(RelSort const *n, std::string s)
ConstRexScalarPtrVector getOrderKeysAndRelease() const
const ConstRexScalarPtrVector & getOrderKeys() const
auto const isUpdateViaSelect() const
bool v(T const *n, std::string s)
const std::string op_typeinfo_
const Catalog_Namespace::Catalog & catalog_
SQLTypes getTargetType() const
ConstRexScalarPtrVector partition_keys_
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
friend std::size_t hash_value(RelTranslatedJoin const &)
void setModifiedTableCatalog(const Catalog_Namespace::Catalog *catalog) const
bool isUnboundedPreceding() const
friend std::size_t hash_value(RexCase const &)
RexLiteral(const double val, const SQLTypes type, const SQLTypes target_type, const unsigned scale, const unsigned precision, const unsigned target_scale, const unsigned target_precision)
void setFields(std::vector< std::string > &&fields)
const RexAgg * getAggExpr(size_t i) const
size_t loop_join_inner_table_max_num_rows
friend std::size_t hash_value(RelLogicalUnion const &)
RegisteredQueryHint global_hints_
std::shared_ptr< RelAlgNode > deepCopy() const override
virtual void acceptChildren(Visitor &v) const override
virtual size_t toHash() const
void replaceInput(std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input) override
std::shared_ptr< RelAlgNode > deepCopy() const override
bool bbox_intersect_allow_gpu_build
void injectOffsetInFragmentExpr() const
const size_t getNumFragments() const
size_t getAggExprSize() const
virtual size_t toHash() const =0
std::string getQualifier() const
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
RexLiteral(const SQLTypes target_type)
virtual bool visit(RelLogicalValues const *n, std::string s)
QueryNotSupported(const std::string &reason)
virtual size_t toHash() const override
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
size_t size() const override
std::optional< size_t > limit_
std::vector< std::unique_ptr< const RexScalar >> RowValues
virtual void acceptChildren(Visitor &v) const override
const size_t getAggExprsCount() const
virtual void acceptChildren(Visitor &v) const override
const std::string & getName() const
std::optional< size_t > getLimit() const
const size_t inputCount() const
virtual size_t toHash() const override
ExecutionResultShPtr getExecutionResult() const
virtual void acceptChildren(Visitor &v) const override
size_t getRelNodeDagId() const
auto const isVarlenUpdateRequired() const
RexAgg(const SQLAgg agg, const bool distinct, const SQLTypeInfo &type, const std::vector< size_t > &operands)
size_t aggregate_tree_fanout
const RexScalar * getAndReleaseCondition() const
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
virtual void acceptChildren(Visitor &v) const override
size_t size() const override
std::unique_ptr< RexAgg > deepCopy() const
void setFields(std::vector< std::string > &&new_fields)
const QueryHint getHint() const
virtual void accept(Visitor &v, std::string name) const override
size_t size() const override
const std::vector< TargetMetaInfo > & getOutputMetainfo() const
const TableDescriptor * getTableDescriptor() const
constexpr size_t HASH_NULLPTR
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
RelTableFunction()=default
virtual void acceptChildren(Visitor &v) const override
TargetColumnList target_column_list_
TableDescriptor const * table_descriptor_
void setAggExprs(std::vector< std::unique_ptr< const RexAgg >> &agg_exprs)
std::vector< std::string > fields_
JoinType getJoinType() const
virtual bool visit(RexRef const *n, std::string s)
bool hasContextData() const
bool isLimitDelivered() const
virtual void acceptChildren(Visitor &v) const override
RelTranslatedJoin(const RelAlgNode *lhs, const RelAlgNode *rhs, const std::vector< const Analyzer::ColumnVar * > lhs_join_cols, const std::vector< const Analyzer::ColumnVar * > rhs_join_cols, const std::vector< std::shared_ptr< const Analyzer::Expr >> filter_ops, const RexScalar *outer_join_cond, const bool nested_loop, const JoinType join_type, const std::string &op_type, const std::string &qualifier, const std::string &op_typeinfo)
size_t getFilterCondSize() const
friend std::size_t hash_value(RexOperator const &)
const bool hasHintEnabled(QueryHint candidate_hint) const
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
has_pushed_down_window_expr_
const ExplainedQueryHint & getHintInfo(QueryHint hint) const
RANodeOutput get_node_output(const RelAlgNode *ra_node)
bool isAnyQueryHintDelivered() const
std::shared_ptr< RelAlgNode > deepCopy() const override
unsigned getTargetPrecision() const
virtual size_t toHash() const =0
ModifyManipulationTarget(bool const update_via_select=false, bool const delete_via_select=false, bool const varlen_update_required=false, TableDescriptor const *table_descriptor=nullptr, ColumnNameList target_columns=ColumnNameList(), const Catalog_Namespace::Catalog *catalog=nullptr)
bool force_one_to_many_hash_join
RelJoin(std::shared_ptr< const RelAlgNode > lhs, std::shared_ptr< const RelAlgNode > rhs, std::unique_ptr< const RexScalar > &condition, const JoinType join_type)
BuildState getBuildState() const
virtual size_t toHash() const override
RelModify(Catalog_Namespace::Catalog const &cat, TableDescriptor const *const td, bool flattened, std::string const &op_string, TargetColumnList const &target_column_list, RelAlgNodeInputPtr input)
RexSubQuery(std::shared_ptr< SQLTypeInfo > type, std::shared_ptr< ExecutionResultShPtr > result, const std::shared_ptr< const RelAlgNode > ra)
std::shared_ptr< const ExecutionResult > ExecutionResultShPtr
bool is_update_via_select_
const RexScalar * getTargetExpr(size_t idx) const
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
RexRef(const size_t index)
friend std::size_t hash_value(RelSort const &)
std::vector< TargetMetaInfo > tuple_type_
TableDescriptor const * getModifiedTableDescriptor() const
void registerQueryHints(std::shared_ptr< RelAlgNode > node, Hints *hints_delivered, RegisteredQueryHint &global_query_hint)
void setCondition(std::unique_ptr< const RexScalar > &condition)
friend std::size_t hash_value(RelTableFunction const &)
const std::string getFieldName(const size_t i) const
const RexScalar * getScalarSource(const size_t i) const
constexpr auto is_datetime(SQLTypes type)
const bool hasHintEnabled(QueryHint candidate_hint) const
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Hints * getDeliveredHints()
const Catalog_Namespace::Catalog * getModifiedTableCatalog() const
virtual size_t toHash() const override
static void setBuildState(RelAlgDag &rel_alg_dag, const RelAlgDag::BuildState build_state)
bool validateTargetColumns(VALIDATION_FUNCTOR validator) const
static void resetRelAlgFirstId() noexcept