OmniSciDB  c1a53651b2
 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)
 
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:66
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:69
Definition: sqltypes.h:70
std::string get_type_name() const
Definition: sqltypes.h:507
Definition: sqltypes.h:58
#define CHECK(condition)
Definition: Logger.h:291
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:62
Definition: Datum.h:67

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

2016  {
2017  const auto time_unit_val = const_expr->get_constval().bigintval;
2018  if (window_frame_bound_type == kINTERVAL_DAY_TIME) {
2019  if (time_unit_val == kMilliSecsPerSec) {
2020  return kSECOND;
2021  } else if (time_unit_val == kMilliSecsPerMin) {
2022  return kMINUTE;
2023  } else if (time_unit_val == kMilliSecsPerHour) {
2024  return kHOUR;
2025  } else if (time_unit_val == kMilliSecsPerDay) {
2026  return kDAY;
2027  }
2028  } else {
2029  CHECK(window_frame_bound_type == kINTERVAL_YEAR_MONTH);
2030  if (time_unit_val == 1) {
2031  return kMONTH;
2032  } else if (time_unit_val == 12) {
2033  return kYEAR;
2034  }
2035  }
2036  CHECK(false);
2037  return kUNKNOWN_FIELD;
2038 }
static constexpr int64_t kMilliSecsPerDay
static constexpr int64_t kMilliSecsPerMin
static constexpr int64_t kMilliSecsPerSec
int64_t bigintval
Definition: Datum.h:72
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 1999 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().

2000  {
2001  const auto time_unit_val = const_expr->get_constval().bigintval;
2002  if (window_frame_bound_type == kINTERVAL_DAY_TIME) {
2003  if (time_unit_val == kMilliSecsPerSec) {
2004  return 1;
2005  } else if (time_unit_val == kMilliSecsPerMin) {
2006  return kSecsPerMin;
2007  } else if (time_unit_val == kMilliSecsPerHour) {
2008  return kSecsPerHour;
2009  }
2010  }
2011  CHECK(false);
2012  return kUNKNOWN_FIELD;
2013 }
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:72
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 754 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().

761  {
762  CHECK(in_vals.empty());
763  bool dicts_are_equal = source_dict == dest_dict;
764  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
765  ++index) {
766  const auto row = values_rowset->getOneColRow(index);
767  if (UNLIKELY(!row.valid)) {
768  continue;
769  }
770  if (dicts_are_equal) {
771  in_vals.push_back(row.value);
772  } else {
773  const int string_id =
774  row.value == needle_null_val
775  ? needle_null_val
776  : dest_dict->getIdOfString(source_dict->getString(row.value));
777  if (string_id != StringDictionary::INVALID_STR_ID) {
778  in_vals.push_back(string_id);
779  }
780  }
781  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
782  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
783  throw std::runtime_error(
784  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
785  }
786  }
787 }
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 815 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.

824  {
825  CHECK(in_vals.empty());
826  std::vector<int32_t> source_ids;
827  source_ids.reserve(values_rowset->entryCount());
828  bool has_nulls = false;
829  if (source_dict_ref == dest_dict_ref) {
830  in_vals.reserve(values_rowset_slice.second - values_rowset_slice.first +
831  1); // Add 1 to cover interval
832  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
833  ++index) {
834  const auto row = values_rowset->getOneColRow(index);
835  if (!row.valid) {
836  continue;
837  }
838  if (row.value != needle_null_val) {
839  in_vals.push_back(row.value);
840  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
841  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
842  throw std::runtime_error(
843  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
844  }
845  } else {
846  has_nulls = true;
847  }
848  }
849  if (has_nulls) {
850  in_vals.push_back(
851  needle_null_val); // we've deduped null values as an optimization, although
852  // this is not required by consumer
853  }
854  return;
855  }
856  // Code path below is for when dictionaries are not shared
857  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
858  ++index) {
859  const auto row = values_rowset->getOneColRow(index);
860  if (row.valid) {
861  if (row.value != needle_null_val) {
862  source_ids.push_back(row.value);
863  } else {
864  has_nulls = true;
865  }
866  }
867  }
868  std::vector<int32_t> dest_ids;
869  translate_string_ids(dest_ids,
870  leaf_hosts.front(),
871  dest_dict_ref,
872  source_ids,
873  source_dict_ref,
874  dest_generation);
875  CHECK_EQ(dest_ids.size(), source_ids.size());
876  in_vals.reserve(dest_ids.size() + (has_nulls ? 1 : 0));
877  if (has_nulls) {
878  in_vals.push_back(needle_null_val);
879  }
880  for (const int32_t dest_id : dest_ids) {
881  if (dest_id != StringDictionary::INVALID_STR_ID) {
882  in_vals.push_back(dest_id);
883  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
884  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
885  throw std::runtime_error(
886  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
887  }
888  }
889  }
890 }
#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 789 of file RelAlgTranslator.cpp.

References CHECK, g_enable_watchdog, g_max_integer_set_size, and UNLIKELY.

Referenced by RelAlgTranslator::getInIntegerSetExpr().

792  {
793  CHECK(in_vals.empty());
794  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
795  ++index) {
796  const auto row = values_rowset->getOneColRow(index);
797  if (row.valid) {
798  in_vals.push_back(row.value);
799  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
800  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
801  throw std::runtime_error(
802  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
803  }
804  }
805  }
806 }
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 1261 of file RelAlgTranslator.cpp.

References CHECK, and kPLUS.

Referenced by RelAlgTranslator::translateDatePlusMinus().

1261  {
1262  CHECK(op == kPLUS);
1263  return "DATETIME_PLUS"s;
1264 }
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 609 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().

610  {
612  return nullptr;
613  }
614  if (val_set.rowCount() > 5000000 && g_enable_watchdog) {
615  throw std::runtime_error(
616  "Unable to handle 'expr IN (subquery)', subquery returned 5M+ rows.");
617  }
618  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
619  const size_t fetcher_count = cpu_threads();
620  std::vector<std::list<std::shared_ptr<Analyzer::Expr>>> expr_set(
621  fetcher_count, std::list<std::shared_ptr<Analyzer::Expr>>());
622  std::vector<std::future<void>> fetcher_threads;
623  const auto& ti = arg->get_type_info();
624  const auto entry_count = val_set.entryCount();
625  for (size_t i = 0,
626  start_entry = 0,
627  stride = (entry_count + fetcher_count - 1) / fetcher_count;
628  i < fetcher_count && start_entry < entry_count;
629  ++i, start_entry += stride) {
630  const auto end_entry = std::min(start_entry + stride, entry_count);
631  fetcher_threads.push_back(std::async(
633  [&](std::list<std::shared_ptr<Analyzer::Expr>>& in_vals,
634  const size_t start,
635  const size_t end) {
636  for (auto index = start; index < end; ++index) {
637  auto row = val_set.getRowAt(index);
638  if (row.empty()) {
639  continue;
640  }
641  auto scalar_tv = boost::get<ScalarTargetValue>(&row[0]);
642  Datum d{0};
643  bool is_null_const{false};
644  std::tie(d, is_null_const) = datum_from_scalar_tv(scalar_tv, ti);
645  if (ti.is_string() && ti.get_compression() != kENCODING_NONE) {
646  auto ti_none_encoded = ti;
647  ti_none_encoded.set_compression(kENCODING_NONE);
648  auto none_encoded_string =
649  makeExpr<Analyzer::Constant>(ti, is_null_const, d);
650  auto dict_encoded_string = std::make_shared<Analyzer::UOper>(
651  ti, false, kCAST, none_encoded_string);
652  in_vals.push_back(dict_encoded_string);
653  } else {
654  in_vals.push_back(makeExpr<Analyzer::Constant>(ti, is_null_const, d));
655  }
656  }
657  },
658  std::ref(expr_set[i]),
659  start_entry,
660  end_entry));
661  }
662  for (auto& child : fetcher_threads) {
663  child.get();
664  }
665 
666  val_set.moveToBegin();
667  for (auto& exprs : expr_set) {
668  value_exprs.splice(value_exprs.end(), exprs);
669  }
670  return makeExpr<Analyzer::InValues>(arg, value_exprs);
671 }
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:67
bool can_use_parallel_algorithms(const ResultSet &rows)
Definition: ResultSet.cpp:1558

+ 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_time(), kAVG, kMAX, kMIN, and kSUM.

Referenced by RelAlgTranslator::translateAggregateRex().

266  {
267  if ((agg_kind == kMIN || agg_kind == kMAX || agg_kind == kSUM || agg_kind == kAVG) &&
268  !(arg_ti.is_number() || arg_ti.is_boolean() || arg_ti.is_time())) {
269  return false;
270  }
271 
272  return true;
273 }
bool is_number() const
Definition: sqltypes.h:585
bool is_time() const
Definition: sqltypes.h:586
Definition: sqldefs.h:75
Definition: sqldefs.h:77
bool is_boolean() const
Definition: sqltypes.h:587
Definition: sqldefs.h:76
Definition: sqldefs.h:74

+ Here is the call graph for this function:

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

1194  {
1195  CHECK(ti.is_number());
1196  Datum datum{0};
1197  switch (ti.get_type()) {
1198  case kTINYINT: {
1199  datum.tinyintval = val;
1200  break;
1201  }
1202  case kSMALLINT: {
1203  datum.smallintval = val;
1204  break;
1205  }
1206  case kINT: {
1207  datum.intval = val;
1208  break;
1209  }
1210  case kBIGINT: {
1211  datum.bigintval = val;
1212  break;
1213  }
1214  case kDECIMAL:
1215  case kNUMERIC: {
1216  datum.bigintval = val * exp_to_scale(ti.get_scale());
1217  break;
1218  }
1219  case kFLOAT: {
1220  datum.floatval = val;
1221  break;
1222  }
1223  case kDOUBLE: {
1224  datum.doubleval = val;
1225  break;
1226  }
1227  default:
1228  CHECK(false);
1229  }
1230  return makeExpr<Analyzer::Constant>(ti, false, datum);
1231 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:386
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
bool is_number() const
Definition: sqltypes.h:585
#define CHECK(condition)
Definition: Logger.h:291
uint64_t exp_to_scale(const unsigned exp)
Definition: sqltypes.h:62
Definition: Datum.h:67

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

References Descending, and First.

Referenced by RelAlgTranslator::translateWindowFunction().

1988  {
1989  std::vector<Analyzer::OrderEntry> collation;
1990  for (size_t i = 0; i < sort_fields.size(); ++i) {
1991  const auto& sort_field = sort_fields[i];
1992  collation.emplace_back(i,
1993  sort_field.getSortDir() == SortDirection::Descending,
1994  sort_field.getNullsPosition() == NullSortedPosition::First);
1995  }
1996  return collation;
1997 }

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

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

1168  {
1169  if (!literal_expr || literal_expr->get_is_null()) {
1170  throw std::runtime_error("The 'DatePart' argument must be a not 'null' literal.");
1171  }
1172 }

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

Referenced by fill_dictionary_encoded_in_vals(), and fill_integer_in_vals().