OmniSciDB  fe05a0c208
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 >
, SQLQualifier
get_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::Constant
makeNumericConstant (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

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

Definition at line 43 of file RelAlgTranslator.cpp.

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

Referenced by RelAlgTranslator::translateLiteral().

45  {
46  SQLTypeInfo ti(sql_type, 0, 0, true);
47  if (ti.is_decimal()) {
48  ti.set_scale(scale);
49  ti.set_precision(precision);
50  }
51  return ti;
52 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 77 of file RelAlgTranslator.cpp.

References CHECK, test_fsi::d, 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().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 621 of file RelAlgTranslator.cpp.

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

Referenced by RelAlgTranslator::getInIntegerSetExpr().

628  {
629  CHECK(in_vals.empty());
630  bool dicts_are_equal = source_dict == dest_dict;
631  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
632  ++index) {
633  const auto row = values_rowset->getOneColRow(index);
634  if (UNLIKELY(!row.valid)) {
635  continue;
636  }
637  if (dicts_are_equal) {
638  in_vals.push_back(row.value);
639  } else {
640  const int string_id =
641  row.value == needle_null_val
642  ? needle_null_val
643  : dest_dict->getIdOfString(source_dict->getString(row.value));
644  if (string_id != StringDictionary::INVALID_STR_ID) {
645  in_vals.push_back(string_id);
646  }
647  }
648  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
649  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
650  throw std::runtime_error(
651  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
652  }
653  }
654 }
bool g_enable_watchdog
std::string getString(int32_t string_id) const
static constexpr int32_t INVALID_STR_ID
#define UNLIKELY(x)
Definition: likely.h:25
#define CHECK(condition)
Definition: Logger.h:203
int32_t getIdOfString(const std::string &str) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 682 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.

691  {
692  CHECK(in_vals.empty());
693  std::vector<int32_t> source_ids;
694  source_ids.reserve(values_rowset->entryCount());
695  bool has_nulls = false;
696  if (source_dict_ref == dest_dict_ref) {
697  in_vals.reserve(values_rowset_slice.second - values_rowset_slice.first +
698  1); // Add 1 to cover interval
699  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
700  ++index) {
701  const auto row = values_rowset->getOneColRow(index);
702  if (!row.valid) {
703  continue;
704  }
705  if (row.value != needle_null_val) {
706  in_vals.push_back(row.value);
707  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
708  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
709  throw std::runtime_error(
710  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
711  }
712  } else {
713  has_nulls = true;
714  }
715  }
716  if (has_nulls) {
717  in_vals.push_back(
718  needle_null_val); // we've deduped null values as an optimization, although
719  // this is not required by consumer
720  }
721  return;
722  }
723  // Code path below is for when dictionaries are not shared
724  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
725  ++index) {
726  const auto row = values_rowset->getOneColRow(index);
727  if (row.valid) {
728  if (row.value != needle_null_val) {
729  source_ids.push_back(row.value);
730  } else {
731  has_nulls = true;
732  }
733  }
734  }
735  std::vector<int32_t> dest_ids;
736  translate_string_ids(dest_ids,
737  leaf_hosts.front(),
738  dest_dict_ref,
739  source_ids,
740  source_dict_ref,
741  dest_generation);
742  CHECK_EQ(dest_ids.size(), source_ids.size());
743  in_vals.reserve(dest_ids.size() + (has_nulls ? 1 : 0));
744  if (has_nulls) {
745  in_vals.push_back(needle_null_val);
746  }
747  for (const int32_t dest_id : dest_ids) {
748  if (dest_id != StringDictionary::INVALID_STR_ID) {
749  in_vals.push_back(dest_id);
750  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
751  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
752  throw std::runtime_error(
753  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
754  }
755  }
756  }
757 }
#define CHECK_EQ(x, y)
Definition: Logger.h:211
bool g_enable_watchdog
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:203

+ Here is the call graph for this function:

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 656 of file RelAlgTranslator.cpp.

References CHECK, g_enable_watchdog, g_max_integer_set_size, and UNLIKELY.

Referenced by RelAlgTranslator::getInIntegerSetExpr().

659  {
660  CHECK(in_vals.empty());
661  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
662  ++index) {
663  const auto row = values_rowset->getOneColRow(index);
664  if (row.valid) {
665  in_vals.push_back(row.value);
666  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
667  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
668  throw std::runtime_error(
669  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
670  }
671  }
672  }
673 }
bool g_enable_watchdog
#define UNLIKELY(x)
Definition: likely.h:25
#define CHECK(condition)
Definition: Logger.h:203

+ Here is the caller graph for this function:

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

Definition at line 1076 of file RelAlgTranslator.cpp.

References CHECK, and kPLUS.

Referenced by RelAlgTranslator::translateDatePlusMinus().

1076  {
1077  CHECK(op == kPLUS);
1078  return "DATETIME_PLUS"s;
1079 }
Definition: sqldefs.h:41
#define CHECK(condition)
Definition: Logger.h:203

+ Here is the caller graph for this function:

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 476 of file RelAlgTranslator.cpp.

References result_set::can_use_parallel_algorithms(), cpu_threads(), test_fsi::d, datum_from_scalar_tv(), g_enable_watchdog, i, kCAST, and kENCODING_NONE.

Referenced by RelAlgTranslator::translateInOper().

477  {
479  return nullptr;
480  }
481  if (val_set.rowCount() > 5000000 && g_enable_watchdog) {
482  throw std::runtime_error(
483  "Unable to handle 'expr IN (subquery)', subquery returned 5M+ rows.");
484  }
485  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
486  const size_t fetcher_count = cpu_threads();
487  std::vector<std::list<std::shared_ptr<Analyzer::Expr>>> expr_set(
488  fetcher_count, std::list<std::shared_ptr<Analyzer::Expr>>());
489  std::vector<std::future<void>> fetcher_threads;
490  const auto& ti = arg->get_type_info();
491  const auto entry_count = val_set.entryCount();
492  for (size_t i = 0,
493  start_entry = 0,
494  stride = (entry_count + fetcher_count - 1) / fetcher_count;
495  i < fetcher_count && start_entry < entry_count;
496  ++i, start_entry += stride) {
497  const auto end_entry = std::min(start_entry + stride, entry_count);
498  fetcher_threads.push_back(std::async(
499  std::launch::async,
500  [&](std::list<std::shared_ptr<Analyzer::Expr>>& in_vals,
501  const size_t start,
502  const size_t end) {
503  for (auto index = start; index < end; ++index) {
504  auto row = val_set.getRowAt(index);
505  if (row.empty()) {
506  continue;
507  }
508  auto scalar_tv = boost::get<ScalarTargetValue>(&row[0]);
509  Datum d{0};
510  bool is_null_const{false};
511  std::tie(d, is_null_const) = datum_from_scalar_tv(scalar_tv, ti);
512  if (ti.is_string() && ti.get_compression() != kENCODING_NONE) {
513  auto ti_none_encoded = ti;
514  ti_none_encoded.set_compression(kENCODING_NONE);
515  auto none_encoded_string =
516  makeExpr<Analyzer::Constant>(ti, is_null_const, d);
517  auto dict_encoded_string = std::make_shared<Analyzer::UOper>(
518  ti, false, kCAST, none_encoded_string);
519  in_vals.push_back(dict_encoded_string);
520  } else {
521  in_vals.push_back(makeExpr<Analyzer::Constant>(ti, is_null_const, d));
522  }
523  }
524  },
525  std::ref(expr_set[i]),
526  start_entry,
527  end_entry));
528  }
529  for (auto& child : fetcher_threads) {
530  child.get();
531  }
532 
533  val_set.moveToBegin();
534  for (auto& exprs : expr_set) {
535  value_exprs.splice(value_exprs.end(), exprs);
536  }
537  return makeExpr<Analyzer::InValues>(arg, value_exprs);
538 }
bool g_enable_watchdog
tuple d
Definition: test_fsi.py:9
Definition: sqldefs.h:49
std::pair< Datum, bool > datum_from_scalar_tv(const ScalarTargetValue *scalar_tv, const SQLTypeInfo &ti) noexcept
int cpu_threads()
Definition: thread_count.h:24
bool can_use_parallel_algorithms(const ResultSet &rows)
Definition: ResultSet.cpp:1118

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 54 of file RelAlgTranslator.cpp.

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

Referenced by RelAlgTranslator::translateOper().

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

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

Definition at line 214 of file RelAlgTranslator.cpp.

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

Referenced by RelAlgTranslator::translateAggregateRex().

214  {
215  if ((agg_kind == kMIN || agg_kind == kMAX || agg_kind == kSUM || agg_kind == kAVG) &&
216  !(arg_ti.is_number() || arg_ti.is_boolean() || arg_ti.is_time())) {
217  return false;
218  }
219 
220  return true;
221 }
bool is_number() const
Definition: sqltypes.h:494
bool is_time() const
Definition: sqltypes.h:495
Definition: sqldefs.h:73
Definition: sqldefs.h:75
bool is_boolean() const
Definition: sqltypes.h:496
Definition: sqldefs.h:74
Definition: sqldefs.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1008 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().

1009  {
1010  CHECK(ti.is_number());
1011  Datum datum{0};
1012  switch (ti.get_type()) {
1013  case kTINYINT: {
1014  datum.tinyintval = val;
1015  break;
1016  }
1017  case kSMALLINT: {
1018  datum.smallintval = val;
1019  break;
1020  }
1021  case kINT: {
1022  datum.intval = val;
1023  break;
1024  }
1025  case kBIGINT: {
1026  datum.bigintval = val;
1027  break;
1028  }
1029  case kDECIMAL:
1030  case kNUMERIC: {
1031  datum.bigintval = val * exp_to_scale(ti.get_scale());
1032  break;
1033  }
1034  case kFLOAT: {
1035  datum.floatval = val;
1036  break;
1037  }
1038  case kDOUBLE: {
1039  datum.doubleval = val;
1040  break;
1041  }
1042  default:
1043  CHECK(false);
1044  }
1045  return makeExpr<Analyzer::Constant>(ti, false, datum);
1046 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:319
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:314
bool is_number() const
Definition: sqltypes.h:494
#define CHECK(condition)
Definition: Logger.h:203
uint64_t exp_to_scale(const unsigned exp)
Definition: sqltypes.h:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1690 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().

1690  {
1691  const auto& window_bound = rex_window_function->getUpperBound();
1692  const bool to_current_row = !window_bound.unbounded && !window_bound.preceding &&
1693  !window_bound.following && window_bound.is_current_row &&
1694  !window_bound.offset && window_bound.order_key == 1;
1695  switch (rex_window_function->getKind()) {
1700  return to_current_row;
1701  }
1702  default: {
1703  return rex_window_function->getOrderKeys().empty()
1704  ? (window_bound.unbounded && !window_bound.preceding &&
1705  window_bound.following && !window_bound.is_current_row &&
1706  !window_bound.offset && window_bound.order_key == 2)
1707  : to_current_row;
1708  }
1709  }
1710 }
SqlWindowFunctionKind getKind() const
const RexWindowBound & getUpperBound() const
const ConstRexScalarPtrVector & getOrderKeys() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1671 of file RelAlgTranslator.cpp.

References Descending, First, and i.

Referenced by RelAlgTranslator::translateWindowFunction().

1672  {
1673  std::vector<Analyzer::OrderEntry> collation;
1674  for (size_t i = 0; i < sort_fields.size(); ++i) {
1675  const auto& sort_field = sort_fields[i];
1676  collation.emplace_back(i,
1677  sort_field.getSortDir() == SortDirection::Descending,
1678  sort_field.getNullsPosition() == NullSortedPosition::First);
1679  }
1680  return collation;
1681 }

+ Here is the caller graph for this function:

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

Definition at line 982 of file RelAlgTranslator.cpp.

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

983  {
984  if (!literal_expr || literal_expr->get_is_null()) {
985  throw std::runtime_error("The 'DatePart' argument must be a not 'null' literal.");
986  }
987 }

+ Here is the caller graph for this function:

Variable Documentation

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

Definition at line 619 of file RelAlgTranslator.cpp.

Referenced by fill_dictionary_encoded_in_vals(), and fill_integer_in_vals().