OmniSciDB  a987f07e93
 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:64
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:67
Definition: sqltypes.h:68
std::string get_type_name() const
Definition: sqltypes.h:504
Definition: sqltypes.h:56
#define CHECK(condition)
Definition: Logger.h:289
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:60
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 1987 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().

1988  {
1989  const auto time_unit_val = const_expr->get_constval().bigintval;
1990  if (window_frame_bound_type == kINTERVAL_DAY_TIME) {
1991  if (time_unit_val == kMilliSecsPerSec) {
1992  return kSECOND;
1993  } else if (time_unit_val == kMilliSecsPerMin) {
1994  return kMINUTE;
1995  } else if (time_unit_val == kMilliSecsPerHour) {
1996  return kHOUR;
1997  } else if (time_unit_val == kMilliSecsPerDay) {
1998  return kDAY;
1999  }
2000  } else {
2001  CHECK(window_frame_bound_type == kINTERVAL_YEAR_MONTH);
2002  if (time_unit_val == 1) {
2003  return kMONTH;
2004  } else if (time_unit_val == 12) {
2005  return kYEAR;
2006  }
2007  }
2008  CHECK(false);
2009  return kUNKNOWN_FIELD;
2010 }
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:344
static constexpr int64_t kMilliSecsPerHour
#define CHECK(condition)
Definition: Logger.h:289

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

1972  {
1973  const auto time_unit_val = const_expr->get_constval().bigintval;
1974  if (window_frame_bound_type == kINTERVAL_DAY_TIME) {
1975  if (time_unit_val == kMilliSecsPerSec) {
1976  return 1;
1977  } else if (time_unit_val == kMilliSecsPerMin) {
1978  return kSecsPerMin;
1979  } else if (time_unit_val == kMilliSecsPerHour) {
1980  return kSecsPerHour;
1981  }
1982  }
1983  CHECK(false);
1984  return kUNKNOWN_FIELD;
1985 }
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:344
static constexpr int64_t kMilliSecsPerHour
#define CHECK(condition)
Definition: Logger.h:289

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

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

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

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

References CHECK, g_enable_watchdog, g_max_integer_set_size, and UNLIKELY.

Referenced by RelAlgTranslator::getInIntegerSetExpr().

788  {
789  CHECK(in_vals.empty());
790  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
791  ++index) {
792  const auto row = values_rowset->getOneColRow(index);
793  if (row.valid) {
794  in_vals.push_back(row.value);
795  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
796  total_in_vals_count.fetch_add(1024) >= g_max_integer_set_size)) {
797  throw std::runtime_error(
798  "Unable to handle 'expr IN (subquery)', subquery returned 30M+ rows.");
799  }
800  }
801  }
802 }
bool g_enable_watchdog
#define UNLIKELY(x)
Definition: likely.h:25
#define CHECK(condition)
Definition: Logger.h:289

+ Here is the caller graph for this function:

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

Definition at line 1253 of file RelAlgTranslator.cpp.

References CHECK, and kPLUS.

Referenced by RelAlgTranslator::translateDatePlusMinus().

1253  {
1254  CHECK(op == kPLUS);
1255  return "DATETIME_PLUS"s;
1256 }
Definition: sqldefs.h:40
#define CHECK(condition)
Definition: Logger.h:289

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

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

+ 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:581
bool is_time() const
Definition: sqltypes.h:582
Definition: sqldefs.h:75
Definition: sqldefs.h:77
bool is_boolean() const
Definition: sqltypes.h:583
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 1185 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().

1186  {
1187  CHECK(ti.is_number());
1188  Datum datum{0};
1189  switch (ti.get_type()) {
1190  case kTINYINT: {
1191  datum.tinyintval = val;
1192  break;
1193  }
1194  case kSMALLINT: {
1195  datum.smallintval = val;
1196  break;
1197  }
1198  case kINT: {
1199  datum.intval = val;
1200  break;
1201  }
1202  case kBIGINT: {
1203  datum.bigintval = val;
1204  break;
1205  }
1206  case kDECIMAL:
1207  case kNUMERIC: {
1208  datum.bigintval = val * exp_to_scale(ti.get_scale());
1209  break;
1210  }
1211  case kFLOAT: {
1212  datum.floatval = val;
1213  break;
1214  }
1215  case kDOUBLE: {
1216  datum.doubleval = val;
1217  break;
1218  }
1219  default:
1220  CHECK(false);
1221  }
1222  return makeExpr<Analyzer::Constant>(ti, false, datum);
1223 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:385
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
bool is_number() const
Definition: sqltypes.h:581
#define CHECK(condition)
Definition: Logger.h:289
uint64_t exp_to_scale(const unsigned exp)
Definition: sqltypes.h:60
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 1959 of file RelAlgTranslator.cpp.

References Descending, and First.

Referenced by RelAlgTranslator::translateWindowFunction().

1960  {
1961  std::vector<Analyzer::OrderEntry> collation;
1962  for (size_t i = 0; i < sort_fields.size(); ++i) {
1963  const auto& sort_field = sort_fields[i];
1964  collation.emplace_back(i,
1965  sort_field.getSortDir() == SortDirection::Descending,
1966  sort_field.getNullsPosition() == NullSortedPosition::First);
1967  }
1968  return collation;
1969 }

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

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

1160  {
1161  if (!literal_expr || literal_expr->get_is_null()) {
1162  throw std::runtime_error("The 'DatePart' argument must be a not 'null' literal.");
1163  }
1164 }

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

Referenced by fill_dictionary_encoded_in_vals(), and fill_integer_in_vals().