OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{RelAlgTranslator.cpp} Namespace Reference

Classes

struct  ByTypeIndex
 

Typedefs

using Handler = std::shared_ptr< Analyzer::Expr >(RelAlgTranslator::*)(RexScalar const *) const
 
using IndexedHandler = std::pair< std::type_index, Handler >
 

Functions

SQLTypeInfo build_type_info (const SQLTypes sql_type, const int scale, const int precision)
 
std::pair< Datum, bool > datum_from_scalar_tv (const ScalarTargetValue *scalar_tv, const SQLTypeInfo &ti) noexcept
 
template<typename... Ts>
std::array< IndexedHandler,
sizeof...(Ts)> 
makeHandlers ()
 
bool is_agg_supported_for_type (const SQLAgg &agg_kind, const SQLTypeInfo &arg_ti)
 
bool is_distinct_supported (SQLAgg const agg_kind)
 
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)
 
size_t determineTimeValMultiplierForTimeType (const SQLTypes &window_frame_bound_type, const Analyzer::Constant *const_expr)
 
ExtractField determineTimeUnit (const SQLTypes &window_frame_bound_type, const Analyzer::Constant *const_expr)
 

Variables

const size_t g_max_integer_set_size {1 << 25}
 

Typedef Documentation

using anonymous_namespace{RelAlgTranslator.cpp}::Handler = typedef std::shared_ptr<Analyzer::Expr> (RelAlgTranslator::*)(RexScalar const*) const

Definition at line 181 of file RelAlgTranslator.cpp.

using anonymous_namespace{RelAlgTranslator.cpp}::IndexedHandler = typedef std::pair<std::type_index, Handler>

Definition at line 182 of file RelAlgTranslator.cpp.

Function Documentation

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:

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

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ExtractField anonymous_namespace{RelAlgTranslator.cpp}::determineTimeUnit ( const SQLTypes window_frame_bound_type,
const Analyzer::Constant const_expr 
)

Definition at line 2075 of file RelAlgTranslator.cpp.

References Datum::bigintval, CHECK, Analyzer::Constant::get_constval(), kDAY, kHOUR, kINTERVAL_DAY_TIME, kINTERVAL_YEAR_MONTH, kMilliSecsPerDay, kMilliSecsPerHour, kMilliSecsPerMin, kMilliSecsPerSec, kMINUTE, kMONTH, kSECOND, kUNKNOWN_FIELD, and kYEAR.

Referenced by RelAlgTranslator::translateIntervalExprForWindowFraming().

2076  {
2077  const auto time_unit_val = const_expr->get_constval().bigintval;
2078  if (window_frame_bound_type == kINTERVAL_DAY_TIME) {
2079  if (time_unit_val == kMilliSecsPerSec) {
2080  return kSECOND;
2081  } else if (time_unit_val == kMilliSecsPerMin) {
2082  return kMINUTE;
2083  } else if (time_unit_val == kMilliSecsPerHour) {
2084  return kHOUR;
2085  } else if (time_unit_val == kMilliSecsPerDay) {
2086  return kDAY;
2087  }
2088  } else {
2089  CHECK(window_frame_bound_type == kINTERVAL_YEAR_MONTH);
2090  if (time_unit_val == 1) {
2091  return kMONTH;
2092  } else if (time_unit_val == 12) {
2093  return kYEAR;
2094  }
2095  }
2096  CHECK(false);
2097  return kUNKNOWN_FIELD;
2098 }
static constexpr int64_t kMilliSecsPerDay
static constexpr int64_t kMilliSecsPerMin
static constexpr int64_t kMilliSecsPerSec
int64_t bigintval
Definition: Datum.h:74
Datum get_constval() const
Definition: Analyzer.h:348
static constexpr int64_t kMilliSecsPerHour
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t anonymous_namespace{RelAlgTranslator.cpp}::determineTimeValMultiplierForTimeType ( const SQLTypes window_frame_bound_type,
const Analyzer::Constant const_expr 
)

Definition at line 2059 of file RelAlgTranslator.cpp.

References Datum::bigintval, CHECK, Analyzer::Constant::get_constval(), kINTERVAL_DAY_TIME, kMilliSecsPerHour, kMilliSecsPerMin, kMilliSecsPerSec, kSecsPerHour, kSecsPerMin, and kUNKNOWN_FIELD.

Referenced by RelAlgTranslator::translateIntervalExprForWindowFraming().

2060  {
2061  const auto time_unit_val = const_expr->get_constval().bigintval;
2062  if (window_frame_bound_type == kINTERVAL_DAY_TIME) {
2063  if (time_unit_val == kMilliSecsPerSec) {
2064  return 1;
2065  } else if (time_unit_val == kMilliSecsPerMin) {
2066  return kSecsPerMin;
2067  } else if (time_unit_val == kMilliSecsPerHour) {
2068  return kSecsPerHour;
2069  }
2070  }
2071  CHECK(false);
2072  return kUNKNOWN_FIELD;
2073 }
static constexpr int64_t kSecsPerHour
static constexpr int64_t kSecsPerMin
static constexpr int64_t kMilliSecsPerMin
static constexpr int64_t kMilliSecsPerSec
int64_t bigintval
Definition: Datum.h:74
Datum get_constval() const
Definition: Analyzer.h:348
static constexpr int64_t kMilliSecsPerHour
#define CHECK(condition)
Definition: Logger.h:291

+ 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 777 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().

784  {
785  CHECK(in_vals.empty());
786  bool dicts_are_equal = source_dict == dest_dict;
787  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
788  ++index) {
789  const auto row = values_rowset->getOneColRow(index);
790  if (UNLIKELY(!row.valid)) {
791  continue;
792  }
793  if (dicts_are_equal) {
794  in_vals.push_back(row.value);
795  } else {
796  const int string_id =
797  row.value == needle_null_val
798  ? needle_null_val
799  : dest_dict->getIdOfString(source_dict->getString(row.value));
800  if (string_id != StringDictionary::INVALID_STR_ID) {
801  in_vals.push_back(string_id);
802  }
803  }
804  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
805  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
806  throw std::runtime_error(
807  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
808  }
809  }
810 }
std::string getString(int32_t string_id) const
static constexpr int32_t INVALID_STR_ID
bool g_enable_watchdog
#define UNLIKELY(x)
Definition: likely.h:25
#define CHECK(condition)
Definition: Logger.h:291
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 838 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.

847  {
848  CHECK(in_vals.empty());
849  std::vector<int32_t> source_ids;
850  source_ids.reserve(values_rowset->entryCount());
851  bool has_nulls = false;
852  if (source_dict_ref == dest_dict_ref) {
853  in_vals.reserve(values_rowset_slice.second - values_rowset_slice.first +
854  1); // Add 1 to cover interval
855  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
856  ++index) {
857  const auto row = values_rowset->getOneColRow(index);
858  if (!row.valid) {
859  continue;
860  }
861  if (row.value != needle_null_val) {
862  in_vals.push_back(row.value);
863  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
864  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
865  throw std::runtime_error(
866  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
867  }
868  } else {
869  has_nulls = true;
870  }
871  }
872  if (has_nulls) {
873  in_vals.push_back(
874  needle_null_val); // we've deduped null values as an optimization, although
875  // this is not required by consumer
876  }
877  return;
878  }
879  // Code path below is for when dictionaries are not shared
880  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
881  ++index) {
882  const auto row = values_rowset->getOneColRow(index);
883  if (row.valid) {
884  if (row.value != needle_null_val) {
885  source_ids.push_back(row.value);
886  } else {
887  has_nulls = true;
888  }
889  }
890  }
891  std::vector<int32_t> dest_ids;
892  translate_string_ids(dest_ids,
893  leaf_hosts.front(),
894  dest_dict_ref,
895  source_ids,
896  source_dict_ref,
897  dest_generation);
898  CHECK_EQ(dest_ids.size(), source_ids.size());
899  in_vals.reserve(dest_ids.size() + (has_nulls ? 1 : 0));
900  if (has_nulls) {
901  in_vals.push_back(needle_null_val);
902  }
903  for (const int32_t dest_id : dest_ids) {
904  if (dest_id != StringDictionary::INVALID_STR_ID) {
905  in_vals.push_back(dest_id);
906  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
907  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
908  throw std::runtime_error(
909  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
910  }
911  }
912  }
913 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
static constexpr int32_t INVALID_STR_ID
bool g_enable_watchdog
#define UNLIKELY(x)
Definition: likely.h:25
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)
#define CHECK(condition)
Definition: Logger.h:291

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

References CHECK, g_enable_watchdog, g_max_integer_set_size, and UNLIKELY.

Referenced by RelAlgTranslator::getInIntegerSetExpr().

815  {
816  CHECK(in_vals.empty());
817  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
818  ++index) {
819  const auto row = values_rowset->getOneColRow(index);
820  if (row.valid) {
821  in_vals.push_back(row.value);
822  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
823  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
824  throw std::runtime_error(
825  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
826  }
827  }
828  }
829 }
bool g_enable_watchdog
#define UNLIKELY(x)
Definition: likely.h:25
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

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

Definition at line 1313 of file RelAlgTranslator.cpp.

References CHECK, and kPLUS.

Referenced by RelAlgTranslator::translateDatePlusMinus().

1313  {
1314  CHECK(op == kPLUS);
1315  return "DATETIME_PLUS"s;
1316 }
Definition: sqldefs.h:40
#define CHECK(condition)
Definition: Logger.h:291

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

References threading_serial::async(), result_set::can_use_parallel_algorithms(), cpu_threads(), datum_from_scalar_tv(), g_enable_watchdog, kCAST, and kENCODING_NONE.

Referenced by RelAlgTranslator::translateInOper().

633  {
635  return nullptr;
636  }
637  if (val_set.rowCount() > 5000000 && g_enable_watchdog) {
638  throw std::runtime_error(
639  "Unable to handle 'expr IN (subquery)', subquery returned 5M+ rows.");
640  }
641  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
642  const size_t fetcher_count = cpu_threads();
643  std::vector<std::list<std::shared_ptr<Analyzer::Expr>>> expr_set(
644  fetcher_count, std::list<std::shared_ptr<Analyzer::Expr>>());
645  std::vector<std::future<void>> fetcher_threads;
646  const auto& ti = arg->get_type_info();
647  const auto entry_count = val_set.entryCount();
648  for (size_t i = 0,
649  start_entry = 0,
650  stride = (entry_count + fetcher_count - 1) / fetcher_count;
651  i < fetcher_count && start_entry < entry_count;
652  ++i, start_entry += stride) {
653  const auto end_entry = std::min(start_entry + stride, entry_count);
654  fetcher_threads.push_back(std::async(
656  [&](std::list<std::shared_ptr<Analyzer::Expr>>& in_vals,
657  const size_t start,
658  const size_t end) {
659  for (auto index = start; index < end; ++index) {
660  auto row = val_set.getRowAt(index);
661  if (row.empty()) {
662  continue;
663  }
664  auto scalar_tv = boost::get<ScalarTargetValue>(&row[0]);
665  Datum d{0};
666  bool is_null_const{false};
667  std::tie(d, is_null_const) = datum_from_scalar_tv(scalar_tv, ti);
668  if (ti.is_string() && ti.get_compression() != kENCODING_NONE) {
669  auto ti_none_encoded = ti;
670  ti_none_encoded.set_compression(kENCODING_NONE);
671  auto none_encoded_string =
672  makeExpr<Analyzer::Constant>(ti, is_null_const, d);
673  auto dict_encoded_string = std::make_shared<Analyzer::UOper>(
674  ti, false, kCAST, none_encoded_string);
675  in_vals.push_back(dict_encoded_string);
676  } else {
677  in_vals.push_back(makeExpr<Analyzer::Constant>(ti, is_null_const, d));
678  }
679  }
680  },
681  std::ref(expr_set[i]),
682  start_entry,
683  end_entry));
684  }
685  for (auto& child : fetcher_threads) {
686  child.get();
687  }
688 
689  val_set.moveToBegin();
690  for (auto& exprs : expr_set) {
691  value_exprs.splice(value_exprs.end(), exprs);
692  }
693  return makeExpr<Analyzer::InValues>(arg, value_exprs);
694 }
Definition: sqldefs.h:48
future< Result > async(Fn &&fn, Args &&...args)
bool g_enable_watchdog
std::pair< Datum, bool > datum_from_scalar_tv(const ScalarTargetValue *scalar_tv, const SQLTypeInfo &ti) noexcept
int cpu_threads()
Definition: thread_count.h:25
Definition: Datum.h:69
bool can_use_parallel_algorithms(const ResultSet &rows)
Definition: ResultSet.cpp:1581

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

References SQLTypeInfo::is_boolean(), SQLTypeInfo::is_number(), SQLTypeInfo::is_string(), SQLTypeInfo::is_time(), and kMODE.

Referenced by RelAlgTranslator::translateAggregateRex().

266  {
267  return arg_ti.is_number() || arg_ti.is_boolean() || arg_ti.is_time() ||
268  (agg_kind == kMODE && arg_ti.is_string()) ||
269  !shared::is_any<kAVG, kMIN, kMAX, kSUM, kAPPROX_QUANTILE, kMODE>(agg_kind);
270 }
bool is_number() const
Definition: sqltypes.h:574
bool is_time() const
Definition: sqltypes.h:577
bool is_boolean() const
Definition: sqltypes.h:580
bool is_string() const
Definition: sqltypes.h:559
Definition: sqldefs.h:83

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{RelAlgTranslator.cpp}::is_distinct_supported ( SQLAgg const  agg_kind)

Definition at line 272 of file RelAlgTranslator.cpp.

Referenced by RelAlgTranslator::translateAggregateRex().

272  {
273  return shared::is_any<kMIN, kMAX, kCOUNT, kAPPROX_COUNT_DISTINCT>(agg_kind);
274 }

+ Here is the caller graph for this function:

template<typename... Ts>
std::array<IndexedHandler, sizeof...(Ts)> anonymous_namespace{RelAlgTranslator.cpp}::makeHandlers ( )

Definition at line 185 of file RelAlgTranslator.cpp.

Referenced by RelAlgTranslator::translateScalarRex().

185  {
186  return {IndexedHandler{std::type_index(typeid(Ts)),
187  &RelAlgTranslator::translateRexScalar<Ts>}...};
188 }
std::pair< std::type_index, Handler > IndexedHandler

+ 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 1245 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().

1246  {
1247  CHECK(ti.is_number());
1248  Datum datum{0};
1249  switch (ti.get_type()) {
1250  case kTINYINT: {
1251  datum.tinyintval = val;
1252  break;
1253  }
1254  case kSMALLINT: {
1255  datum.smallintval = val;
1256  break;
1257  }
1258  case kINT: {
1259  datum.intval = val;
1260  break;
1261  }
1262  case kBIGINT: {
1263  datum.bigintval = val;
1264  break;
1265  }
1266  case kDECIMAL:
1267  case kNUMERIC: {
1268  datum.bigintval = val * exp_to_scale(ti.get_scale());
1269  break;
1270  }
1271  case kFLOAT: {
1272  datum.floatval = val;
1273  break;
1274  }
1275  case kDOUBLE: {
1276  datum.doubleval = val;
1277  break;
1278  }
1279  default:
1280  CHECK(false);
1281  }
1282  return makeExpr<Analyzer::Constant>(ti, false, datum);
1283 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:396
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
bool is_number() const
Definition: sqltypes.h:574
#define CHECK(condition)
Definition: Logger.h:291
uint64_t exp_to_scale(const unsigned exp)
Definition: sqltypes.h:72
Definition: Datum.h:69

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

References Descending, and First.

Referenced by RelAlgTranslator::translateWindowFunction().

2048  {
2049  std::vector<Analyzer::OrderEntry> collation;
2050  for (size_t i = 0; i < sort_fields.size(); ++i) {
2051  const auto& sort_field = sort_fields[i];
2052  collation.emplace_back(i,
2053  sort_field.getSortDir() == SortDirection::Descending,
2054  sort_field.getNullsPosition() == NullSortedPosition::First);
2055  }
2056  return collation;
2057 }

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

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

1220  {
1221  if (!literal_expr || literal_expr->get_is_null()) {
1222  throw std::runtime_error("The 'DatePart' argument must be a not 'null' literal.");
1223  }
1224 }

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

Referenced by fill_dictionary_encoded_in_vals(), and fill_integer_in_vals().