OmniSciDB  29e35f4d58
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)
 
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 SQLTypeInfoCore< TYPE_FACET_PACK >::is_decimal(), SQLTypeInfoCore< TYPE_FACET_PACK >::set_precision(), and SQLTypeInfoCore< TYPE_FACET_PACK >::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, 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 kTINYINT: {
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.tinyintval = *ival;
90  }
91  break;
92  }
93  case kSMALLINT: {
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.smallintval = *ival;
100  }
101  break;
102  }
103  case kINT: {
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.intval = *ival;
110  }
111  break;
112  }
113  case kDECIMAL:
114  case kNUMERIC:
115  case kBIGINT:
116  case kDATE:
117  case kTIME:
118  case kTIMESTAMP: {
119  const auto ival = boost::get<int64_t>(scalar_tv);
120  CHECK(ival);
121  if (*ival == inline_int_null_val(ti)) {
122  is_null_const = true;
123  } else {
124  d.bigintval = *ival;
125  }
126  break;
127  }
128  case kDOUBLE: {
129  const auto dval = boost::get<double>(scalar_tv);
130  CHECK(dval);
131  if (*dval == inline_fp_null_val(ti)) {
132  is_null_const = true;
133  } else {
134  d.doubleval = *dval;
135  }
136  break;
137  }
138  case kFLOAT: {
139  const auto fval = boost::get<float>(scalar_tv);
140  CHECK(fval);
141  if (*fval == inline_fp_null_val(ti)) {
142  is_null_const = true;
143  } else {
144  d.floatval = *fval;
145  }
146  break;
147  }
148  case kTEXT:
149  case kVARCHAR:
150  case kCHAR: {
151  auto nullable_sptr = boost::get<NullableString>(scalar_tv);
152  CHECK(nullable_sptr);
153  if (boost::get<void*>(nullable_sptr)) {
154  is_null_const = true;
155  } else {
156  auto sptr = boost::get<std::string>(nullable_sptr);
157  d.stringval = new std::string(*sptr);
158  }
159  break;
160  }
161  default:
162  CHECK(false);
163  }
164  return {d, is_null_const};
165 }
Definition: sqltypes.h:52
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:326
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:55
Definition: sqltypes.h:56
Definition: sqltypes.h:44
#define CHECK(condition)
Definition: Logger.h:193
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:48
+ 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 589 of file RelAlgTranslator.cpp.

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

596  {
597  CHECK(in_vals.empty());
598  bool dicts_are_equal = source_dict == dest_dict;
599  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
600  ++index) {
601  const auto row = values_rowset->getOneColRow(index);
602  if (UNLIKELY(!row.valid)) {
603  continue;
604  }
605  if (dicts_are_equal) {
606  in_vals.push_back(row.value);
607  } else {
608  const int string_id =
609  row.value == needle_null_val
610  ? needle_null_val
611  : dest_dict->getIdOfString(source_dict->getString(row.value));
612  if (string_id != StringDictionary::INVALID_STR_ID) {
613  in_vals.push_back(string_id);
614  }
615  }
616  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
617  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
618  throw std::runtime_error(
619  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
620  }
621  }
622 }
int32_t getIdOfString(const std::string &str) const
bool g_enable_watchdog
Definition: Execute.cpp:71
static constexpr int32_t INVALID_STR_ID
std::string getString(int32_t string_id) const
#define UNLIKELY(x)
Definition: likely.h:20
#define CHECK(condition)
Definition: Logger.h:193
+ 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 650 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().

659  {
660  CHECK(in_vals.empty());
661  std::vector<int32_t> source_ids;
662  source_ids.reserve(values_rowset->entryCount());
663  bool has_nulls = false;
664  if (source_dict_ref == dest_dict_ref) {
665  in_vals.reserve(values_rowset_slice.second - values_rowset_slice.first +
666  1); // Add 1 to cover interval
667  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
668  ++index) {
669  const auto row = values_rowset->getOneColRow(index);
670  if (!row.valid) {
671  continue;
672  }
673  if (row.value != needle_null_val) {
674  in_vals.push_back(row.value);
675  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
676  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
677  throw std::runtime_error(
678  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
679  }
680  } else {
681  has_nulls = true;
682  }
683  }
684  if (has_nulls) {
685  in_vals.push_back(
686  needle_null_val); // we've deduped null values as an optimization, although
687  // this is not required by consumer
688  }
689  return;
690  }
691  // Code path below is for when dictionaries are not shared
692  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
693  ++index) {
694  const auto row = values_rowset->getOneColRow(index);
695  if (row.valid) {
696  if (row.value != needle_null_val) {
697  source_ids.push_back(row.value);
698  } else {
699  has_nulls = true;
700  }
701  }
702  }
703  std::vector<int32_t> dest_ids;
704  translate_string_ids(dest_ids,
705  leaf_hosts.front(),
706  dest_dict_ref,
707  source_ids,
708  source_dict_ref,
709  dest_generation);
710  CHECK_EQ(dest_ids.size(), source_ids.size());
711  in_vals.reserve(dest_ids.size() + (has_nulls ? 1 : 0));
712  if (has_nulls) {
713  in_vals.push_back(needle_null_val);
714  }
715  for (const int32_t dest_id : dest_ids) {
716  if (dest_id != StringDictionary::INVALID_STR_ID) {
717  in_vals.push_back(dest_id);
718  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
719  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
720  throw std::runtime_error(
721  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
722  }
723  }
724  }
725 }
#define CHECK_EQ(x, y)
Definition: Logger.h:201
bool g_enable_watchdog
Definition: Execute.cpp:71
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:20
#define CHECK(condition)
Definition: Logger.h:193
+ 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 624 of file RelAlgTranslator.cpp.

References CHECK, g_enable_watchdog, g_max_integer_set_size, and UNLIKELY.

Referenced by RelAlgTranslator::getInIntegerSetExpr().

627  {
628  CHECK(in_vals.empty());
629  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
630  ++index) {
631  const auto row = values_rowset->getOneColRow(index);
632  if (row.valid) {
633  in_vals.push_back(row.value);
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  }
641 }
bool g_enable_watchdog
Definition: Execute.cpp:71
#define UNLIKELY(x)
Definition: likely.h:20
#define CHECK(condition)
Definition: Logger.h:193
+ 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 1064 of file RelAlgTranslator.cpp.

References CHECK, and kPLUS.

Referenced by RelAlgTranslator::translateDatePlusMinus().

1064  {
1065  CHECK(op == kPLUS);
1066  return "DATETIME_PLUS"s;
1067 }
Definition: sqldefs.h:41
#define CHECK(condition)
Definition: Logger.h:193
+ 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 445 of file RelAlgTranslator.cpp.

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

Referenced by RelAlgTranslator::translateInOper().

446  {
447  if (!can_use_parallel_algorithms(val_set)) {
448  return nullptr;
449  }
450  if (val_set.rowCount() > 5000000 && g_enable_watchdog) {
451  throw std::runtime_error(
452  "Unable to handle 'expr IN (subquery)', subquery returned 5M+ rows.");
453  }
454  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
455  const size_t fetcher_count = cpu_threads();
456  std::vector<std::list<std::shared_ptr<Analyzer::Expr>>> expr_set(
457  fetcher_count, std::list<std::shared_ptr<Analyzer::Expr>>());
458  std::vector<std::future<void>> fetcher_threads;
459  const auto& ti = arg->get_type_info();
460  const auto entry_count = val_set.entryCount();
461  for (size_t i = 0,
462  start_entry = 0,
463  stride = (entry_count + fetcher_count - 1) / fetcher_count;
464  i < fetcher_count && start_entry < entry_count;
465  ++i, start_entry += stride) {
466  const auto end_entry = std::min(start_entry + stride, entry_count);
467  fetcher_threads.push_back(std::async(
468  std::launch::async,
469  [&](std::list<std::shared_ptr<Analyzer::Expr>>& in_vals,
470  const size_t start,
471  const size_t end) {
472  for (auto index = start; index < end; ++index) {
473  auto row = val_set.getRowAt(index);
474  if (row.empty()) {
475  continue;
476  }
477  auto scalar_tv = boost::get<ScalarTargetValue>(&row[0]);
478  Datum d{0};
479  bool is_null_const{false};
480  std::tie(d, is_null_const) = datum_from_scalar_tv(scalar_tv, ti);
481  if (ti.is_string() && ti.get_compression() != kENCODING_NONE) {
482  auto ti_none_encoded = ti;
483  ti_none_encoded.set_compression(kENCODING_NONE);
484  auto none_encoded_string =
485  makeExpr<Analyzer::Constant>(ti, is_null_const, d);
486  auto dict_encoded_string = std::make_shared<Analyzer::UOper>(
487  ti, false, kCAST, none_encoded_string);
488  in_vals.push_back(dict_encoded_string);
489  } else {
490  in_vals.push_back(makeExpr<Analyzer::Constant>(ti, is_null_const, d));
491  }
492  }
493  },
494  std::ref(expr_set[i]),
495  start_entry,
496  end_entry));
497  }
498  for (auto& child : fetcher_threads) {
499  child.get();
500  }
501 
502  val_set.moveToBegin();
503  for (auto& exprs : expr_set) {
504  value_exprs.splice(value_exprs.end(), exprs);
505  }
506  return makeExpr<Analyzer::InValues>(arg, value_exprs);
507 }
bool g_enable_watchdog
Definition: Execute.cpp:71
Definition: sqldefs.h:49
bool can_use_parallel_algorithms(const ResultSet &rows)
Definition: ResultSet.cpp:869
std::pair< Datum, bool > datum_from_scalar_tv(const ScalarTargetValue *scalar_tv, const SQLTypeInfo &ti) noexcept
int cpu_threads()
Definition: thread_count.h:25
+ 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:201
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 205 of file RelAlgTranslator.cpp.

References SQLTypeInfoCore< TYPE_FACET_PACK >::is_boolean(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_number(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_time(), kAVG, kMAX, kMIN, and kSUM.

Referenced by RelAlgTranslator::translateAggregateRex().

205  {
206  if ((agg_kind == kMIN || agg_kind == kMAX || agg_kind == kSUM || agg_kind == kAVG) &&
207  !(arg_ti.is_number() || arg_ti.is_boolean() || arg_ti.is_time())) {
208  return false;
209  }
210 
211  return true;
212 }
bool is_time() const
Definition: sqltypes.h:483
Definition: sqldefs.h:73
Definition: sqldefs.h:75
bool is_boolean() const
Definition: sqltypes.h:484
bool is_number() const
Definition: sqltypes.h:482
Definition: sqldefs.h:74
Definition: sqldefs.h:72
+ 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 967 of file RelAlgTranslator.cpp.

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

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

968  {
969  CHECK(ti.is_number());
970  Datum datum{0};
971  switch (ti.get_type()) {
972  case kTINYINT: {
973  datum.tinyintval = val;
974  break;
975  }
976  case kSMALLINT: {
977  datum.smallintval = val;
978  break;
979  }
980  case kINT: {
981  datum.intval = val;
982  break;
983  }
984  case kBIGINT: {
985  datum.bigintval = val;
986  break;
987  }
988  case kDECIMAL:
989  case kNUMERIC: {
990  datum.bigintval = val * exp_to_scale(ti.get_scale());
991  break;
992  }
993  case kFLOAT: {
994  datum.floatval = val;
995  break;
996  }
997  case kDOUBLE: {
998  datum.doubleval = val;
999  break;
1000  }
1001  default:
1002  CHECK(false);
1003  }
1004  return makeExpr<Analyzer::Constant>(ti, false, datum);
1005 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:331
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:326
bool is_number() const
Definition: sqltypes.h:482
#define CHECK(condition)
Definition: Logger.h:193
uint64_t exp_to_scale(const unsigned exp)
Definition: sqltypes.h:48
+ 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 1600 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().

1600  {
1601  const auto& window_bound = rex_window_function->getUpperBound();
1602  const bool to_current_row = !window_bound.unbounded && !window_bound.preceding &&
1603  !window_bound.following && window_bound.is_current_row &&
1604  !window_bound.offset && window_bound.order_key == 1;
1605  switch (rex_window_function->getKind()) {
1610  return to_current_row;
1611  }
1612  default: {
1613  return rex_window_function->getOrderKeys().empty()
1614  ? (window_bound.unbounded && !window_bound.preceding &&
1615  window_bound.following && !window_bound.is_current_row &&
1616  !window_bound.offset && window_bound.order_key == 2)
1617  : to_current_row;
1618  }
1619  }
1620 }
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 1581 of file RelAlgTranslator.cpp.

References Descending, and First.

Referenced by RelAlgTranslator::translateWindowFunction().

1582  {
1583  std::vector<Analyzer::OrderEntry> collation;
1584  for (size_t i = 0; i < sort_fields.size(); ++i) {
1585  const auto& sort_field = sort_fields[i];
1586  collation.emplace_back(i,
1587  sort_field.getSortDir() == SortDirection::Descending,
1588  sort_field.getNullsPosition() == NullSortedPosition::First);
1589  }
1590  return collation;
1591 }
+ 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 587 of file RelAlgTranslator.cpp.

Referenced by fill_dictionary_encoded_in_vals(), and fill_integer_in_vals().