OmniSciDB  f17484ade4
 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: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 2064 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().

2065  {
2066  const auto time_unit_val = const_expr->get_constval().bigintval;
2067  if (window_frame_bound_type == kINTERVAL_DAY_TIME) {
2068  if (time_unit_val == kMilliSecsPerSec) {
2069  return kSECOND;
2070  } else if (time_unit_val == kMilliSecsPerMin) {
2071  return kMINUTE;
2072  } else if (time_unit_val == kMilliSecsPerHour) {
2073  return kHOUR;
2074  } else if (time_unit_val == kMilliSecsPerDay) {
2075  return kDAY;
2076  }
2077  } else {
2078  CHECK(window_frame_bound_type == kINTERVAL_YEAR_MONTH);
2079  if (time_unit_val == 1) {
2080  return kMONTH;
2081  } else if (time_unit_val == 12) {
2082  return kYEAR;
2083  }
2084  }
2085  CHECK(false);
2086  return kUNKNOWN_FIELD;
2087 }
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 2048 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().

2049  {
2050  const auto time_unit_val = const_expr->get_constval().bigintval;
2051  if (window_frame_bound_type == kINTERVAL_DAY_TIME) {
2052  if (time_unit_val == kMilliSecsPerSec) {
2053  return 1;
2054  } else if (time_unit_val == kMilliSecsPerMin) {
2055  return kSecsPerMin;
2056  } else if (time_unit_val == kMilliSecsPerHour) {
2057  return kSecsPerHour;
2058  }
2059  }
2060  CHECK(false);
2061  return kUNKNOWN_FIELD;
2062 }
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 772 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().

779  {
780  CHECK(in_vals.empty());
781  bool dicts_are_equal = source_dict == dest_dict;
782  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
783  ++index) {
784  const auto row = values_rowset->getOneColRow(index);
785  if (UNLIKELY(!row.valid)) {
786  continue;
787  }
788  if (dicts_are_equal) {
789  in_vals.push_back(row.value);
790  } else {
791  const int string_id =
792  row.value == needle_null_val
793  ? needle_null_val
794  : dest_dict->getIdOfString(source_dict->getString(row.value));
795  if (string_id != StringDictionary::INVALID_STR_ID) {
796  in_vals.push_back(string_id);
797  }
798  }
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 }
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 833 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.

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

References CHECK, g_enable_watchdog, g_max_integer_set_size, and UNLIKELY.

Referenced by RelAlgTranslator::getInIntegerSetExpr().

810  {
811  CHECK(in_vals.empty());
812  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
813  ++index) {
814  const auto row = values_rowset->getOneColRow(index);
815  if (row.valid) {
816  in_vals.push_back(row.value);
817  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
818  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
819  throw std::runtime_error(
820  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
821  }
822  }
823  }
824 }
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 1308 of file RelAlgTranslator.cpp.

References CHECK, and kPLUS.

Referenced by RelAlgTranslator::translateDatePlusMinus().

1308  {
1309  CHECK(op == kPLUS);
1310  return "DATETIME_PLUS"s;
1311 }
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 627 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().

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

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 1240 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().

1241  {
1242  CHECK(ti.is_number());
1243  Datum datum{0};
1244  switch (ti.get_type()) {
1245  case kTINYINT: {
1246  datum.tinyintval = val;
1247  break;
1248  }
1249  case kSMALLINT: {
1250  datum.smallintval = val;
1251  break;
1252  }
1253  case kINT: {
1254  datum.intval = val;
1255  break;
1256  }
1257  case kBIGINT: {
1258  datum.bigintval = val;
1259  break;
1260  }
1261  case kDECIMAL:
1262  case kNUMERIC: {
1263  datum.bigintval = val * exp_to_scale(ti.get_scale());
1264  break;
1265  }
1266  case kFLOAT: {
1267  datum.floatval = val;
1268  break;
1269  }
1270  case kDOUBLE: {
1271  datum.doubleval = val;
1272  break;
1273  }
1274  default:
1275  CHECK(false);
1276  }
1277  return makeExpr<Analyzer::Constant>(ti, false, datum);
1278 }
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 2036 of file RelAlgTranslator.cpp.

References Descending, and First.

Referenced by RelAlgTranslator::translateWindowFunction().

2037  {
2038  std::vector<Analyzer::OrderEntry> collation;
2039  for (size_t i = 0; i < sort_fields.size(); ++i) {
2040  const auto& sort_field = sort_fields[i];
2041  collation.emplace_back(i,
2042  sort_field.getSortDir() == SortDirection::Descending,
2043  sort_field.getNullsPosition() == NullSortedPosition::First);
2044  }
2045  return collation;
2046 }

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

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

1215  {
1216  if (!literal_expr || literal_expr->get_is_null()) {
1217  throw std::runtime_error("The 'DatePart' argument must be a not 'null' literal.");
1218  }
1219 }

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

Referenced by fill_dictionary_encoded_in_vals(), and fill_integer_in_vals().