OmniSciDB  dfae7c3b14
anonymous_namespace{RelAlgTranslator.cpp} Namespace Reference

Functions

SQLTypeInfo build_type_info (const SQLTypes sql_type, const int scale, const int precision)
 
std::pair< std::shared_ptr< Analyzer::Expr >, SQLQualifierget_quantified_rhs (const RexScalar *rex_scalar, const RelAlgTranslator &translator)
 
std::pair< Datum, bool > datum_from_scalar_tv (const ScalarTargetValue *scalar_tv, const SQLTypeInfo &ti) noexcept
 
bool is_agg_supported_for_type (const SQLAgg &agg_kind, const SQLTypeInfo &arg_ti)
 
std::shared_ptr< Analyzer::Exprget_in_values_expr (std::shared_ptr< Analyzer::Expr > arg, const ResultSet &val_set)
 
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)
 
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)
 
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 std::vector< LeafHostInfo > &leaf_hosts, const DictRef source_dict_ref, const DictRef dest_dict_ref, const int32_t dest_generation, const int64_t needle_null_val)
 
void validate_datetime_datepart_argument (const std::shared_ptr< Analyzer::Constant > literal_expr)
 
std::shared_ptr< Analyzer::ConstantmakeNumericConstant (const SQLTypeInfo &ti, const long val)
 
std::string get_datetimeplus_rewrite_funcname (const SQLOps &op)
 
std::vector< Analyzer::OrderEntrytranslate_collation (const std::vector< SortField > &sort_fields)
 
bool supported_lower_bound (const RexWindowFunctionOperator::RexWindowBound &window_bound)
 
bool supported_upper_bound (const RexWindowFunctionOperator *rex_window_function)
 

Variables

const size_t g_max_integer_set_size {1 << 25}
 

Function Documentation

◆ build_type_info()

SQLTypeInfo anonymous_namespace{RelAlgTranslator.cpp}::build_type_info ( const SQLTypes  sql_type,
const int  scale,
const int  precision 
)

Definition at line 44 of file RelAlgTranslator.cpp.

References SQLTypeInfo::is_decimal(), SQLTypeInfo::set_precision(), and SQLTypeInfo::set_scale().

Referenced by RelAlgTranslator::translateLiteral().

46  {
47  SQLTypeInfo ti(sql_type, 0, 0, true);
48  if (ti.is_decimal()) {
49  ti.set_scale(scale);
50  ti.set_precision(precision);
51  }
52  return ti;
53 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ datum_from_scalar_tv()

std::pair<Datum, bool> anonymous_namespace{RelAlgTranslator.cpp}::datum_from_scalar_tv ( const ScalarTargetValue scalar_tv,
const SQLTypeInfo ti 
)
noexcept

Definition at line 78 of file RelAlgTranslator.cpp.

References CHECK, inline_fp_null_val(), inline_int_null_val(), kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kINT, kNUMERIC, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, and kVARCHAR.

Referenced by get_in_values_expr(), RelAlgTranslator::translateInOper(), and RelAlgTranslator::translateScalarSubquery().

79  {
80  Datum d{0};
81  bool is_null_const{false};
82  switch (ti.get_type()) {
83  case kBOOLEAN: {
84  const auto ival = boost::get<int64_t>(scalar_tv);
85  CHECK(ival);
86  if (*ival == inline_int_null_val(ti)) {
87  is_null_const = true;
88  } else {
89  d.boolval = *ival;
90  }
91  break;
92  }
93  case kTINYINT: {
94  const auto ival = boost::get<int64_t>(scalar_tv);
95  CHECK(ival);
96  if (*ival == inline_int_null_val(ti)) {
97  is_null_const = true;
98  } else {
99  d.tinyintval = *ival;
100  }
101  break;
102  }
103  case kSMALLINT: {
104  const auto ival = boost::get<int64_t>(scalar_tv);
105  CHECK(ival);
106  if (*ival == inline_int_null_val(ti)) {
107  is_null_const = true;
108  } else {
109  d.smallintval = *ival;
110  }
111  break;
112  }
113  case kINT: {
114  const auto ival = boost::get<int64_t>(scalar_tv);
115  CHECK(ival);
116  if (*ival == inline_int_null_val(ti)) {
117  is_null_const = true;
118  } else {
119  d.intval = *ival;
120  }
121  break;
122  }
123  case kDECIMAL:
124  case kNUMERIC:
125  case kBIGINT:
126  case kDATE:
127  case kTIME:
128  case kTIMESTAMP: {
129  const auto ival = boost::get<int64_t>(scalar_tv);
130  CHECK(ival);
131  if (*ival == inline_int_null_val(ti)) {
132  is_null_const = true;
133  } else {
134  d.bigintval = *ival;
135  }
136  break;
137  }
138  case kDOUBLE: {
139  const auto dval = boost::get<double>(scalar_tv);
140  CHECK(dval);
141  if (*dval == inline_fp_null_val(ti)) {
142  is_null_const = true;
143  } else {
144  d.doubleval = *dval;
145  }
146  break;
147  }
148  case kFLOAT: {
149  const auto fval = boost::get<float>(scalar_tv);
150  CHECK(fval);
151  if (*fval == inline_fp_null_val(ti)) {
152  is_null_const = true;
153  } else {
154  d.floatval = *fval;
155  }
156  break;
157  }
158  case kTEXT:
159  case kVARCHAR:
160  case kCHAR: {
161  auto nullable_sptr = boost::get<NullableString>(scalar_tv);
162  CHECK(nullable_sptr);
163  if (boost::get<void*>(nullable_sptr)) {
164  is_null_const = true;
165  } else {
166  auto sptr = boost::get<std::string>(nullable_sptr);
167  d.stringval = new std::string(*sptr);
168  }
169  break;
170  }
171  default:
172  CHECK(false) << "Unhandled type: " << ti.get_type_name();
173  }
174  return {d, is_null_const};
175 }
Definition: sqltypes.h:51
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:54
Definition: sqltypes.h:55
std::string get_type_name() const
Definition: sqltypes.h:362
Definition: sqltypes.h:43
#define CHECK(condition)
Definition: Logger.h:197
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:259
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fill_dictionary_encoded_in_vals() [1/2]

void anonymous_namespace{RelAlgTranslator.cpp}::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 
)

Definition at line 607 of file RelAlgTranslator.cpp.

References CHECK, g_enable_watchdog, g_max_integer_set_size, StringDictionaryProxy::getIdOfString(), StringDictionaryProxy::getString(), StringDictionary::INVALID_STR_ID, and UNLIKELY.

614  {
615  CHECK(in_vals.empty());
616  bool dicts_are_equal = source_dict == dest_dict;
617  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
618  ++index) {
619  const auto row = values_rowset->getOneColRow(index);
620  if (UNLIKELY(!row.valid)) {
621  continue;
622  }
623  if (dicts_are_equal) {
624  in_vals.push_back(row.value);
625  } else {
626  const int string_id =
627  row.value == needle_null_val
628  ? needle_null_val
629  : dest_dict->getIdOfString(source_dict->getString(row.value));
630  if (string_id != StringDictionary::INVALID_STR_ID) {
631  in_vals.push_back(string_id);
632  }
633  }
634  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
635  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
636  throw std::runtime_error(
637  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
638  }
639  }
640 }
int32_t getIdOfString(const std::string &str) const
bool g_enable_watchdog
Definition: Execute.cpp:74
static constexpr int32_t INVALID_STR_ID
std::string getString(int32_t string_id) const
#define UNLIKELY(x)
Definition: likely.h:25
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:

◆ fill_dictionary_encoded_in_vals() [2/2]

void anonymous_namespace{RelAlgTranslator.cpp}::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 std::vector< LeafHostInfo > &  leaf_hosts,
const DictRef  source_dict_ref,
const DictRef  dest_dict_ref,
const int32_t  dest_generation,
const int64_t  needle_null_val 
)

Definition at line 668 of file RelAlgTranslator.cpp.

References CHECK, CHECK_EQ, g_enable_watchdog, g_max_integer_set_size, StringDictionary::INVALID_STR_ID, translate_string_ids(), and UNLIKELY.

Referenced by RelAlgTranslator::getInIntegerSetExpr().

677  {
678  CHECK(in_vals.empty());
679  std::vector<int32_t> source_ids;
680  source_ids.reserve(values_rowset->entryCount());
681  bool has_nulls = false;
682  if (source_dict_ref == dest_dict_ref) {
683  in_vals.reserve(values_rowset_slice.second - values_rowset_slice.first +
684  1); // Add 1 to cover interval
685  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
686  ++index) {
687  const auto row = values_rowset->getOneColRow(index);
688  if (!row.valid) {
689  continue;
690  }
691  if (row.value != needle_null_val) {
692  in_vals.push_back(row.value);
693  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
694  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
695  throw std::runtime_error(
696  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
697  }
698  } else {
699  has_nulls = true;
700  }
701  }
702  if (has_nulls) {
703  in_vals.push_back(
704  needle_null_val); // we've deduped null values as an optimization, although
705  // this is not required by consumer
706  }
707  return;
708  }
709  // Code path below is for when dictionaries are not shared
710  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
711  ++index) {
712  const auto row = values_rowset->getOneColRow(index);
713  if (row.valid) {
714  if (row.value != needle_null_val) {
715  source_ids.push_back(row.value);
716  } else {
717  has_nulls = true;
718  }
719  }
720  }
721  std::vector<int32_t> dest_ids;
722  translate_string_ids(dest_ids,
723  leaf_hosts.front(),
724  dest_dict_ref,
725  source_ids,
726  source_dict_ref,
727  dest_generation);
728  CHECK_EQ(dest_ids.size(), source_ids.size());
729  in_vals.reserve(dest_ids.size() + (has_nulls ? 1 : 0));
730  if (has_nulls) {
731  in_vals.push_back(needle_null_val);
732  }
733  for (const int32_t dest_id : dest_ids) {
734  if (dest_id != StringDictionary::INVALID_STR_ID) {
735  in_vals.push_back(dest_id);
736  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
737  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
738  throw std::runtime_error(
739  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
740  }
741  }
742  }
743 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
bool g_enable_watchdog
Definition: Execute.cpp:74
static constexpr int32_t INVALID_STR_ID
void translate_string_ids(std::vector< int32_t > &dest_ids, const LeafHostInfo &dict_server_host, const DictRef dest_dict_ref, const std::vector< int32_t > &source_ids, const DictRef source_dict_ref, const int32_t dest_generation)
#define UNLIKELY(x)
Definition: likely.h:25
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fill_integer_in_vals()

void anonymous_namespace{RelAlgTranslator.cpp}::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 
)

Definition at line 642 of file RelAlgTranslator.cpp.

References CHECK, g_enable_watchdog, g_max_integer_set_size, and UNLIKELY.

Referenced by RelAlgTranslator::getInIntegerSetExpr().

645  {
646  CHECK(in_vals.empty());
647  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
648  ++index) {
649  const auto row = values_rowset->getOneColRow(index);
650  if (row.valid) {
651  in_vals.push_back(row.value);
652  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
653  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
654  throw std::runtime_error(
655  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
656  }
657  }
658  }
659 }
bool g_enable_watchdog
Definition: Execute.cpp:74
#define UNLIKELY(x)
Definition: likely.h:25
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the caller graph for this function:

◆ get_datetimeplus_rewrite_funcname()

std::string anonymous_namespace{RelAlgTranslator.cpp}::get_datetimeplus_rewrite_funcname ( const SQLOps op)

Definition at line 1062 of file RelAlgTranslator.cpp.

References CHECK, and kPLUS.

Referenced by RelAlgTranslator::translateDatePlusMinus().

1062  {
1063  CHECK(op == kPLUS);
1064  return "DATETIME_PLUS"s;
1065 }
Definition: sqldefs.h:41
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the caller graph for this function:

◆ get_in_values_expr()

std::shared_ptr<Analyzer::Expr> anonymous_namespace{RelAlgTranslator.cpp}::get_in_values_expr ( std::shared_ptr< Analyzer::Expr arg,
const ResultSet val_set 
)

Definition at line 463 of file RelAlgTranslator.cpp.

References can_use_parallel_algorithms(), cpu_threads(), datum_from_scalar_tv(), parse_ast::end, g_enable_watchdog, kCAST, and kENCODING_NONE.

Referenced by RelAlgTranslator::translateInOper().

464  {
465  if (!can_use_parallel_algorithms(val_set)) {
466  return nullptr;
467  }
468  if (val_set.rowCount() > 5000000 && g_enable_watchdog) {
469  throw std::runtime_error(
470  "Unable to handle 'expr IN (subquery)', subquery returned 5M+ rows.");
471  }
472  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
473  const size_t fetcher_count = cpu_threads();
474  std::vector<std::list<std::shared_ptr<Analyzer::Expr>>> expr_set(
475  fetcher_count, std::list<std::shared_ptr<Analyzer::Expr>>());
476  std::vector<std::future<void>> fetcher_threads;
477  const auto& ti = arg->get_type_info();
478  const auto entry_count = val_set.entryCount();
479  for (size_t i = 0,
480  start_entry = 0,
481  stride = (entry_count + fetcher_count - 1) / fetcher_count;
482  i < fetcher_count && start_entry < entry_count;
483  ++i, start_entry += stride) {
484  const auto end_entry = std::min(start_entry + stride, entry_count);
485  fetcher_threads.push_back(std::async(
486  std::launch::async,
487  [&](std::list<std::shared_ptr<Analyzer::Expr>>& in_vals,
488  const size_t start,
489  const size_t end) {
490  for (auto index = start; index < end; ++index) {
491  auto row = val_set.getRowAt(index);
492  if (row.empty()) {
493  continue;
494  }
495  auto scalar_tv = boost::get<ScalarTargetValue>(&row[0]);
496  Datum d{0};
497  bool is_null_const{false};
498  std::tie(d, is_null_const) = datum_from_scalar_tv(scalar_tv, ti);
499  if (ti.is_string() && ti.get_compression() != kENCODING_NONE) {
500  auto ti_none_encoded = ti;
501  ti_none_encoded.set_compression(kENCODING_NONE);
502  auto none_encoded_string =
503  makeExpr<Analyzer::Constant>(ti, is_null_const, d);
504  auto dict_encoded_string = std::make_shared<Analyzer::UOper>(
505  ti, false, kCAST, none_encoded_string);
506  in_vals.push_back(dict_encoded_string);
507  } else {
508  in_vals.push_back(makeExpr<Analyzer::Constant>(ti, is_null_const, d));
509  }
510  }
511  },
512  std::ref(expr_set[i]),
513  start_entry,
514  end_entry));
515  }
516  for (auto& child : fetcher_threads) {
517  child.get();
518  }
519 
520  val_set.moveToBegin();
521  for (auto& exprs : expr_set) {
522  value_exprs.splice(value_exprs.end(), exprs);
523  }
524  return makeExpr<Analyzer::InValues>(arg, value_exprs);
525 }
bool g_enable_watchdog
Definition: Execute.cpp:74
Definition: sqldefs.h:49
bool can_use_parallel_algorithms(const ResultSet &rows)
Definition: ResultSet.cpp:1003
std::pair< Datum, bool > datum_from_scalar_tv(const ScalarTargetValue *scalar_tv, const SQLTypeInfo &ti) noexcept
int cpu_threads()
Definition: thread_count.h:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_quantified_rhs()

std::pair<std::shared_ptr<Analyzer::Expr>, SQLQualifier> anonymous_namespace{RelAlgTranslator.cpp}::get_quantified_rhs ( const RexScalar rex_scalar,
const RelAlgTranslator translator 
)

Definition at line 55 of file RelAlgTranslator.cpp.

References CHECK_EQ, RexFunctionOperator::getName(), kALL, kANY, kCAST, kONE, and RelAlgTranslator::translateScalarRex().

Referenced by RelAlgTranslator::translateOper().

57  {
58  std::shared_ptr<Analyzer::Expr> rhs;
59  SQLQualifier sql_qual{kONE};
60  const auto rex_operator = dynamic_cast<const RexOperator*>(rex_scalar);
61  if (!rex_operator) {
62  return std::make_pair(rhs, sql_qual);
63  }
64  const auto rex_function = dynamic_cast<const RexFunctionOperator*>(rex_operator);
65  const auto qual_str = rex_function ? rex_function->getName() : "";
66  if (qual_str == "PG_ANY"sv || qual_str == "PG_ALL"sv) {
67  CHECK_EQ(size_t(1), rex_function->size());
68  rhs = translator.translateScalarRex(rex_function->getOperand(0));
69  sql_qual = (qual_str == "PG_ANY"sv) ? kANY : kALL;
70  }
71  if (!rhs && rex_operator->getOperator() == kCAST) {
72  CHECK_EQ(size_t(1), rex_operator->size());
73  std::tie(rhs, sql_qual) = get_quantified_rhs(rex_operator->getOperand(0), translator);
74  }
75  return std::make_pair(rhs, sql_qual);
76 }
Definition: sqldefs.h:69
#define CHECK_EQ(x, y)
Definition: Logger.h:205
SQLQualifier
Definition: sqldefs.h:69
Definition: sqldefs.h:49
std::shared_ptr< Analyzer::Expr > translateScalarRex(const RexScalar *rex) const
Definition: sqldefs.h:69
std::pair< std::shared_ptr< Analyzer::Expr >, SQLQualifier > get_quantified_rhs(const RexScalar *rex_scalar, const RelAlgTranslator &translator)
Definition: sqldefs.h:69
const std::string & getName() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_agg_supported_for_type()

bool anonymous_namespace{RelAlgTranslator.cpp}::is_agg_supported_for_type ( const SQLAgg agg_kind,
const SQLTypeInfo arg_ti 
)

Definition at line 215 of file RelAlgTranslator.cpp.

References SQLTypeInfo::is_boolean(), SQLTypeInfo::is_number(), SQLTypeInfo::is_time(), kAVG, kMAX, kMIN, and kSUM.

Referenced by RelAlgTranslator::translateAggregateRex().

215  {
216  if ((agg_kind == kMIN || agg_kind == kMAX || agg_kind == kSUM || agg_kind == kAVG) &&
217  !(arg_ti.is_number() || arg_ti.is_boolean() || arg_ti.is_time())) {
218  return false;
219  }
220 
221  return true;
222 }
bool is_time() const
Definition: sqltypes.h:423
bool is_boolean() const
Definition: sqltypes.h:424
Definition: sqldefs.h:73
Definition: sqldefs.h:75
Definition: sqldefs.h:74
Definition: sqldefs.h:72
bool is_number() const
Definition: sqltypes.h:422
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeNumericConstant()

std::shared_ptr<Analyzer::Constant> anonymous_namespace{RelAlgTranslator.cpp}::makeNumericConstant ( const SQLTypeInfo ti,
const long  val 
)

Definition at line 994 of file RelAlgTranslator.cpp.

References CHECK, exp_to_scale(), SQLTypeInfo::get_scale(), SQLTypeInfo::get_type(), SQLTypeInfo::is_number(), kBIGINT, kDECIMAL, kDOUBLE, kFLOAT, kINT, kNUMERIC, kSMALLINT, and kTINYINT.

Referenced by RelAlgTranslator::translateAbs(), RelAlgTranslator::translateCardinality(), RelAlgTranslator::translateDatePlusMinus(), and RelAlgTranslator::translateSign().

995  {
996  CHECK(ti.is_number());
997  Datum datum{0};
998  switch (ti.get_type()) {
999  case kTINYINT: {
1000  datum.tinyintval = val;
1001  break;
1002  }
1003  case kSMALLINT: {
1004  datum.smallintval = val;
1005  break;
1006  }
1007  case kINT: {
1008  datum.intval = val;
1009  break;
1010  }
1011  case kBIGINT: {
1012  datum.bigintval = val;
1013  break;
1014  }
1015  case kDECIMAL:
1016  case kNUMERIC: {
1017  datum.bigintval = val * exp_to_scale(ti.get_scale());
1018  break;
1019  }
1020  case kFLOAT: {
1021  datum.floatval = val;
1022  break;
1023  }
1024  case kDOUBLE: {
1025  datum.doubleval = val;
1026  break;
1027  }
1028  default:
1029  CHECK(false);
1030  }
1031  return makeExpr<Analyzer::Constant>(ti, false, datum);
1032 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:264
#define CHECK(condition)
Definition: Logger.h:197
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:259
uint64_t exp_to_scale(const unsigned exp)
Definition: sqltypes.h:47
bool is_number() const
Definition: sqltypes.h:422
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ supported_lower_bound()

bool anonymous_namespace{RelAlgTranslator.cpp}::supported_lower_bound ( const RexWindowFunctionOperator::RexWindowBound window_bound)

◆ supported_upper_bound()

bool anonymous_namespace{RelAlgTranslator.cpp}::supported_upper_bound ( const RexWindowFunctionOperator rex_window_function)

Definition at line 1641 of file RelAlgTranslator.cpp.

References CUME_DIST, DENSE_RANK, RexWindowFunctionOperator::getKind(), RexWindowFunctionOperator::getOrderKeys(), RexWindowFunctionOperator::getUpperBound(), RANK, ROW_NUMBER, and RexWindowFunctionOperator::RexWindowBound::unbounded.

Referenced by RelAlgTranslator::translateWindowFunction().

1641  {
1642  const auto& window_bound = rex_window_function->getUpperBound();
1643  const bool to_current_row = !window_bound.unbounded && !window_bound.preceding &&
1644  !window_bound.following && window_bound.is_current_row &&
1645  !window_bound.offset && window_bound.order_key == 1;
1646  switch (rex_window_function->getKind()) {
1651  return to_current_row;
1652  }
1653  default: {
1654  return rex_window_function->getOrderKeys().empty()
1655  ? (window_bound.unbounded && !window_bound.preceding &&
1656  window_bound.following && !window_bound.is_current_row &&
1657  !window_bound.offset && window_bound.order_key == 2)
1658  : to_current_row;
1659  }
1660  }
1661 }
SqlWindowFunctionKind getKind() const
const ConstRexScalarPtrVector & getOrderKeys() const
const RexWindowBound & getUpperBound() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ translate_collation()

std::vector<Analyzer::OrderEntry> anonymous_namespace{RelAlgTranslator.cpp}::translate_collation ( const std::vector< SortField > &  sort_fields)

Definition at line 1622 of file RelAlgTranslator.cpp.

References Descending, and First.

Referenced by RelAlgTranslator::translateWindowFunction().

1623  {
1624  std::vector<Analyzer::OrderEntry> collation;
1625  for (size_t i = 0; i < sort_fields.size(); ++i) {
1626  const auto& sort_field = sort_fields[i];
1627  collation.emplace_back(i,
1628  sort_field.getSortDir() == SortDirection::Descending,
1629  sort_field.getNullsPosition() == NullSortedPosition::First);
1630  }
1631  return collation;
1632 }
+ Here is the caller graph for this function:

◆ validate_datetime_datepart_argument()

void anonymous_namespace{RelAlgTranslator.cpp}::validate_datetime_datepart_argument ( const std::shared_ptr< Analyzer::Constant literal_expr)
inline

Definition at line 968 of file RelAlgTranslator.cpp.

Referenced by RelAlgTranslator::translateDateadd(), RelAlgTranslator::translateDatediff(), RelAlgTranslator::translateDatepart(), and RelAlgTranslator::translateExtract().

969  {
970  if (!literal_expr || literal_expr->get_is_null()) {
971  throw std::runtime_error("The 'DatePart' argument must be a not 'null' literal.");
972  }
973 }
+ Here is the caller graph for this function:

Variable Documentation

◆ g_max_integer_set_size

const size_t anonymous_namespace{RelAlgTranslator.cpp}::g_max_integer_set_size {1 << 25}

Definition at line 605 of file RelAlgTranslator.cpp.

Referenced by fill_dictionary_encoded_in_vals(), and fill_integer_in_vals().