49 const int precision) {
62 std::shared_ptr<Analyzer::Expr> rhs;
64 const auto rex_operator =
dynamic_cast<const RexOperator*
>(rex_scalar);
66 return std::make_pair(rhs, sql_qual);
69 const auto qual_str = rex_function ? rex_function->
getName() :
"";
70 if (qual_str ==
"PG_ANY"sv || qual_str ==
"PG_ALL"sv) {
71 CHECK_EQ(
size_t(1), rex_function->size());
73 sql_qual = (qual_str ==
"PG_ANY"sv) ?
kANY :
kALL;
75 if (!rhs && rex_operator->getOperator() ==
kCAST) {
76 CHECK_EQ(
size_t(1), rex_operator->size());
79 return std::make_pair(rhs, sql_qual);
87 bool is_null_const{
false};
88 switch (ti.get_type()) {
90 const auto ival = boost::get<int64_t>(scalar_tv);
100 const auto ival = boost::get<int64_t>(scalar_tv);
103 is_null_const =
true;
105 d.tinyintval = *ival;
110 const auto ival = boost::get<int64_t>(scalar_tv);
113 is_null_const =
true;
115 d.smallintval = *ival;
120 const auto ival = boost::get<int64_t>(scalar_tv);
123 is_null_const =
true;
135 const auto ival = boost::get<int64_t>(scalar_tv);
138 is_null_const =
true;
145 const auto dval = boost::get<double>(scalar_tv);
148 is_null_const =
true;
155 const auto fval = boost::get<float>(scalar_tv);
158 is_null_const =
true;
167 auto nullable_sptr = boost::get<NullableString>(scalar_tv);
168 CHECK(nullable_sptr);
169 if (boost::get<void*>(nullable_sptr)) {
170 is_null_const =
true;
172 auto sptr = boost::get<std::string>(nullable_sptr);
173 d.stringval =
new std::string(*sptr);
178 CHECK(
false) <<
"Unhandled type: " << ti.get_type_name();
180 return {d, is_null_const};
187 template <
typename... Ts>
189 return {IndexedHandler{std::type_index(
typeid(Ts)),
190 &RelAlgTranslator::translateRexScalar<Ts>}...};
196 : type_index_(std::type_index(type_info)) {}
197 bool operator()(IndexedHandler
const& pair)
const {
return pair.first == type_index_; }
203 std::shared_ptr<Analyzer::Expr> RelAlgTranslator::translateRexScalar<RexInput>(
205 return translateInput(static_cast<RexInput const*>(rex));
208 std::shared_ptr<Analyzer::Expr> RelAlgTranslator::translateRexScalar<RexLiteral>(
210 return translateLiteral(static_cast<RexLiteral const*>(rex));
213 std::shared_ptr<Analyzer::Expr>
214 RelAlgTranslator::translateRexScalar<RexWindowFunctionOperator>(
216 return translateWindowFunction(static_cast<RexWindowFunctionOperator const*>(rex));
219 std::shared_ptr<Analyzer::Expr> RelAlgTranslator::translateRexScalar<RexFunctionOperator>(
221 return translateFunction(static_cast<RexFunctionOperator const*>(rex));
224 std::shared_ptr<Analyzer::Expr> RelAlgTranslator::translateRexScalar<RexOperator>(
226 return translateOper(static_cast<RexOperator const*>(rex));
229 std::shared_ptr<Analyzer::Expr> RelAlgTranslator::translateRexScalar<RexCase>(
231 return translateCase(static_cast<RexCase const*>(rex));
234 std::shared_ptr<Analyzer::Expr> RelAlgTranslator::translateRexScalar<RexSubQuery>(
236 return translateScalarSubquery(static_cast<RexSubQuery const*>(rex));
241 auto cache_itr =
cache_.find(rex);
242 if (cache_itr ==
cache_.end()) {
251 static_assert(std::is_trivially_destructible_v<decltype(handlers)>);
252 auto it = std::find_if(handlers.cbegin(), handlers.cend(), ByTypeIndex{
typeid(*rex)});
253 CHECK(it != handlers.cend()) <<
"Unhandled type: " <<
typeid(*rex).name();
255 auto cached =
cache_.emplace(rex, (this->*it->second)(rex));
256 CHECK(cached.second) <<
"Failed to emplace rex of type " <<
typeid(*rex).name();
257 cache_itr = cached.first;
259 return cache_itr->second;
272 !shared::is_any<kAVG, kMIN, kMAX, kSUM, kAPPROX_QUANTILE, kMODE>(agg_kind);
276 return shared::is_any<kMIN, kMAX, kCOUNT, kAPPROX_COUNT_DISTINCT>(agg_kind);
283 const std::vector<std::shared_ptr<Analyzer::Expr>>& scalar_sources) {
287 std::shared_ptr<Analyzer::Expr> arg_expr;
288 std::shared_ptr<Analyzer::Expr> arg1;
291 CHECK_LT(operand, scalar_sources.size());
293 arg_expr = scalar_sources[operand];
296 if (rex->
size() == 2) {
299 if (!const_arg1 || const_arg1->get_type_info().get_type() !=
kINT ||
300 const_arg1->get_constval().intval < 1 ||
301 const_arg1->get_constval().intval > 100) {
302 throw std::runtime_error(
303 "APPROX_COUNT_DISTINCT's second parameter must be a SMALLINT literal "
304 "between 1 and 100");
311 throw std::runtime_error(
312 "APPROX_PERCENTILE/MEDIAN is not supported in distributed mode at this "
316 if (rex->
size() == 2) {
328 arg1 = std::make_shared<Analyzer::Constant>(
kDOUBLE,
false, median);
333 throw std::runtime_error(
334 "MODE is not supported in distributed mode at this time.");
338 if (arg_expr->get_type_info().is_geometry()) {
339 throw std::runtime_error(
340 "COUNT_IF does not currently support geospatial types.");
345 if (arg1->get_type_info().get_type() !=
kBOOLEAN) {
346 throw std::runtime_error(
"Conditional argument must be a boolean expression.");
352 const auto& arg_ti = arg_expr->get_type_info();
354 throw std::runtime_error(
"Aggregate on " + arg_ti.get_type_name() +
355 " is not supported yet.");
358 throw std::runtime_error(
toString(agg_kind) +
359 " does not currently support the DISTINCT qualifier.");
362 const auto agg_ti =
get_agg_type(agg_kind, arg_expr.get());
363 return makeExpr<Analyzer::AggExpr>(agg_ti, agg_kind, arg_expr,
is_distinct, arg1);
367 const RexLiteral* rex_literal) {
369 rex_literal->getType(), rex_literal->getScale(), rex_literal->getPrecision());
371 rex_literal->getTargetScale(),
372 rex_literal->getTargetPrecision());
373 switch (rex_literal->getType()) {
377 d.
bigintval = rex_literal->getVal<int64_t>();
378 return makeExpr<Analyzer::Constant>(rex_literal->getType(),
false, d);
381 const auto val = rex_literal->getVal<int64_t>();
382 const int precision = rex_literal->getPrecision();
383 const int scale = rex_literal->getScale();
384 if (target_ti.is_fp() && !scale) {
389 return lit_ti != target_ti ? lit_expr->add_cast(target_ti) : lit_expr;
397 d.
boolval = rex_literal->getVal<
bool>();
398 return makeExpr<Analyzer::Constant>(
kBOOLEAN,
false, d);
402 d.
doubleval = rex_literal->getVal<
double>();
404 makeExpr<Analyzer::Constant>(
SQLTypeInfo(rex_literal->getType(),
405 rex_literal->getPrecision(),
406 rex_literal->getScale(),
410 return lit_ti != target_ti ? lit_expr->add_cast(target_ti) : lit_expr;
415 d.
bigintval = rex_literal->getVal<int64_t>();
416 return makeExpr<Analyzer::Constant>(rex_literal->getType(),
false, d);
422 rex_literal->getType() ==
kTIMESTAMP && rex_literal->getPrecision() > 0
423 ? rex_literal->getVal<int64_t>()
424 : rex_literal->getVal<int64_t>() / 1000;
425 return makeExpr<Analyzer::Constant>(
426 SQLTypeInfo(rex_literal->getType(), rex_literal->getPrecision(), 0,
false),
432 d.
bigintval = rex_literal->getVal<int64_t>() * 24 * 3600;
433 return makeExpr<Analyzer::Constant>(rex_literal->getType(),
false, d);
436 if (target_ti.is_array()) {
440 return makeExpr<Analyzer::ArrayExpr>(target_ti,
args,
true);
444 return makeExpr<Analyzer::Constant>(
kNULLT,
true,
Datum{0});
446 return makeExpr<Analyzer::Constant>(rex_literal->getTargetType(),
true,
Datum{0});
449 LOG(
FATAL) <<
"Unexpected literal type " << lit_ti.get_type_name();
456 const RexSubQuery* rex_subquery)
const {
458 throw std::runtime_error(
"EXPLAIN is not supported with sub-queries");
461 auto result = rex_subquery->getExecutionResult();
462 auto row_set =
result->getRows();
463 const size_t row_count = row_set->rowCount();
464 if (row_count >
size_t(1)) {
465 throw std::runtime_error(
"Scalar sub-query returned multiple rows");
467 auto ti = rex_subquery->getType();
469 throw std::runtime_error(
470 "Scalar sub-queries which return strings not supported in distributed mode");
472 if (row_count ==
size_t(0)) {
473 if (row_set->isValidationOnlyRes()) {
475 if (ti.is_string()) {
480 if (ti.is_dict_encoded_string()) {
484 return makeExpr<Analyzer::Constant>(ti,
false, d);
486 throw std::runtime_error(
"Scalar sub-query returned no results");
489 row_set->moveToBegin();
490 auto const first_row = row_set->getNextRow(ti.is_dict_encoded_string(),
false);
491 CHECK_EQ(first_row.size(), size_t(1));
493 bool is_null_const{
false};
494 auto scalar_tv = boost::get<ScalarTargetValue>(&first_row[0]);
496 if (ti.is_dict_encoded_string()) {
500 return makeExpr<Analyzer::Constant>(ti, is_null_const, d);
508 <<
"Not found in input_to_nest_level_, source="
510 const int rte_idx = it_rte_idx->second;
511 const auto scan_source =
dynamic_cast<const RelScan*
>(source);
516 CHECK(in_metainfo.empty());
517 const auto table_desc = scan_source->getTableDescriptor();
518 const auto& catalog = scan_source->getCatalog();
520 catalog.getMetadataForColumnBySpi(table_desc->tableId, rex_input->
getIndex() + 1);
522 auto col_ti = cd->columnType;
523 if (col_ti.is_string()) {
524 col_ti.set_type(
kTEXT);
526 if (cd->isVirtualCol) {
534 col_ti.set_notnull(
false);
536 return std::make_shared<Analyzer::ColumnVar>(
541 CHECK(!in_metainfo.empty()) <<
"for "
544 const int32_t col_id = rex_input->
getIndex();
545 CHECK_LT(col_id, in_metainfo.size());
546 auto col_ti = in_metainfo[col_id].get_type_info();
551 col_ti.set_notnull(
false);
555 return std::make_shared<Analyzer::ColumnVar>(
566 const auto& target_ti = rex_operator->
getType();
568 const auto& operand_ti = operand_expr->get_type_info();
569 if (operand_ti.is_string() && target_ti.is_string()) {
572 if (target_ti.is_time() ||
576 return target_ti.is_date_in_days()
578 : operand_expr->add_cast(target_ti);
580 if (!operand_ti.is_string() && target_ti.is_string()) {
581 return operand_expr->add_cast(target_ti);
583 return std::make_shared<Analyzer::UOper>(target_ti,
false, sql_op, operand_expr);
588 if (
auto const_expr =
589 dynamic_cast<const Analyzer::Constant*>(operand_expr.get())) {
590 if (const_expr->get_type_info() ==
kNULLT && const_expr->get_is_null()) {
592 operand_expr = makeExpr<Analyzer::Constant>(
kTEXT,
true);
598 const auto& operand_ti = operand_expr->get_type_info();
599 CHECK(operand_ti.is_string());
600 if (operand_ti.is_dict_encoded_string()) {
604 if (operand_expr->get_num_column_vars(
true) == 0UL) {
608 throw std::runtime_error(
609 "ENCODE_TEXT is not currently supported in distributed mode at this time.");
617 return makeExpr<Analyzer::UOper>(
618 casted_target_ti, operand_expr->get_contains_agg(),
kCAST, operand_expr);
622 return std::make_shared<Analyzer::UOper>(
kBOOLEAN, sql_op, operand_expr);
629 const auto& ti = operand_expr->get_type_info();
630 return std::make_shared<Analyzer::UOper>(ti,
false,
kUMINUS, operand_expr);
633 const auto& ti = operand_expr->get_type_info();
634 CHECK(ti.is_array());
635 return makeExpr<Analyzer::UOper>(ti.get_elem_type(),
false,
kUNNEST, operand_expr);
646 const ResultSet& val_set) {
651 std::ostringstream oss;
652 oss <<
"Unable to handle 'expr IN (subquery)': # input rows (" << val_set.rowCount()
653 <<
") is larger than threshold 'g_watchdog_in_clause_max_num_input_rows':"
655 throw std::runtime_error(oss.str());
657 std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
659 std::vector<std::list<std::shared_ptr<Analyzer::Expr>>> expr_set(
660 fetcher_count, std::list<std::shared_ptr<Analyzer::Expr>>());
661 std::vector<std::future<void>> fetcher_threads;
662 const auto& ti = arg->get_type_info();
663 const auto entry_count = val_set.entryCount();
666 stride = (entry_count + fetcher_count - 1) / fetcher_count;
667 i < fetcher_count && start_entry < entry_count;
668 ++i, start_entry += stride) {
669 const auto end_entry = std::min(start_entry + stride, entry_count);
672 [&](std::list<std::shared_ptr<Analyzer::Expr>>& in_vals,
675 for (
auto index = start; index < end; ++index) {
676 auto row = val_set.getRowAt(index);
680 auto scalar_tv = boost::get<ScalarTargetValue>(&row[0]);
682 bool is_null_const{
false};
685 auto ti_none_encoded = ti;
687 auto none_encoded_string =
688 makeExpr<Analyzer::Constant>(ti, is_null_const, d);
689 auto dict_encoded_string = std::make_shared<Analyzer::UOper>(
690 ti,
false,
kCAST, none_encoded_string);
691 in_vals.push_back(dict_encoded_string);
693 in_vals.push_back(makeExpr<Analyzer::Constant>(ti, is_null_const, d));
697 std::ref(expr_set[i]),
701 for (
auto& child : fetcher_threads) {
705 val_set.moveToBegin();
706 for (
auto& exprs : expr_set) {
707 value_exprs.splice(value_exprs.end(), exprs);
709 return makeExpr<Analyzer::InValues>(arg, value_exprs);
722 throw std::runtime_error(
"EXPLAIN is not supported with sub-queries");
727 const auto rex_subquery =
dynamic_cast<const RexSubQuery*
>(rhs);
729 auto ti = lhs->get_type_info();
730 auto result = rex_subquery->getExecutionResult();
732 auto& row_set =
result->getRows();
733 CHECK_EQ(
size_t(1), row_set->colCount());
734 const auto& rhs_ti = row_set->getColType(0);
735 if (rhs_ti.get_type() != ti.get_type()) {
736 throw std::runtime_error(
737 "The two sides of the IN operator must have the same type; found " +
738 ti.get_type_name() +
" and " + rhs_ti.get_type_name());
741 VLOG(1) <<
"RelAlgTranslator::translateInOper: took " <<
timer_stop(clock_begin)
744 row_set->moveToBegin();
745 std::shared_ptr<Analyzer::Expr> expr;
746 if ((ti.is_integer() || (ti.is_string() && ti.get_compression() ==
kENCODING_DICT)) &&
747 !row_set->didOutputColumnar()) {
753 auto const num_values =
756 VLOG(1) <<
"Skip to build a bitmap for tiny integer-set case: # values ("
757 <<
::toString(num_values) <<
") <= threshold ("
768 std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
770 auto row = row_set->getNextRow(
true,
false);
776 std::ostringstream oss;
777 oss <<
"Unable to handle 'expr IN (subquery)' via non-bitmap, # unique values ("
778 << value_exprs.size()
779 <<
") is larger than the threshold "
780 "'g_watchdog_in_clause_max_num_elem_non_bitmap': "
782 throw std::runtime_error(oss.str());
784 auto scalar_tv = boost::get<ScalarTargetValue>(&row[0]);
786 bool is_null_const{
false};
789 auto ti_none_encoded = ti;
791 auto none_encoded_string = makeExpr<Analyzer::Constant>(ti, is_null_const, d);
792 auto dict_encoded_string =
793 std::make_shared<Analyzer::UOper>(ti,
false,
kCAST, none_encoded_string);
794 value_exprs.push_back(dict_encoded_string);
796 value_exprs.push_back(makeExpr<Analyzer::Constant>(ti, is_null_const, d));
799 return makeExpr<Analyzer::InValues>(lhs, value_exprs);
805 std::vector<int64_t>& in_vals,
806 std::atomic<size_t>& total_in_vals_count,
807 const ResultSet* values_rowset,
808 const std::pair<int64_t, int64_t> values_rowset_slice,
811 const int64_t needle_null_val) {
812 CHECK(in_vals.empty());
813 bool dicts_are_equal = source_dict == dest_dict;
814 for (
auto index = values_rowset_slice.first; index < values_rowset_slice.second;
816 const auto row = values_rowset->getOneColRow(index);
820 if (dicts_are_equal) {
821 in_vals.push_back(row.value);
823 const int string_id =
824 row.value == needle_null_val
828 in_vals.push_back(string_id);
832 total_in_vals_count.fetch_add(1024) >=
834 std::ostringstream oss;
835 oss <<
"Unable to handle 'expr IN (subquery)' via bitmap, # unique encoded-string ("
836 << total_in_vals_count.load()
837 <<
") is larger than the threshold 'g_watchdog_in_clause_max_num_elem_bitmap': "
839 throw std::runtime_error(oss.str());
845 std::atomic<size_t>& total_in_vals_count,
846 const ResultSet* values_rowset,
847 const std::pair<int64_t, int64_t> values_rowset_slice) {
848 CHECK(in_vals.empty());
849 for (
auto index = values_rowset_slice.first; index < values_rowset_slice.second;
851 const auto row = values_rowset->getOneColRow(index);
853 in_vals.push_back(row.value);
855 total_in_vals_count.fetch_add(1024) >=
857 std::ostringstream oss;
858 oss <<
"Unable to handle 'expr IN (subquery)' via bitmap, # unique integer "
860 << total_in_vals_count.load()
861 <<
") is larger than the threshold "
862 "'g_watchdog_in_clause_max_num_elem_bitmap': "
864 throw std::runtime_error(oss.str());
878 std::vector<int64_t>& in_vals,
879 std::atomic<size_t>& total_in_vals_count,
880 const ResultSet* values_rowset,
881 const std::pair<int64_t, int64_t> values_rowset_slice,
882 const std::vector<LeafHostInfo>& leaf_hosts,
885 const int32_t dest_generation,
886 const int64_t needle_null_val) {
887 CHECK(in_vals.empty());
888 std::vector<int32_t> source_ids;
889 source_ids.reserve(values_rowset->entryCount());
890 bool has_nulls =
false;
891 if (source_dict_ref == dest_dict_ref) {
892 in_vals.reserve(values_rowset_slice.second - values_rowset_slice.first +
894 for (
auto index = values_rowset_slice.first; index < values_rowset_slice.second;
896 const auto row = values_rowset->getOneColRow(index);
900 if (row.value != needle_null_val) {
901 in_vals.push_back(row.value);
903 total_in_vals_count.fetch_add(1024) >=
905 std::ostringstream oss;
906 oss <<
"Unable to handle 'expr IN (subquery)' via bitmap, # unique "
907 "encoded-string values ("
908 << total_in_vals_count.load()
909 <<
") is larger than the threshold "
910 "'g_watchdog_in_clause_max_num_elem_bitmap': "
912 throw std::runtime_error(oss.str());
926 for (
auto index = values_rowset_slice.first; index < values_rowset_slice.second;
928 const auto row = values_rowset->getOneColRow(index);
930 if (row.value != needle_null_val) {
931 source_ids.push_back(row.value);
937 std::vector<int32_t> dest_ids;
944 CHECK_EQ(dest_ids.size(), source_ids.size());
945 in_vals.reserve(dest_ids.size() + (has_nulls ? 1 : 0));
947 in_vals.push_back(needle_null_val);
949 for (
const int32_t dest_id : dest_ids) {
951 in_vals.push_back(dest_id);
953 total_in_vals_count.fetch_add(1024) >=
955 std::ostringstream oss;
956 oss <<
"Unable to handle 'expr IN (subquery)' via bitmap, # unique "
957 "encoded-string values ("
958 << total_in_vals_count.load()
959 <<
") is larger than the threshold "
960 "'g_watchdog_in_clause_max_num_elem_bitmap': "
962 throw std::runtime_error(oss.str());
977 std::shared_ptr<Analyzer::Expr> arg,
978 const ResultSet& val_set)
const {
982 std::vector<int64_t> value_exprs;
984 std::vector<std::vector<int64_t>> expr_set(fetcher_count);
985 std::vector<std::future<void>> fetcher_threads;
986 const auto& arg_type = arg->get_type_info();
987 const auto entry_count = val_set.entryCount();
988 CHECK_EQ(
size_t(1), val_set.colCount());
989 const auto& col_type = val_set.getColType(0);
991 (col_type.get_comp_param() <= 0 || arg_type.get_comp_param() <= 0)) {
995 std::atomic<size_t> total_in_vals_count{0};
998 stride = (entry_count + fetcher_count - 1) / fetcher_count;
999 i < fetcher_count && start_entry < entry_count;
1000 ++i, start_entry += stride) {
1001 expr_set[i].reserve(entry_count / fetcher_count);
1002 const auto end_entry = std::min(start_entry + stride, entry_count);
1003 if (arg_type.is_string()) {
1007 const auto& dest_dict_key = arg_type.getStringDictKey();
1008 const auto& source_dict_key = col_type.getStringDictKey();
1009 const auto dd =
executor_->getStringDictionaryProxy(
1010 arg_type.getStringDictKey(), val_set.getRowSetMemOwner(),
true);
1011 const auto sd =
executor_->getStringDictionaryProxy(
1012 col_type.getStringDictKey(), val_set.getRowSetMemOwner(),
true);
1015 const auto catalog =
1021 &total_in_vals_count,
1027 catalog](std::vector<int64_t>& in_vals,
const size_t start,
const size_t end) {
1032 total_in_vals_count,
1035 catalog->getStringDictionaryHosts(),
1036 {source_dict_key.db_id, source_dict_key.dict_id},
1037 {dest_dict_key.db_id, dest_dict_key.dict_id},
1038 dd->getGeneration(),
1042 total_in_vals_count,
1050 std::ref(expr_set[i]),
1054 CHECK(arg_type.is_integer());
1057 [&val_set, &total_in_vals_count](
1058 std::vector<int64_t>& in_vals,
const size_t start,
const size_t end) {
1061 std::ref(expr_set[i]),
1066 for (
auto& child : fetcher_threads) {
1070 val_set.moveToBegin();
1071 value_exprs.reserve(entry_count);
1072 for (
auto& exprs : expr_set) {
1073 value_exprs.insert(value_exprs.end(), exprs.begin(), exprs.end());
1075 return makeExpr<Analyzer::InIntegerSet>(
1076 arg, value_exprs, arg_type.get_notnull() && col_type.get_notnull());
1082 if (rex_operator->
size() == 1) {
1086 if (sql_op ==
kIN) {
1091 if (date_plus_minus) {
1092 return date_plus_minus;
1104 for (
size_t i = 1; i < rex_operator->
size(); ++i) {
1105 std::shared_ptr<Analyzer::Expr> rhs;
1107 const auto rhs_op = rex_operator->
getOperand(i);
1127 const auto lhs_ti = lhs->get_type_info();
1128 if (lhs_ti.is_geometry()) {
1131 throw std::runtime_error(
1132 "Bounding Box Intersection equivalence is currently only supported for "
1133 "geospatial types");
1138 const RexCase* rex_case)
const {
1139 std::shared_ptr<Analyzer::Expr> else_expr;
1140 std::list<std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>
1142 for (
size_t i = 0; i < rex_case->
branchCount(); ++i) {
1145 expr_list.emplace_back(when_expr, then_expr);
1155 const auto num_operands = rex_function->
size();
1158 std::vector<std::shared_ptr<Analyzer::Expr>> regressor_values;
1159 for (
size_t regressor_idx = 1; regressor_idx < num_operands; ++regressor_idx) {
1160 regressor_values.emplace_back(
1163 return makeExpr<Analyzer::MLPredictExpr>(model_value, regressor_values);
1168 const auto num_operands = rex_function->
size();
1171 std::vector<std::shared_ptr<Analyzer::Expr>> feature_values;
1172 for (
size_t feature_idx = 1; feature_idx < num_operands - 1; ++feature_idx) {
1173 feature_values.emplace_back(
1176 auto pc_dimension_value =
1178 return makeExpr<Analyzer::PCAProjectExpr>(
1179 model_value, feature_values, pc_dimension_value);
1189 if (!partition_count->get_type_info().is_integer()) {
1190 throw std::runtime_error(
1191 "PARTITION_COUNT expression of width_bucket function expects an integer type.");
1193 auto check_numeric_type =
1194 [](
const std::string& col_name,
const Analyzer::Expr* expr,
bool allow_null_type) {
1195 if (expr->get_type_info().get_type() ==
kNULLT) {
1196 if (!allow_null_type) {
1197 throw std::runtime_error(
1198 col_name +
" expression of width_bucket function expects non-null type.");
1202 if (!expr->get_type_info().is_number()) {
1203 throw std::runtime_error(
1204 col_name +
" expression of width_bucket function expects a numeric type.");
1208 check_numeric_type(
"TARGET_VALUE", target_value.get(),
true);
1209 check_numeric_type(
"LOWER_BOUND", lower_bound.get(),
false);
1210 check_numeric_type(
"UPPER_BOUND", upper_bound.get(),
false);
1212 auto cast_to_double_if_necessary = [](std::shared_ptr<Analyzer::Expr> arg) {
1213 const auto& arg_ti = arg->get_type_info();
1214 if (arg_ti.get_type() !=
kDOUBLE) {
1216 return arg->add_cast(double_ti);
1220 target_value = cast_to_double_if_necessary(target_value);
1221 lower_bound = cast_to_double_if_necessary(lower_bound);
1222 upper_bound = cast_to_double_if_necessary(upper_bound);
1223 return makeExpr<Analyzer::WidthBucketExpr>(
1229 CHECK(rex_function->
size() == 2 || rex_function->
size() == 3);
1232 if (!std::dynamic_pointer_cast<const Analyzer::Constant>(like)) {
1233 throw std::runtime_error(
"The matching pattern must be a literal.");
1235 const auto escape = (rex_function->
size() == 3)
1238 const bool is_ilike = rex_function->
getName() ==
"PG_ILIKE"sv;
1244 CHECK(rex_function->
size() == 2 || rex_function->
size() == 3);
1247 if (!std::dynamic_pointer_cast<const Analyzer::Constant>(pattern)) {
1248 throw std::runtime_error(
"The matching pattern must be a literal.");
1250 const auto escape = (rex_function->
size() == 3)
1260 return makeExpr<Analyzer::LikelihoodExpr>(arg, 0.9375);
1267 return makeExpr<Analyzer::LikelihoodExpr>(arg, 0.0625);
1273 const std::shared_ptr<Analyzer::Constant> literal_expr) {
1274 if (!literal_expr || literal_expr->get_is_null()) {
1275 throw std::runtime_error(
"The 'DatePart' argument must be a not 'null' literal.");
1288 const bool is_date_trunc = rex_function->
getName() ==
"PG_DATE_TRUNC"sv;
1289 if (is_date_trunc) {
1304 datum.tinyintval = val;
1308 datum.smallintval = val;
1316 datum.bigintval = val;
1325 datum.floatval = val;
1329 datum.doubleval = val;
1335 return makeExpr<Analyzer::Constant>(ti,
false, datum);
1347 const auto number_units_const =
1349 if (number_units_const && number_units_const->get_is_null()) {
1350 throw std::runtime_error(
"The 'Interval' argument literal must not be 'null'.");
1354 const auto& datetime_ti = datetime->get_type_info();
1355 if (datetime_ti.get_type() ==
kTIME) {
1356 throw std::runtime_error(
"DateAdd operation not supported for TIME.");
1359 const int dim = datetime_ti.get_dimension();
1360 return makeExpr<Analyzer::DateaddExpr>(
1368 return "DATETIME_PLUS"s;
1375 if (rex_operator->
size() != 2) {
1379 const auto datetime_ti = datetime->get_type_info();
1380 if (!datetime_ti.is_timestamp() && !datetime_ti.is_date()) {
1381 if (datetime_ti.get_type() ==
kTIME) {
1382 throw std::runtime_error(
"DateTime addition/subtraction not supported for TIME.");
1387 const auto rhs_ti = rhs->get_type_info();
1389 if (datetime_ti.is_high_precision_timestamp() ||
1390 rhs_ti.is_high_precision_timestamp()) {
1391 throw std::runtime_error(
1392 "High Precision timestamps are not supported for TIMESTAMPDIFF operation. "
1397 const auto& rex_operator_ti = rex_operator->
getType();
1398 const auto datediff_field =
1401 makeExpr<Analyzer::DatediffExpr>(bigint_ti, datediff_field, rhs, datetime);
1404 return makeExpr<Analyzer::BinOper>(bigint_ti.get_type(),
1415 std::vector<std::shared_ptr<Analyzer::Expr>>
args = {datetime, rhs};
1416 auto dt_plus = makeExpr<Analyzer::FunctionOper>(
1423 const auto interval =
fold_expr(rhs.get());
1424 auto interval_ti = interval->get_type_info();
1428 std::shared_ptr<Analyzer::Expr> interval_sec;
1432 (op ==
kMINUS ? -interval_lit->get_constval().bigintval
1433 : interval_lit->get_constval().bigintval) /
1436 interval_sec = makeExpr<Analyzer::BinOper>(bigint_ti.get_type(),
1443 std::make_shared<Analyzer::UOper>(bigint_ti,
false,
kUMINUS, interval_sec);
1446 return makeExpr<Analyzer::DateaddExpr>(datetime_ti,
daSECOND, interval_sec, datetime);
1449 const auto interval_months = op ==
kMINUS ? std::make_shared<Analyzer::UOper>(
1450 bigint_ti,
false,
kUMINUS, interval)
1452 return makeExpr<Analyzer::DateaddExpr>(datetime_ti,
daMONTH, interval_months, datetime);
1482 return makeExpr<Analyzer::CharLengthExpr>(str_arg->decompress(),
1483 rex_function->
getName() ==
"CHAR_LENGTH"sv);
1491 if (
nullptr == expr || !expr->get_type_info().is_string() ||
1492 expr->get_type_info().is_varlen()) {
1493 throw std::runtime_error(rex_function->
getName() +
1494 " expects a dictionary encoded text column.");
1498 throw std::runtime_error(
1500 " does not support unnest operator as its input expression.");
1502 return makeExpr<Analyzer::KeyForStringExpr>(
args[0]);
1509 const auto& arg_ti = arg->get_type_info();
1510 if (arg_ti.get_type() !=
kDOUBLE) {
1512 arg = arg->add_cast(double_ti);
1514 return makeExpr<Analyzer::SampleRatioExpr>(arg);
1519 std::string user{
"SESSIONLESS_USER"};
1521 user =
query_state_->getConstSessionInfo()->get_currentUser().userName;
1528 const auto func_name = rex_function->
getName();
1530 std::ostringstream oss;
1531 oss <<
"Function " << func_name <<
" not supported.";
1532 throw std::runtime_error(oss.str());
1537 switch (string_op_kind) {
1539 return makeExpr<Analyzer::LowerStringOper>(
args);
1541 return makeExpr<Analyzer::UpperStringOper>(
args);
1543 return makeExpr<Analyzer::InitCapStringOper>(
args);
1545 return makeExpr<Analyzer::ReverseStringOper>(
args);
1547 return makeExpr<Analyzer::RepeatStringOper>(
args);
1549 return makeExpr<Analyzer::ConcatStringOper>(
args);
1552 return makeExpr<Analyzer::PadStringOper>(string_op_kind,
args);
1557 return makeExpr<Analyzer::TrimStringOper>(string_op_kind,
args);
1560 return makeExpr<Analyzer::SubstringStringOper>(
args);
1562 return makeExpr<Analyzer::OverlayStringOper>(
args);
1564 return makeExpr<Analyzer::ReplaceStringOper>(
args);
1566 return makeExpr<Analyzer::SplitPartStringOper>(
args);
1568 return makeExpr<Analyzer::RegexpReplaceStringOper>(
args);
1570 return makeExpr<Analyzer::RegexpSubstrStringOper>(
args);
1572 return makeExpr<Analyzer::RegexpCountStringOper>(
args);
1574 return makeExpr<Analyzer::JsonValueStringOper>(
args);
1576 return makeExpr<Analyzer::Base64EncodeStringOper>(
args);
1578 return makeExpr<Analyzer::Base64DecodeStringOper>(
args);
1581 args.front()->get_type_info().is_string()) {
1583 return args.front();
1585 return makeExpr<Analyzer::TryStringCastOper>(rex_function->
getType(),
args);
1587 return makeExpr<Analyzer::PositionStringOper>(
args);
1589 return makeExpr<Analyzer::JarowinklerSimilarityStringOper>(
args);
1591 return makeExpr<Analyzer::LevenshteinDistanceStringOper>(
args);
1593 return makeExpr<Analyzer::HashStringOper>(
args);
1595 return makeExpr<Analyzer::UrlEncodeStringOper>(
args);
1597 return makeExpr<Analyzer::UrlDecodeStringOper>(
args);
1599 throw std::runtime_error(
"Unsupported string function.");
1606 const auto ret_ti = rex_function->
getType();
1608 const auto arg_ti = arg->get_type_info();
1609 if (!arg_ti.is_array()) {
1610 throw std::runtime_error(rex_function->
getName() +
" expects an array expression.");
1612 if (arg_ti.get_subtype() ==
kARRAY) {
1613 throw std::runtime_error(rex_function->
getName() +
1614 " expects one-dimension array expression.");
1616 const auto array_size = arg_ti.get_size();
1617 const auto array_elem_size = arg_ti.get_elem_type().get_array_context_logical_size();
1619 if (array_size > 0) {
1620 if (array_elem_size <= 0) {
1621 throw std::runtime_error(rex_function->
getName() +
1622 ": unexpected array element type.");
1628 return makeExpr<Analyzer::CardinalityExpr>(arg);
1636 return makeExpr<Analyzer::BinOper>(
1637 base->get_type_info().get_elem_type(),
false,
kARRAY_AT,
kONE, base, index);
1641 constexpr
bool is_null =
false;
1644 return makeExpr<Analyzer::Constant>(
kDATE,
is_null, datum);
1648 constexpr
bool is_null =
false;
1651 return makeExpr<Analyzer::Constant>(
kTIME,
is_null, datum);
1663 const std::string datetime_err{R
"(Only DATETIME('NOW') supported for now.)"};
1664 if (!arg_lit || arg_lit->get_is_null()) {
1665 throw std::runtime_error(datetime_err);
1667 CHECK(arg_lit->get_type_info().is_string());
1668 if (*arg_lit->get_constval().stringval !=
"NOW"sv) {
1669 throw std::runtime_error(datetime_err);
1676 std::list<std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>
1680 const auto& operand_ti = operand->get_type_info();
1681 CHECK(operand_ti.is_number());
1683 const auto lt_zero = makeExpr<Analyzer::BinOper>(
kBOOLEAN,
kLT,
kONE, operand, zero);
1684 const auto uminus_operand =
1685 makeExpr<Analyzer::UOper>(operand_ti.get_type(),
kUMINUS, operand);
1686 expr_list.emplace_back(lt_zero, uminus_operand);
1687 return makeExpr<Analyzer::CaseExpr>(operand_ti,
false, expr_list, operand);
1692 std::list<std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>
1696 const auto& operand_ti = operand->get_type_info();
1697 CHECK(operand_ti.is_number());
1699 const auto lt_zero = makeExpr<Analyzer::BinOper>(
kBOOLEAN,
kLT,
kONE, operand, zero);
1701 const auto eq_zero = makeExpr<Analyzer::BinOper>(
kBOOLEAN,
kEQ,
kONE, operand, zero);
1703 const auto gt_zero = makeExpr<Analyzer::BinOper>(
kBOOLEAN,
kGT,
kONE, operand, zero);
1705 return makeExpr<Analyzer::CaseExpr>(
1709 makeExpr<Analyzer::Constant>(operand_ti,
true,
Datum{0}));
1713 return makeExpr<Analyzer::OffsetInFragment>();
1719 auto sql_type = rex_function->
getType();
1724 if (translated_function_args.size() > 0) {
1725 const auto first_element_logical_type =
1728 auto diff_elem_itr =
1729 std::find_if(translated_function_args.begin(),
1730 translated_function_args.end(),
1731 [first_element_logical_type](
const auto expr) {
1732 const auto element_logical_type =
1734 if (first_element_logical_type != element_logical_type) {
1735 if (first_element_logical_type.is_none_encoded_string() &&
1736 element_logical_type.is_none_encoded_string()) {
1743 if (diff_elem_itr != translated_function_args.end()) {
1744 throw std::runtime_error(
1746 std::to_string(diff_elem_itr - translated_function_args.begin()) +
1747 " is not of the same type as other elements of the array. Consider casting "
1748 "to force this condition.\nElement Type: " +
1751 "\nArray type: " + first_element_logical_type.to_string());
1754 if (first_element_logical_type.is_string()) {
1755 sql_type.set_subtype(
kTEXT);
1757 if (first_element_logical_type.is_none_encoded_string()) {
1761 CHECK(first_element_logical_type.is_dict_encoded_string());
1762 sql_type.set_comp_param(first_element_logical_type.get_comp_param());
1763 sql_type.setStringDictKey(first_element_logical_type.getStringDictKey());
1765 }
else if (first_element_logical_type.is_dict_encoded_string()) {
1766 sql_type.set_subtype(
kTEXT);
1768 sql_type.set_comp_param(first_element_logical_type.get_comp_param());
1769 sql_type.setStringDictKey(first_element_logical_type.getStringDictKey());
1771 sql_type.set_subtype(first_element_logical_type.get_type());
1772 sql_type.set_scale(first_element_logical_type.get_scale());
1773 sql_type.set_precision(first_element_logical_type.get_precision());
1776 return makeExpr<Analyzer::ArrayExpr>(sql_type, translated_function_args);
1780 return makeExpr<Analyzer::ArrayExpr>(sql_type, translated_function_args);
1783 return makeExpr<Analyzer::ArrayExpr>(rex_function->
getType(),
1793 if (rex_function->
getName() ==
"REGEXP_LIKE"sv) {
1796 if (rex_function->
getName() ==
"LIKELY"sv) {
1799 if (rex_function->
getName() ==
"UNLIKELY"sv) {
1805 if (rex_function->
getName() ==
"DATEADD"sv) {
1808 if (rex_function->
getName() ==
"DATEDIFF"sv) {
1811 if (rex_function->
getName() ==
"DATEPART"sv) {
1817 if (rex_function->
getName() ==
"KEY_FOR_STRING"sv) {
1820 if (rex_function->
getName() ==
"WIDTH_BUCKET"sv) {
1823 if (rex_function->
getName() ==
"SAMPLE_RATIO"sv) {
1826 if (rex_function->
getName() ==
"CURRENT_USER"sv) {
1829 if (rex_function->
getName() ==
"ML_PREDICT"sv) {
1832 if (rex_function->
getName() ==
"PCA_PROJECT"sv) {
1862 "JAROWINKLER_SIMILARITY"sv,
1863 "LEVENSHTEIN_DISTANCE"sv,
1870 if (rex_function->
getName() ==
"ITEM"sv) {
1873 if (rex_function->
getName() ==
"CURRENT_DATE"sv) {
1876 if (rex_function->
getName() ==
"CURRENT_TIME"sv) {
1879 if (rex_function->
getName() ==
"CURRENT_TIMESTAMP"sv) {
1882 if (rex_function->
getName() ==
"NOW"sv) {
1885 if (rex_function->
getName() ==
"DATETIME"sv) {
1891 if (rex_function->
getName() ==
"ABS"sv) {
1894 if (rex_function->
getName() ==
"SIGN"sv) {
1898 return makeExpr<Analyzer::FunctionOperWithCustomTypeHandling>(
1902 }
else if (rex_function->
getName() ==
"ROUND"sv) {
1903 std::vector<std::shared_ptr<Analyzer::Expr>>
args =
1906 if (rex_function->
size() == 1) {
1914 args.push_back(makeExpr<Analyzer::Constant>(t,
false, d));
1918 CHECK(args.size() == 2);
1920 if (!args[0]->get_type_info().is_number()) {
1921 throw std::runtime_error(
"Only numeric 1st operands are supported");
1926 if (!args[1]->get_type_info().is_integer()) {
1927 throw std::runtime_error(
"Only integer 2nd operands are supported");
1934 ? args[0]->get_type_info()
1937 return makeExpr<Analyzer::FunctionOperWithCustomTypeHandling>(
1940 if (rex_function->
getName() ==
"DATETIME_PLUS"sv) {
1941 auto dt_plus = makeExpr<Analyzer::FunctionOper>(rex_function->
getType(),
1950 if (rex_function->
getName() ==
"/INT"sv) {
1957 if (rex_function->
getName() ==
"Reinterpret"sv) {
1969 "ST_NumGeometries"sv,
1975 "HeavyDB_Geo_PolyBoundsPtr"sv)) {
1985 "convert_meters_to_pixel_width"sv,
1986 "convert_meters_to_pixel_height"sv,
1987 "is_point_in_view"sv,
1988 "is_point_size_in_view"sv)) {
1997 "ST_IntersectsBox"sv,
1998 "ST_Approx_Overlaps"sv,
2007 if (rex_function->
getName() ==
"OFFSET_IN_FRAGMENT"sv) {
2011 if (rex_function->
getName() ==
"ARRAY"sv) {
2016 "ST_GeomFromText"sv,
2017 "ST_GeogFromText"sv,
2024 "ST_Transform"sv)) {
2029 "ST_Intersection"sv,
2033 "ST_ConcaveHull"sv)) {
2047 return distance_check;
2054 if (rex_function->
getName() == std::string(
"||") ||
2055 rex_function->
getName() == std::string(
"SUBSTRING")) {
2057 return makeExpr<Analyzer::FunctionOper>(
2058 ret_ti, rex_function->
getName(), arg_expr_list);
2069 auto ext_func_args = ext_func_sig.getInputArgs();
2070 CHECK_LE(arg_expr_list.size(), ext_func_args.size());
2071 for (
size_t i = 0, di = 0; i < arg_expr_list.size(); i++) {
2072 CHECK_LT(i + di, ext_func_args.size());
2073 auto ext_func_arg = ext_func_args[i + di];
2087 std::dynamic_pointer_cast<Analyzer::Constant>(arg_expr_list[i])) {
2089 if (ext_func_arg_ti != arg_expr_list[i]->get_type_info()) {
2090 arg_expr_list[i] = constant->add_cast(ext_func_arg_ti);
2097 LOG(
WARNING) <<
"RelAlgTranslator::translateFunction: " << e.what();
2103 bool arguments_not_null =
true;
2104 for (
const auto& arg_expr : arg_expr_list) {
2105 if (!arg_expr->get_type_info().get_notnull()) {
2106 arguments_not_null =
false;
2112 return makeExpr<Analyzer::FunctionOper>(ret_ti, rex_function->
getName(), arg_expr_list);
2118 const std::vector<SortField>& sort_fields) {
2119 std::vector<Analyzer::OrderEntry> collation;
2120 for (
size_t i = 0; i < sort_fields.size(); ++i) {
2121 const auto& sort_field = sort_fields[i];
2122 collation.emplace_back(i,
2160 if (time_unit_val == 1) {
2162 }
else if (time_unit_val == 12) {
2197 bool is_time_unit =
false) {
2209 CHECK(is_time_unit);
2217 throw std::runtime_error(
2218 "We currently only support integer-type literal expression as a window "
2219 "frame bound expression");
2230 std::tuple<bool, bool, std::shared_ptr<Analyzer::Expr>>
2232 bool negative_constant =
false;
2233 if (dynamic_cast<const RexOperator*>(bound_expr)) {
2235 const auto bin_oper =
dynamic_cast<const Analyzer::BinOper*
>(translated_expr.get());
2236 auto time_literal_expr =
2238 CHECK(time_literal_expr);
2241 time_literal_expr->get_constval(),
2243 return std::make_tuple(
false, negative_constant, translated_expr);
2244 }
else if (dynamic_cast<const RexLiteral*>(bound_expr)) {
2246 if (
auto literal_expr =
2247 dynamic_cast<const Analyzer::Constant*>(translated_expr.get())) {
2249 literal_expr->get_type_info().get_type(), literal_expr->get_constval());
2250 return std::make_tuple(
false, negative_constant, translated_expr);
2253 return std::make_tuple(
true, negative_constant,
nullptr);
2258 std::vector<std::shared_ptr<Analyzer::Expr>>
args;
2259 for (
size_t i = 0; i < rex_window_function->
size(); ++i) {
2262 std::vector<std::shared_ptr<Analyzer::Expr>> partition_keys;
2263 for (
const auto& partition_key : rex_window_function->
getPartitionKeys()) {
2266 std::vector<std::shared_ptr<Analyzer::Expr>> order_keys;
2267 for (
const auto& order_key : rex_window_function->
getOrderKeys()) {
2270 std::vector<Analyzer::OrderEntry> collation =
2273 auto ti = rex_window_function->
getType();
2274 auto window_func_kind = rex_window_function->
getKind();
2282 ti = args.front()->get_type_info();
2285 ti.set_notnull(
false);
2288 bool negative_constant =
false;
2289 bool detect_invalid_frame_start_bound_expr =
false;
2290 bool detect_invalid_frame_end_bound_expr =
false;
2293 bool has_end_bound_frame_expr =
false;
2294 std::shared_ptr<Analyzer::Expr> frame_start_bound_expr;
2297 std::shared_ptr<Analyzer::Expr> frame_end_bound_expr;
2300 bool has_framing_clause =
2302 auto frame_mode = rex_window_function->
isRows()
2305 if (order_keys.empty()) {
2312 has_framing_clause =
false;
2315 if (frame_start_bound.bound_expr) {
2316 std::tie(detect_invalid_frame_start_bound_expr,
2318 frame_start_bound_expr) =
2322 if (frame_end_bound.bound_expr) {
2324 detect_invalid_frame_end_bound_expr, negative_constant, frame_end_bound_expr) =
2329 if (detect_invalid_frame_start_bound_expr || detect_invalid_frame_end_bound_expr) {
2330 throw std::runtime_error(
2331 "We currently only support literal expression as a window frame bound "
2337 if (negative_constant) {
2338 throw std::runtime_error(
2339 "A constant expression for window framing should have nonnegative value.");
2342 if (frame_start_bound_expr &&
2343 frame_start_bound_expr->get_type_info().is_timeinterval()) {
2347 frame_start_bound_expr.get());
2350 if (frame_end_bound_expr && frame_end_bound_expr->get_type_info().is_timeinterval()) {
2354 frame_end_bound_expr.get());
2358 if (frame_start_bound.following) {
2359 if (frame_end_bound.is_current_row) {
2360 throw std::runtime_error(
2361 "Window framing starting from following row cannot end with current row.");
2362 }
else if (has_end_bound_frame_expr && frame_end_bound.preceding) {
2363 throw std::runtime_error(
2364 "Window framing starting from following row cannot have preceding rows.");
2368 if (frame_start_bound.is_current_row && frame_end_bound.preceding &&
2369 !frame_end_bound.unbounded && has_end_bound_frame_expr) {
2370 throw std::runtime_error(
2371 "Window framing starting from current row cannot have preceding rows.");
2374 if (!frame_start_bound_expr &&
2376 !frame_end_bound_expr &&
2378 has_framing_clause =
false;
2379 VLOG(1) <<
"Ignore range framing mode with a frame bound between "
2380 "UNBOUNDED_PRECEDING and CURRENT_ROW";
2383 if (has_framing_clause) {
2385 if (order_keys.size() != 1) {
2386 throw std::runtime_error(
2387 "Window framing with range mode requires a single order-by column");
2390 bool (*)(
const Analyzer::ColumnVar*,
const Analyzer::ColumnVar*)>
2393 for (
auto cv : colvar_set) {
2394 if (!(cv->get_type_info().is_integer() || cv->get_type_info().is_fp() ||
2395 cv->get_type_info().is_time())) {
2396 has_framing_clause =
false;
2397 VLOG(1) <<
"Range framing mode with non-number type ordering column is not "
2398 "supported yet, skip window framing";
2404 std::string
const func_name =
toString(window_func_kind);
2405 auto const num_args = args.size();
2406 bool need_order_by_clause =
false;
2407 bool need_frame_def =
false;
2408 switch (window_func_kind) {
2410 if (has_framing_clause && args.empty()) {
2418 need_order_by_clause =
true;
2419 need_frame_def =
true;
2420 if (num_args != 2) {
2421 throw std::runtime_error(func_name +
" has an invalid number of input arguments");
2425 args.push_back(makeExpr<Analyzer::Constant>(
kINT,
false, d));
2426 const auto target_expr_cv =
2428 if (!target_expr_cv) {
2429 throw std::runtime_error(
"Currently, " + func_name +
2430 " only allows a column reference as its first argument");
2432 const auto target_ti = target_expr_cv->get_type_info();
2433 if (target_ti.is_dict_encoded_string()) {
2437 ti.set_comp_param(target_expr_cv->get_type_info().get_comp_param());
2438 ti.setStringDictKey(target_expr_cv->get_type_info().getStringDictKey());
2439 ti.set_fixed_size();
2441 const auto target_offset_cv =
2443 if (!target_expr_cv ||
2445 target_offset_cv->get_constval())) {
2446 throw std::runtime_error(
2447 "Currently, " + func_name +
2448 " only allows non-negative constant as its second argument");
2454 if (num_args != 1) {
2455 throw std::runtime_error(func_name +
" has an invalid number of input arguments");
2457 need_order_by_clause =
true;
2458 need_frame_def =
true;
2462 if (has_framing_clause) {
2463 throw std::runtime_error(func_name +
" does not support window framing clause");
2465 auto const input_expr_ti = args.front()->get_type_info();
2466 if (input_expr_ti.is_string()) {
2467 throw std::runtime_error(func_name +
" not supported on " +
2468 input_expr_ti.get_type_name() +
" type yet");
2470 need_order_by_clause =
true;
2471 std::string
const arg_str{args.front()->toString()};
2472 bool needs_inject_input_arg_ordering =
2475 [&arg_str](std::shared_ptr<Analyzer::Expr>
const& expr) {
2476 return boost::equals(arg_str, expr->toString());
2478 if (needs_inject_input_arg_ordering) {
2479 VLOG(1) <<
"Inject " << args.front()->toString() <<
" as ordering column of the "
2480 << func_name <<
" function";
2481 order_keys.push_back(args.front());
2484 collation.emplace_back(collation.size() + 1,
2493 if (num_args != 2) {
2494 throw std::runtime_error(func_name +
" has an invalid number of input arguments");
2497 need_order_by_clause =
true;
2498 need_frame_def =
true;
2501 throw std::runtime_error(func_name +
2502 " must have a positional argument expression.");
2504 bool has_valid_arg =
false;
2505 if (args[1]->get_type_info().is_integer()) {
2506 if (
auto* n_value_ptr = dynamic_cast<Analyzer::Constant*>(args[1].
get())) {
2507 if (0 < n_value_ptr->get_constval().intval) {
2510 auto d = n_value_ptr->get_constval();
2512 n_value_ptr->set_constval(d);
2513 has_valid_arg =
true;
2517 if (!has_valid_arg) {
2518 throw std::runtime_error(
"The positional argument of the " + func_name +
2519 " must be a positive integer constant.");
2524 if (order_keys.empty()) {
2525 throw std::runtime_error(
2526 func_name +
" requires an ORDER BY sub-clause within the window clause");
2528 if (has_framing_clause) {
2531 <<
" must use a pre-defined window frame range (e.g., ROWS BETWEEN "
2532 "UNBOUNDED PRECEDING AND CURRENT ROW). "
2533 "Thus, we skip the user-defined window frame for this window function";
2535 has_framing_clause =
true;
2543 if (need_order_by_clause && order_keys.empty()) {
2544 throw std::runtime_error(func_name +
" requires an ORDER BY clause");
2547 if (need_frame_def && !has_framing_clause) {
2548 throw std::runtime_error(func_name +
" requires window frame definition");
2551 if (!has_framing_clause) {
2554 frame_start_bound_expr =
nullptr;
2555 frame_end_bound_expr =
nullptr;
2558 return makeExpr<Analyzer::WindowFunction>(
2560 rex_window_function->
getKind(),
2565 makeExpr<Analyzer::WindowFrame>(frame_start_bound_type, frame_start_bound_expr),
2566 makeExpr<Analyzer::WindowFrame>(frame_end_bound_type, frame_end_bound_expr),
2571 std::shared_ptr<Analyzer::Expr> order_key,
2572 bool for_preceding_bound,
2578 CHECK(frame_bound_expr);
2580 const auto order_key_ti = order_key->get_type_info();
2581 const auto frame_bound_ti = frame_bound_expr->get_type_info();
2582 const auto time_val_expr =
2584 const auto time_unit_val_expr =
2588 bool invalid_time_unit_type =
false;
2589 bool invalid_frame_bound_expr_type =
false;
2591 auto prepare_time_value_datum = [&d,
2592 &invalid_frame_bound_expr_type,
2594 &for_preceding_bound](
bool is_timestamp_second) {
2601 switch (time_val_expr->get_type_info().get_type()) {
2603 d.
bigintval = time_val_expr->get_constval().tinyintval;
2607 d.
bigintval = time_val_expr->get_constval().smallintval;
2611 d.
bigintval = time_val_expr->get_constval().intval;
2615 d.
bigintval = time_val_expr->get_constval().bigintval;
2620 if (!is_timestamp_second) {
2622 invalid_frame_bound_expr_type =
true;
2625 d.
bigintval = time_val_expr->get_constval().bigintval;
2629 if (!is_timestamp_second) {
2631 invalid_frame_bound_expr_type =
true;
2634 d.
bigintval = time_val_expr->get_constval().doubleval *
2635 pow(10, time_val_expr->get_type_info().get_scale());
2639 invalid_frame_bound_expr_type =
true;
2643 if (for_preceding_bound) {
2648 switch (order_key_ti.get_type()) {
2650 if (time_val_expr->get_type_info().is_integer()) {
2653 frame_bound_ti.get_type(), time_unit_val_expr);
2654 switch (time_val_expr->get_type_info().get_type()) {
2656 d.
bigintval = time_val_expr->get_constval().tinyintval * time_multiplier;
2660 d.
bigintval = time_val_expr->get_constval().smallintval * time_multiplier;
2664 d.
bigintval = time_val_expr->get_constval().intval * time_multiplier;
2668 d.
bigintval = time_val_expr->get_constval().bigintval * time_multiplier;
2677 invalid_frame_bound_expr_type =
true;
2680 invalid_time_unit_type =
true;
2682 if (invalid_frame_bound_expr_type) {
2683 throw std::runtime_error(
2684 "Invalid time unit is used to define window frame bound expression for " +
2685 order_key_ti.get_type_name() +
" type");
2686 }
else if (invalid_time_unit_type) {
2687 throw std::runtime_error(
2688 "Window frame bound expression has an invalid type for " +
2689 order_key_ti.get_type_name() +
" type");
2691 return std::make_shared<Analyzer::Constant>(
kBIGINT,
false, d);
2695 if (time_val_expr->get_type_info().is_integer()) {
2696 switch (time_unit) {
2710 invalid_frame_bound_expr_type =
true;
2715 invalid_time_unit_type =
true;
2717 if (invalid_frame_bound_expr_type) {
2718 throw std::runtime_error(
2719 "Invalid time unit is used to define window frame bound expression for " +
2720 order_key_ti.get_type_name() +
" type");
2721 }
else if (invalid_time_unit_type) {
2722 throw std::runtime_error(
2723 "Window frame bound expression has an invalid type for " +
2724 order_key_ti.get_type_name() +
" type");
2727 prepare_time_value_datum(
false);
2728 const auto cast_number_units = makeExpr<Analyzer::Constant>(
kBIGINT,
false, d);
2729 const int dim = order_key_ti.get_dimension();
2730 return makeExpr<Analyzer::DateaddExpr>(
2735 switch (time_unit) {
2737 switch (time_val_expr->get_type_info().get_scale()) {
2758 prepare_time_value_datum(
true);
2763 prepare_time_value_datum(
false);
2768 prepare_time_value_datum(
false);
2773 prepare_time_value_datum(
false);
2778 prepare_time_value_datum(
false);
2783 prepare_time_value_datum(
false);
2787 invalid_time_unit_type =
true;
2791 if (!invalid_time_unit_type) {
2793 const auto cast_number_units = makeExpr<Analyzer::Constant>(
kBIGINT,
false, d);
2794 const int dim = order_key_ti.get_dimension();
2807 if (invalid_frame_bound_expr_type) {
2808 throw std::runtime_error(
2809 "Invalid time unit is used to define window frame bound expression for " +
2810 order_key_ti.get_type_name() +
" type");
2811 }
else if (invalid_time_unit_type) {
2812 throw std::runtime_error(
"Window frame bound expression has an invalid type for " +
2813 order_key_ti.get_type_name() +
" type");
2820 std::vector<std::shared_ptr<Analyzer::Expr>>
args;
2821 for (
size_t i = 0; i < rex_function->
size(); ++i) {
2828 const std::shared_ptr<Analyzer::Expr> qual_expr) {
2832 const auto rewritten_qual_expr =
rewrite_expr(qual_expr.get());
2833 return {{}, {rewritten_qual_expr ? rewritten_qual_expr : qual_expr}};
2836 if (bin_oper->get_optype() ==
kAND) {
2840 simple_quals.insert(
2841 simple_quals.end(), rhs_cf.simple_quals.begin(), rhs_cf.simple_quals.end());
2842 auto quals = lhs_cf.quals;
2843 quals.insert(quals.end(), rhs_cf.quals.begin(), rhs_cf.quals.end());
2844 return {simple_quals, quals};
2847 const auto simple_qual = bin_oper->normalize_simple_predicate(rte_idx);
2853 const std::shared_ptr<Analyzer::Expr>& qual_expr) {
2855 const auto bin_oper = std::dynamic_pointer_cast<
const Analyzer::BinOper>(qual_expr);
2857 const auto rewritten_qual_expr =
rewrite_expr(qual_expr.get());
2858 return {rewritten_qual_expr ? rewritten_qual_expr : qual_expr};
2860 if (bin_oper->get_optype() ==
kOR) {
2863 auto quals = lhs_df;
2864 quals.insert(quals.end(), rhs_df.begin(), rhs_df.end());
2880 const auto& operand_ti = operand->get_type_info();
2881 const auto& target_ti = rex_function->
getType();
2882 if (!operand_ti.is_string()) {
2883 throw std::runtime_error(
2884 "High precision timestamp cast argument must be a string. Input type is: " +
2885 operand_ti.get_type_name());
2886 }
else if (!target_ti.is_high_precision_timestamp()) {
2887 throw std::runtime_error(
2888 "Cast target type should be high precision timestamp. Input type is: " +
2889 target_ti.get_type_name());
2890 }
else if (target_ti.get_dimension() != 6 && target_ti.get_dimension() != 9) {
2891 throw std::runtime_error(
2892 "Cast target type should be TIMESTAMP(6|9). Input type is: TIMESTAMP(" +
2895 return operand->add_cast(target_ti);
DEVICE auto upper_bound(ARGS &&...args)
Defines data structures for the semantic analysis phase of query processing.
size_t g_watchdog_in_clause_max_num_elem_non_bitmap
SqlWindowFrameBoundType determine_frame_bound_type(const RexWindowFunctionOperator::RexWindowBound &bound)
const RexScalar * getThen(const size_t idx) const
const std::vector< JoinType > join_types_
HOST DEVICE SQLTypes get_subtype() const
void set_compression(EncodingType c)
static std::shared_ptr< Analyzer::Expr > normalize(const std::list< std::pair< std::shared_ptr< Analyzer::Expr >, std::shared_ptr< Analyzer::Expr >>> &, const std::shared_ptr< Analyzer::Expr >, const Executor *executor=nullptr)
std::shared_ptr< Analyzer::Expr > translateOffsetInFragment() const
SqlStringOpKind name_to_string_op_kind(const std::string &func_name)
static std::shared_ptr< Analyzer::Expr > get(const std::string &)
std::shared_ptr< Analyzer::Expr > translateCurrentTimestamp() const
std::shared_ptr< Analyzer::Expr > translateBinaryGeoPredicate(const RexFunctionOperator *, SQLTypeInfo &, const bool with_bounds) const
std::shared_ptr< Analyzer::Expr > translateRegexp(const RexFunctionOperator *) const
static bool colvar_comp(const ColumnVar *l, const ColumnVar *r)
size_t getOperand(size_t idx) const
const Executor * executor_
std::shared_ptr< Analyzer::Expr > translateUnlikely(const RexFunctionOperator *) const
const RexScalar * getElse() const
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 >(RelAlgTranslator::*)(RexScalar const *) const Handler
static std::shared_ptr< Analyzer::Expr > analyzeValue(const int64_t intval)
std::shared_ptr< Analyzer::Expr > translateFunction(const RexFunctionOperator *) const
SQLTypeInfo get_nullable_logical_type_info(const SQLTypeInfo &type_info)
std::shared_ptr< Analyzer::Expr > translateScalarRex(const RexScalar *rex) const
const SQLTypeInfo & getType() const
const RexScalar * getOperand(const size_t idx) const
std::shared_ptr< Analyzer::Expr > translateUoper(const RexOperator *) const
HOST DEVICE int get_scale() const
const std::vector< SortField > & getCollation() const
std::shared_ptr< Analyzer::Expr > translateDateadd(const RexFunctionOperator *) const
static bool isFramingAvailableWindowFunc(SqlWindowFunctionKind kind)
static std::shared_ptr< Analyzer::Expr > normalize(const SQLOps optype, const SQLQualifier qual, std::shared_ptr< Analyzer::Expr > left_expr, std::shared_ptr< Analyzer::Expr > right_expr, const Executor *executor=nullptr)
TypeR::rep timer_stop(Type clock_begin)
std::shared_ptr< Analyzer::Expr > translateAbs(const RexFunctionOperator *) const
const RexScalar * getWhen(const size_t idx) const
std::shared_ptr< Analyzer::Expr > ExpressionPtr
std::string getString(int32_t string_id) const
std::shared_ptr< Analyzer::Expr > getInIntegerSetExpr(std::shared_ptr< Analyzer::Expr > arg, const ResultSet &val_set) const
SQLTypeInfo get_agg_type(const SQLAgg agg_kind, const Analyzer::Expr *arg_expr)
std::shared_ptr< Analyzer::Expr > translateItem(const RexFunctionOperator *) const
std::shared_ptr< Analyzer::Constant > makeNumericConstant(const SQLTypeInfo &ti, const long val)
Analyzer::ExpressionPtr rewrite_expr(const Analyzer::Expr *expr)
std::type_index const type_index_
HOST DEVICE SQLTypes get_type() const
bool operator()(IndexedHandler const &pair) const
QualsConjunctiveForm qual_to_conjunctive_form(const std::shared_ptr< Analyzer::Expr > qual_expr)
#define TRANSIENT_DICT_ID
bool is_agg_supported_for_type(const SQLAgg &agg_kind, const SQLTypeInfo &arg_ti)
std::shared_ptr< const RexScalar > bound_expr
std::shared_ptr< Analyzer::Expr > translateGeoProjection(const RexFunctionOperator *, SQLTypeInfo &, const bool with_bounds) const
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
std::shared_ptr< Analyzer::Expr > translateOper(const RexOperator *) const
std::shared_ptr< Analyzer::Expr > translateDatediff(const RexFunctionOperator *) const
std::shared_ptr< Analyzer::Expr > translateInput(const RexInput *) const
std::shared_ptr< Analyzer::Expr > translateSign(const RexFunctionOperator *) const
std::shared_ptr< Analyzer::Expr > translateUnaryGeoFunction(const RexFunctionOperator *) const
bool g_enable_string_functions
std::shared_ptr< Analyzer::Expr > translateBoundingBoxIntersectOper(const RexOperator *) const
ExtractField to_datepart_field(const std::string &field)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
robin_hood::unordered_map< RexScalar const *, std::shared_ptr< Analyzer::Expr > > cache_
Supported runtime functions management and retrieval.
future< Result > async(Fn &&fn, Args &&...args)
static SysCatalog & instance()
static std::shared_ptr< Analyzer::Expr > translateLiteral(const RexLiteral *)
SQLOps getOperator() const
bool window_function_is_value(const SqlWindowFunctionKind kind)
static constexpr int32_t INVALID_STR_ID
CONSTEXPR DEVICE bool is_null(const T &value)
Classes representing a parse tree.
std::shared_ptr< Analyzer::Expr > translateDatetime(const RexFunctionOperator *) const
void fill_dictionary_encoded_in_vals(std::vector< int64_t > &in_vals, std::atomic< size_t > &total_in_vals_count, const ResultSet *values_rowset, const std::pair< int64_t, int64_t > values_rowset_slice, const StringDictionaryProxy *source_dict, const StringDictionaryProxy *dest_dict, const int64_t needle_null_val)
std::shared_ptr< Analyzer::Expr > translateStringOper(const RexFunctionOperator *) const
static std::shared_ptr< Analyzer::Expr > get(std::shared_ptr< Analyzer::Expr > arg_expr, std::shared_ptr< Analyzer::Expr > pattern_expr, std::shared_ptr< Analyzer::Expr > escape_expr, const bool is_not)
size_t determineTimeValMultiplierForTimeType(const SQLTypes &window_frame_bound_type, const Analyzer::Constant *const_expr)
std::pair< std::shared_ptr< Analyzer::Expr >, SQLQualifier > getQuantifiedRhs(const RexScalar *) const
std::vector< Analyzer::OrderEntry > translate_collation(const std::vector< SortField > &sort_fields)
size_t branchCount() const
std::shared_ptr< Analyzer::Expr > translateCurrentTime() const
bool is_distinct_supported(SQLAgg const agg_kind)
SQLTypeInfo build_type_info(const SQLTypes sql_type, const int scale, const int precision)
DatetruncField to_datediff_field(const std::string &field)
std::array< IndexedHandler, sizeof...(Ts)> makeHandlers()
const RexWindowBound & getFrameEndBound() const
std::tuple< bool, bool, std::shared_ptr< Analyzer::Expr > > translateFrameBoundExpr(const RexScalar *bound_expr) const
std::shared_ptr< Analyzer::Expr > translate(const RexScalar *rex) const
std::string toString(const Executor::ExtModuleKinds &kind)
std::tuple< T, std::vector< SQLTypeInfo > > bind_function(std::string name, Analyzer::ExpressionPtrVector func_args, const std::vector< T > &ext_funcs, const std::string processor)
Argument type based extension function binding.
ByTypeIndex(std::type_info const &type_info)
std::shared_ptr< Analyzer::Expr > translatePCAProject(const RexFunctionOperator *) const
const std::unordered_map< const RelAlgNode *, int > input_to_nest_level_
void translate_string_ids(std::vector< int32_t > &dest_ids, const LeafHostInfo &dict_server_host, const shared::StringDictKey &dest_dict_key, const std::vector< int32_t > &source_ids, const shared::StringDictKey &source_dict_key, const int32_t dest_generation)
void set_comp_param(int p)
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
Analyzer::ExpressionPtrVector translateFunctionArgs(const RexFunctionOperator *) const
std::shared_ptr< Analyzer::Expr > translateUnaryGeoPredicate(const RexFunctionOperator *, SQLTypeInfo &, const bool with_bounds) const
size_t g_watchdog_in_clause_max_num_input_rows
const ConstRexScalarPtrVector & getPartitionKeys() const
static std::shared_ptr< Analyzer::Expr > analyzeValue(const std::string &stringval, const bool is_null)
std::shared_ptr< Analyzer::Expr > translateIntervalExprForWindowFraming(std::shared_ptr< Analyzer::Expr > order_key, bool for_preceding_bound, const Analyzer::Expr *expr) const
DEVICE auto lower_bound(ARGS &&...args)
bool is_negative_framing_bound(const SQLTypes t, const Datum &d, bool is_time_unit=false)
const RexWindowBound & getFrameStartBound() const
std::shared_ptr< Analyzer::Expr > translateUnaryGeoConstructor(const RexFunctionOperator *, SQLTypeInfo &, const bool with_bounds) const
std::shared_ptr< Analyzer::Expr > translateArrayFunction(const RexFunctionOperator *) const
static std::shared_ptr< Analyzer::Expr > get(std::shared_ptr< Analyzer::Expr > arg_expr, std::shared_ptr< Analyzer::Expr > like_expr, std::shared_ptr< Analyzer::Expr > escape_expr, const bool is_ilike, const bool is_not)
std::pair< std::type_index, Handler > IndexedHandler
void setStringDictKey(const shared::StringDictKey &dict_key)
static RelRexToStringConfig defaults()
Datum get_constval() const
std::shared_ptr< Analyzer::Expr > translateMLPredict(const RexFunctionOperator *) const
std::shared_ptr< Analyzer::Expr > translateCurrentUser(const RexFunctionOperator *) const
std::shared_ptr< Analyzer::Expr > translateSampleRatio(const RexFunctionOperator *) const
SqlWindowFunctionKind getKind() const
std::shared_ptr< Analyzer::Expr > translateLike(const RexFunctionOperator *) const
bool takes_arg(const TargetInfo &target_info)
static std::shared_ptr< Analyzer::Expr > analyzeValue(const int64_t numericval, const int scale, const int precision)
std::shared_ptr< Analyzer::Expr > translateLikely(const RexFunctionOperator *) const
bool window_function_is_value_with_frame(const SqlWindowFunctionKind kind)
size_t g_in_clause_num_elem_skip_bitmap
static const StringDictKey kTransientDictKey
std::shared_ptr< Analyzer::Expr > get_in_values_expr(std::shared_ptr< Analyzer::Expr > arg, const ResultSet &val_set)
static std::shared_ptr< Analyzer::Expr > get(const int64_t)
std::shared_ptr< Analyzer::Expr > translateTernaryGeoFunction(const RexFunctionOperator *) const
const ConstRexScalarPtrVector & getOrderKeys() const
std::vector< std::shared_ptr< Analyzer::Expr > > qual_to_disjunctive_form(const std::shared_ptr< Analyzer::Expr > &qual_expr)
std::shared_ptr< Analyzer::Expr > translateBinaryGeoFunction(const RexFunctionOperator *) const
std::shared_ptr< Analyzer::Constant > make_fp_constant(const int64_t val, const SQLTypeInfo &ti)
std::pair< Datum, bool > datum_from_scalar_tv(const ScalarTargetValue *scalar_tv, const SQLTypeInfo &ti) noexcept
std::shared_ptr< Analyzer::Expr > translateWidthBucket(const RexFunctionOperator *) const
std::shared_ptr< Analyzer::Expr > translateInOper(const RexOperator *) const
uint64_t exp_to_scale(const unsigned exp)
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
std::vector< ExpressionPtr > ExpressionPtrVector
std::shared_ptr< Analyzer::Expr > translateCase(const RexCase *) const
std::shared_ptr< Analyzer::Expr > translateFunctionWithGeoArg(const RexFunctionOperator *) const
bool any_of(std::vector< Analyzer::Expr * > const &target_exprs)
std::shared_ptr< const query_state::QueryState > query_state_
const std::string & getName() const
std::shared_ptr< Analyzer::Expr > translateCurrentDate() const
std::string get_datetimeplus_rewrite_funcname(const SQLOps &op)
void validate_datetime_datepart_argument(const std::shared_ptr< Analyzer::Constant > literal_expr)
size_t g_watchdog_in_clause_max_num_elem_bitmap
std::shared_ptr< Analyzer::Expr > translateCardinality(const RexFunctionOperator *) const
const std::vector< TargetMetaInfo > & getOutputMetainfo() const
std::shared_ptr< Analyzer::Expr > translateGeoComparison(const RexOperator *) const
std::shared_ptr< Analyzer::Expr > translateDatePlusMinus(const RexOperator *) const
std::shared_ptr< Analyzer::Expr > translateHPTLiteral(const RexFunctionOperator *) const
bool is_distinct(const size_t input_idx, const RelAlgNode *node)
int32_t getIdOfString(const std::string &str) const
std::shared_ptr< Analyzer::Expr > translateDatepart(const RexFunctionOperator *) const
bool can_use_parallel_algorithms(const ResultSet &rows)
std::shared_ptr< Analyzer::Expr > translateBinaryGeoConstructor(const RexFunctionOperator *, SQLTypeInfo &, const bool with_bounds) const
std::shared_ptr< Analyzer::Expr > rewrite_to_date_trunc(const Analyzer::FunctionOper *dt_plus)
SQLTypeInfo ext_arg_type_to_type_info(const ExtArgumentType ext_arg_type)
DateaddField to_dateadd_field(const std::string &field)
std::shared_ptr< Analyzer::Expr > fold_expr(const Analyzer::Expr *expr)
void set_precision(int d)
std::shared_ptr< Analyzer::Expr > translateGeoBoundingBoxIntersectOper(const RexOperator *) const
void fill_integer_in_vals(std::vector< int64_t > &in_vals, std::atomic< size_t > &total_in_vals_count, const ResultSet *values_rowset, const std::pair< int64_t, int64_t > values_rowset_slice)
std::shared_ptr< Analyzer::Expr > translateKeyForString(const RexFunctionOperator *) const
static std::shared_ptr< Analyzer::Expr > translateAggregateRex(const RexAgg *rex, const std::vector< std::shared_ptr< Analyzer::Expr >> &scalar_sources)
std::shared_ptr< Analyzer::Expr > translateWindowFunction(const RexWindowFunctionOperator *) const
const std::shared_ptr< Analyzer::Expr > generate() const
std::shared_ptr< Analyzer::Expr > translateScalarSubquery(const RexSubQuery *) const
boost::variant< int64_t, double, float, NullableString > ScalarTargetValue
std::shared_ptr< Analyzer::Expr > translateLength(const RexFunctionOperator *) const
std::shared_ptr< Analyzer::Expr > translateExtract(const RexFunctionOperator *) const
ExtractField determineTimeUnit(const SQLTypes &window_frame_bound_type, const Analyzer::Constant *const_expr)
HOST DEVICE void set_type(SQLTypes t)