OmniSciDB  a5dc49c757
 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)
 
SqlWindowFrameBoundType determine_frame_bound_type (const RexWindowFunctionOperator::RexWindowBound &bound)
 
bool is_negative_framing_bound (const SQLTypes t, const Datum &d, bool is_time_unit=false)
 

Typedef Documentation

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

Definition at line 184 of file RelAlgTranslator.cpp.

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

Definition at line 185 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 47 of file RelAlgTranslator.cpp.

References SQLTypeInfo::is_decimal(), SQLTypeInfo::set_precision(), and SQLTypeInfo::set_scale().

Referenced by RelAlgTranslator::translateLiteral().

49  {
50  SQLTypeInfo ti(sql_type, 0, 0, true);
51  if (ti.is_decimal()) {
52  ti.set_scale(scale);
53  ti.set_precision(precision);
54  }
55  return ti;
56 }

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SqlWindowFrameBoundType anonymous_namespace{RelAlgTranslator.cpp}::determine_frame_bound_type ( const RexWindowFunctionOperator::RexWindowBound bound)

Definition at line 2170 of file RelAlgTranslator.cpp.

References RexWindowFunctionOperator::RexWindowBound::bound_expr, CHECK, CURRENT_ROW, EXPR_FOLLOWING, EXPR_PRECEDING, RexWindowFunctionOperator::RexWindowBound::following, RexWindowFunctionOperator::RexWindowBound::is_current_row, RexWindowFunctionOperator::RexWindowBound::preceding, RexWindowFunctionOperator::RexWindowBound::unbounded, UNBOUNDED_FOLLOWING, UNBOUNDED_PRECEDING, and UNKNOWN.

Referenced by RelAlgTranslator::translateWindowFunction().

2171  {
2172  if (bound.unbounded) {
2173  CHECK(!bound.bound_expr && !bound.is_current_row);
2174  if (bound.following) {
2176  } else if (bound.preceding) {
2178  }
2179  } else {
2180  if (bound.is_current_row) {
2181  CHECK(!bound.unbounded && !bound.bound_expr);
2183  } else {
2184  CHECK(!bound.unbounded && bound.bound_expr);
2185  if (bound.following) {
2187  } else if (bound.preceding) {
2189  }
2190  }
2191  }
2193 }
std::shared_ptr< const RexScalar > bound_expr
Definition: RelAlgDag.h:581
#define CHECK(condition)
Definition: Logger.h:291

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

2146  {
2147  const auto time_unit_val = const_expr->get_constval().bigintval;
2148  if (window_frame_bound_type == kINTERVAL_DAY_TIME) {
2149  if (time_unit_val == kMilliSecsPerSec) {
2150  return kSECOND;
2151  } else if (time_unit_val == kMilliSecsPerMin) {
2152  return kMINUTE;
2153  } else if (time_unit_val == kMilliSecsPerHour) {
2154  return kHOUR;
2155  } else if (time_unit_val == kMilliSecsPerDay) {
2156  return kDAY;
2157  }
2158  } else {
2159  CHECK(window_frame_bound_type == kINTERVAL_YEAR_MONTH);
2160  if (time_unit_val == 1) {
2161  return kMONTH;
2162  } else if (time_unit_val == 12) {
2163  return kYEAR;
2164  }
2165  }
2166  CHECK(false);
2167  return kUNKNOWN_FIELD;
2168 }
static constexpr int64_t kMilliSecsPerDay
static constexpr int64_t kMilliSecsPerMin
static constexpr int64_t kMilliSecsPerSec
int64_t bigintval
Definition: Datum.h:76
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 2129 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().

2130  {
2131  const auto time_unit_val = const_expr->get_constval().bigintval;
2132  if (window_frame_bound_type == kINTERVAL_DAY_TIME) {
2133  if (time_unit_val == kMilliSecsPerSec) {
2134  return 1;
2135  } else if (time_unit_val == kMilliSecsPerMin) {
2136  return kSecsPerMin;
2137  } else if (time_unit_val == kMilliSecsPerHour) {
2138  return kSecsPerHour;
2139  }
2140  }
2141  CHECK(false);
2142  return kUNKNOWN_FIELD;
2143 }
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:76
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 804 of file RelAlgTranslator.cpp.

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

Referenced by RelAlgTranslator::getInIntegerSetExpr().

811  {
812  CHECK(in_vals.empty());
813  bool dicts_are_equal = source_dict == dest_dict;
814  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
815  ++index) {
816  const auto row = values_rowset->getOneColRow(index);
817  if (UNLIKELY(!row.valid)) {
818  continue;
819  }
820  if (dicts_are_equal) {
821  in_vals.push_back(row.value);
822  } else {
823  const int string_id =
824  row.value == needle_null_val
825  ? needle_null_val
826  : dest_dict->getIdOfString(source_dict->getString(row.value));
827  if (string_id != StringDictionary::INVALID_STR_ID) {
828  in_vals.push_back(string_id);
829  }
830  }
831  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
832  total_in_vals_count.fetch_add(1024) >=
834  std::ostringstream oss;
835  oss << "Unable to handle 'expr IN (subquery)' via bitmap, # unique encoded-string ("
836  << total_in_vals_count.load()
837  << ") is larger than the threshold 'g_watchdog_in_clause_max_num_elem_bitmap': "
839  throw std::runtime_error(oss.str());
840  }
841  }
842 }
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
size_t g_watchdog_in_clause_max_num_elem_bitmap
Definition: Execute.cpp:86
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 877 of file RelAlgTranslator.cpp.

References CHECK, CHECK_EQ, g_enable_watchdog, g_watchdog_in_clause_max_num_elem_bitmap, StringDictionary::INVALID_STR_ID, translate_string_ids(), and UNLIKELY.

886  {
887  CHECK(in_vals.empty());
888  std::vector<int32_t> source_ids;
889  source_ids.reserve(values_rowset->entryCount());
890  bool has_nulls = false;
891  if (source_dict_ref == dest_dict_ref) {
892  in_vals.reserve(values_rowset_slice.second - values_rowset_slice.first +
893  1); // Add 1 to cover interval
894  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
895  ++index) {
896  const auto row = values_rowset->getOneColRow(index);
897  if (!row.valid) {
898  continue;
899  }
900  if (row.value != needle_null_val) {
901  in_vals.push_back(row.value);
902  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
903  total_in_vals_count.fetch_add(1024) >=
905  std::ostringstream oss;
906  oss << "Unable to handle 'expr IN (subquery)' via bitmap, # unique "
907  "encoded-string values ("
908  << total_in_vals_count.load()
909  << ") is larger than the threshold "
910  "'g_watchdog_in_clause_max_num_elem_bitmap': "
912  throw std::runtime_error(oss.str());
913  }
914  } else {
915  has_nulls = true;
916  }
917  }
918  if (has_nulls) {
919  in_vals.push_back(
920  needle_null_val); // we've deduped null values as an optimization, although
921  // this is not required by consumer
922  }
923  return;
924  }
925  // Code path below is for when dictionaries are not shared
926  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
927  ++index) {
928  const auto row = values_rowset->getOneColRow(index);
929  if (row.valid) {
930  if (row.value != needle_null_val) {
931  source_ids.push_back(row.value);
932  } else {
933  has_nulls = true;
934  }
935  }
936  }
937  std::vector<int32_t> dest_ids;
938  translate_string_ids(dest_ids,
939  leaf_hosts.front(),
940  dest_dict_ref,
941  source_ids,
942  source_dict_ref,
943  dest_generation);
944  CHECK_EQ(dest_ids.size(), source_ids.size());
945  in_vals.reserve(dest_ids.size() + (has_nulls ? 1 : 0));
946  if (has_nulls) {
947  in_vals.push_back(needle_null_val);
948  }
949  for (const int32_t dest_id : dest_ids) {
950  if (dest_id != StringDictionary::INVALID_STR_ID) {
951  in_vals.push_back(dest_id);
952  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
953  total_in_vals_count.fetch_add(1024) >=
955  std::ostringstream oss;
956  oss << "Unable to handle 'expr IN (subquery)' via bitmap, # unique "
957  "encoded-string values ("
958  << total_in_vals_count.load()
959  << ") is larger than the threshold "
960  "'g_watchdog_in_clause_max_num_elem_bitmap': "
962  throw std::runtime_error(oss.str());
963  }
964  }
965  }
966 }
#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
size_t g_watchdog_in_clause_max_num_elem_bitmap
Definition: Execute.cpp:86

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

References CHECK, g_enable_watchdog, g_watchdog_in_clause_max_num_elem_bitmap, and UNLIKELY.

Referenced by RelAlgTranslator::getInIntegerSetExpr().

847  {
848  CHECK(in_vals.empty());
849  for (auto index = values_rowset_slice.first; index < values_rowset_slice.second;
850  ++index) {
851  const auto row = values_rowset->getOneColRow(index);
852  if (row.valid) {
853  in_vals.push_back(row.value);
854  if (UNLIKELY(g_enable_watchdog && (in_vals.size() & 1023) == 0 &&
855  total_in_vals_count.fetch_add(1024) >=
857  std::ostringstream oss;
858  oss << "Unable to handle 'expr IN (subquery)' via bitmap, # unique integer "
859  "values ("
860  << total_in_vals_count.load()
861  << ") is larger than the threshold "
862  "'g_watchdog_in_clause_max_num_elem_bitmap': "
864  throw std::runtime_error(oss.str());
865  }
866  }
867  }
868 }
bool g_enable_watchdog
#define UNLIKELY(x)
Definition: likely.h:25
#define CHECK(condition)
Definition: Logger.h:291
size_t g_watchdog_in_clause_max_num_elem_bitmap
Definition: Execute.cpp:86

+ Here is the caller graph for this function:

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

Definition at line 1366 of file RelAlgTranslator.cpp.

References CHECK, and kPLUS.

Referenced by RelAlgTranslator::translateDatePlusMinus().

1366  {
1367  CHECK(op == kPLUS);
1368  return "DATETIME_PLUS"s;
1369 }
Definition: sqldefs.h:43
#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 645 of file RelAlgTranslator.cpp.

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

Referenced by RelAlgTranslator::translateInOper().

646  {
648  return nullptr;
649  }
650  if (val_set.rowCount() > g_watchdog_in_clause_max_num_input_rows && g_enable_watchdog) {
651  std::ostringstream oss;
652  oss << "Unable to handle 'expr IN (subquery)': # input rows (" << val_set.rowCount()
653  << ") is larger than threshold 'g_watchdog_in_clause_max_num_input_rows':"
655  throw std::runtime_error(oss.str());
656  }
657  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
658  const size_t fetcher_count = cpu_threads();
659  std::vector<std::list<std::shared_ptr<Analyzer::Expr>>> expr_set(
660  fetcher_count, std::list<std::shared_ptr<Analyzer::Expr>>());
661  std::vector<std::future<void>> fetcher_threads;
662  const auto& ti = arg->get_type_info();
663  const auto entry_count = val_set.entryCount();
664  for (size_t i = 0,
665  start_entry = 0,
666  stride = (entry_count + fetcher_count - 1) / fetcher_count;
667  i < fetcher_count && start_entry < entry_count;
668  ++i, start_entry += stride) {
669  const auto end_entry = std::min(start_entry + stride, entry_count);
670  fetcher_threads.push_back(std::async(
672  [&](std::list<std::shared_ptr<Analyzer::Expr>>& in_vals,
673  const size_t start,
674  const size_t end) {
675  for (auto index = start; index < end; ++index) {
676  auto row = val_set.getRowAt(index);
677  if (row.empty()) {
678  continue;
679  }
680  auto scalar_tv = boost::get<ScalarTargetValue>(&row[0]);
681  Datum d{0};
682  bool is_null_const{false};
683  std::tie(d, is_null_const) = datum_from_scalar_tv(scalar_tv, ti);
684  if (ti.is_string() && ti.get_compression() != kENCODING_NONE) {
685  auto ti_none_encoded = ti;
686  ti_none_encoded.set_compression(kENCODING_NONE);
687  auto none_encoded_string =
688  makeExpr<Analyzer::Constant>(ti, is_null_const, d);
689  auto dict_encoded_string = std::make_shared<Analyzer::UOper>(
690  ti, false, kCAST, none_encoded_string);
691  in_vals.push_back(dict_encoded_string);
692  } else {
693  in_vals.push_back(makeExpr<Analyzer::Constant>(ti, is_null_const, d));
694  }
695  }
696  },
697  std::ref(expr_set[i]),
698  start_entry,
699  end_entry));
700  }
701  for (auto& child : fetcher_threads) {
702  child.get();
703  }
704 
705  val_set.moveToBegin();
706  for (auto& exprs : expr_set) {
707  value_exprs.splice(value_exprs.end(), exprs);
708  }
709  return makeExpr<Analyzer::InValues>(arg, value_exprs);
710 }
Definition: sqldefs.h:51
future< Result > async(Fn &&fn, Args &&...args)
bool g_enable_watchdog
size_t g_watchdog_in_clause_max_num_input_rows
Definition: Execute.cpp:87
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:71
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 269 of file RelAlgTranslator.cpp.

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

Referenced by RelAlgTranslator::translateAggregateRex().

269  {
270  return arg_ti.is_number() || arg_ti.is_boolean() || arg_ti.is_time() ||
271  (agg_kind == kMODE && arg_ti.is_string()) ||
272  !shared::is_any<kAVG, kMIN, kMAX, kSUM, kAPPROX_QUANTILE, kMODE>(agg_kind);
273 }
bool is_number() const
Definition: sqltypes.h:576
bool is_time() const
Definition: sqltypes.h:579
bool is_boolean() const
Definition: sqltypes.h:582
bool is_string() const
Definition: sqltypes.h:561
Definition: sqldefs.h:86

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

Referenced by RelAlgTranslator::translateAggregateRex().

275  {
276  return shared::is_any<kMIN, kMAX, kCOUNT, kAPPROX_COUNT_DISTINCT>(agg_kind);
277 }

+ Here is the caller graph for this function:

bool anonymous_namespace{RelAlgTranslator.cpp}::is_negative_framing_bound ( const SQLTypes  t,
const Datum d,
bool  is_time_unit = false 
)

Definition at line 2195 of file RelAlgTranslator.cpp.

References Datum::bigintval, CHECK, Datum::doubleval, Datum::intval, kBIGINT, kDECIMAL, kDOUBLE, kINT, kNUMERIC, kSMALLINT, kTINYINT, Datum::smallintval, and Datum::tinyintval.

Referenced by RelAlgTranslator::translateFrameBoundExpr(), and RelAlgTranslator::translateWindowFunction().

2197  {
2198  switch (t) {
2199  case kTINYINT:
2200  return d.tinyintval < 0;
2201  case kSMALLINT:
2202  return d.smallintval < 0;
2203  case kINT:
2204  return d.intval < 0;
2205  case kDOUBLE: {
2206  // the only case that double type is used is for handling time interval
2207  // i.e., represent tiny time units like nanosecond and microsecond as the
2208  // equivalent time value with SECOND time unit
2209  CHECK(is_time_unit);
2210  return d.doubleval < 0;
2211  }
2212  case kDECIMAL:
2213  case kNUMERIC:
2214  case kBIGINT:
2215  return d.bigintval < 0;
2216  default: {
2217  throw std::runtime_error(
2218  "We currently only support integer-type literal expression as a window "
2219  "frame bound expression");
2220  }
2221  }
2222 }
int8_t tinyintval
Definition: Datum.h:73
int32_t intval
Definition: Datum.h:75
int64_t bigintval
Definition: Datum.h:76
int16_t smallintval
Definition: Datum.h:74
#define CHECK(condition)
Definition: Logger.h:291
Definition: sqltypes.h:72
double doubleval
Definition: Datum.h:78

+ Here is the caller graph for this function:

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

Definition at line 188 of file RelAlgTranslator.cpp.

Referenced by RelAlgTranslator::translateScalarRex().

188  {
189  return {IndexedHandler{std::type_index(typeid(Ts)),
190  &RelAlgTranslator::translateRexScalar<Ts>}...};
191 }
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 1298 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().

1299  {
1300  CHECK(ti.is_number());
1301  Datum datum{0};
1302  switch (ti.get_type()) {
1303  case kTINYINT: {
1304  datum.tinyintval = val;
1305  break;
1306  }
1307  case kSMALLINT: {
1308  datum.smallintval = val;
1309  break;
1310  }
1311  case kINT: {
1312  datum.intval = val;
1313  break;
1314  }
1315  case kBIGINT: {
1316  datum.bigintval = val;
1317  break;
1318  }
1319  case kDECIMAL:
1320  case kNUMERIC: {
1321  datum.bigintval = val * exp_to_scale(ti.get_scale());
1322  break;
1323  }
1324  case kFLOAT: {
1325  datum.floatval = val;
1326  break;
1327  }
1328  case kDOUBLE: {
1329  datum.doubleval = val;
1330  break;
1331  }
1332  default:
1333  CHECK(false);
1334  }
1335  return makeExpr<Analyzer::Constant>(ti, false, datum);
1336 }
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:576
#define CHECK(condition)
Definition: Logger.h:291
uint64_t exp_to_scale(const unsigned exp)
Definition: sqltypes.h:72
Definition: Datum.h:71

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

References Descending, and First.

Referenced by RelAlgTranslator::translateWindowFunction().

2118  {
2119  std::vector<Analyzer::OrderEntry> collation;
2120  for (size_t i = 0; i < sort_fields.size(); ++i) {
2121  const auto& sort_field = sort_fields[i];
2122  collation.emplace_back(i,
2123  sort_field.getSortDir() == SortDirection::Descending,
2124  sort_field.getNullsPosition() == NullSortedPosition::First);
2125  }
2126  return collation;
2127 }

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

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

1273  {
1274  if (!literal_expr || literal_expr->get_is_null()) {
1275  throw std::runtime_error("The 'DatePart' argument must be a not 'null' literal.");
1276  }
1277 }

+ Here is the caller graph for this function: