OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Datum.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
23 #include <algorithm>
24 #include <cassert>
25 #include <cctype>
26 #include <charconv>
27 #include <cmath>
28 #include <cstdio>
29 #include <cstdlib>
30 #include <limits>
31 #include <stdexcept>
32 #include <string>
33 
34 #include "DateConverters.h"
35 #include "DateTimeParser.h"
36 #include "Logger/Logger.h"
38 #include "StringTransform.h"
39 #include "misc.h"
40 #include "sqltypes.h"
41 
42 std::string SQLTypeInfo::type_name[kSQLTYPE_LAST] = {"NULL",
43  "BOOLEAN",
44  "CHAR",
45  "VARCHAR",
46  "NUMERIC",
47  "DECIMAL",
48  "INTEGER",
49  "SMALLINT",
50  "FLOAT",
51  "DOUBLE",
52  "TIME",
53  "TIMESTAMP",
54  "BIGINT",
55  "TEXT",
56  "DATE",
57  "ARRAY",
58  "INTERVAL_DAY_TIME",
59  "INTERVAL_YEAR_MONTH",
60  "POINT",
61  "LINESTRING",
62  "POLYGON",
63  "MULTIPOLYGON",
64  "TINYINT",
65  "GEOMETRY",
66  "GEOGRAPHY",
67  "EVAL_CONTEXT_TYPE",
68  "VOID",
69  "CURSOR",
70  "COLUMN",
71  "COLUMN_LIST",
72  "MULTILINESTRING",
73  "MULTIPOINT"};
75  {"NONE", "FIXED", "RL", "DIFF", "DICT", "SPARSE", "COMPRESSED", "DAYS"};
76 
77 namespace {
78 // Return decimal_value * 10^dscale
79 int64_t convert_decimal_value_to_scale_internal(const int64_t decimal_value,
80  int const dscale) {
81  constexpr int max_scale = sql_constants::kMaxRepresentableNumericPrecision; // 19
82  constexpr auto pow10 = shared::powersOf<uint64_t, max_scale + 1>(10);
83  if (dscale < 0) {
84  if (dscale < -max_scale) {
85  return 0; // +/- 0.09223372036854775807 rounds to 0
86  }
87  uint64_t const u = std::abs(decimal_value);
88  uint64_t const pow = pow10[-dscale];
89  uint64_t div = u / pow;
90  uint64_t rem = u % pow;
91  div += pow / 2 <= rem;
92  return decimal_value < 0 ? -div : div;
93  } else if (dscale < max_scale) {
94  int64_t retval;
95 #ifdef _WIN32
96  return decimal_value * pow10[dscale];
97 #else
98  if (!__builtin_mul_overflow(decimal_value, pow10[dscale], &retval)) {
99  return retval;
100  }
101 #endif
102  }
103  if (decimal_value == 0) {
104  return 0;
105  }
106  throw std::runtime_error("Overflow in DECIMAL-to-DECIMAL conversion.");
107 }
108 } // namespace
109 
110 int64_t parse_numeric(const std::string_view s, SQLTypeInfo& ti) {
111  // if we are given a dimension, first parse to the maximum precision of the string
112  // and then convert to the correct size
113  if (ti.get_dimension() != 0) {
114  SQLTypeInfo ti_string(kNUMERIC, 0, 0, false);
115  return convert_decimal_value_to_scale(parse_numeric(s, ti_string), ti_string, ti);
116  }
117  size_t dot = s.find_first_of('.', 0);
118  std::string before_dot;
119  std::string after_dot;
120  if (dot != std::string::npos) {
121  // make .99 as 0.99, or std::stoll below throws exception 'std::invalid_argument'
122  before_dot = (0 == dot) ? "0" : s.substr(0, dot);
123  after_dot = s.substr(dot + 1);
124  } else {
125  before_dot = s;
126  after_dot = "0";
127  }
128  const bool is_negative = before_dot.find_first_of('-', 0) != std::string::npos;
129  const int64_t sign = is_negative ? -1 : 1;
130  int64_t result;
131  result = std::abs(std::stoll(before_dot));
132  int64_t fraction = 0;
133  const size_t before_dot_digits = before_dot.length() - (is_negative ? 1 : 0);
134 
135  constexpr int max_digits = std::numeric_limits<int64_t>::digits10;
136  if (!after_dot.empty()) {
137  int64_t next_digit = 0;
138  // After dot will be used to scale integer part so make sure it wont overflow
139  if (after_dot.size() + before_dot_digits > max_digits) {
140  if (before_dot_digits >= max_digits) {
141  after_dot = "0";
142  } else {
143  next_digit = std::stoll(after_dot.substr(max_digits - before_dot_digits, 1));
144  after_dot = after_dot.substr(0, max_digits - before_dot_digits);
145  }
146  }
147  fraction = std::stoll(after_dot);
148  fraction += next_digit >= 5 ? 1 : 0;
149  }
150 
151  // set the type info based on the literal string
152  ti.set_scale(static_cast<int>(after_dot.length()));
153  ti.set_dimension(static_cast<int>(before_dot_digits + ti.get_scale()));
154  ti.set_notnull(false);
155  if (ti.get_scale()) {
156  result = convert_decimal_value_to_scale_internal(result, ti.get_scale());
157  }
158  result += fraction;
159 
160  return result * sign;
161 }
162 
163 namespace {
164 
165 // Equal to NULL value for nullable types.
166 template <typename T>
167 T minValue(unsigned const fieldsize) {
168  static_assert(std::is_signed_v<T>);
169  return T(-1) << (fieldsize - 1);
170 }
171 
172 template <typename T>
173 T maxValue(unsigned const fieldsize) {
174  return ~minValue<T>(fieldsize);
175 }
176 
177 std::string toString(SQLTypeInfo const& ti, unsigned const fieldsize) {
178  return ti.get_type_name() + '(' + std::to_string(fieldsize) + ')';
179 }
180 
181 // GCC 10 does not support std::from_chars w/ double, so strtold() is used instead.
182 // Convert s to long double then round to integer type T.
183 // It's not assumed that long double is any particular size; it is to be nice to
184 // users who use floating point values where integers are expected. Some platforms
185 // may be more accommodating with larger long doubles than others.
186 template <typename T, typename U = long double>
187 T parseFloatAsInteger(std::string_view s, SQLTypeInfo const& ti) {
188  // Use stack memory if s is small enough before resorting to dynamic memory.
189  constexpr size_t bufsize = 64;
190  char c_str[bufsize];
191  std::string str;
192  char const* str_begin;
193  char* str_end;
194  if (s.size() < bufsize) {
195  s.copy(c_str, s.size());
196  c_str[s.size()] = '\0';
197  str_begin = c_str;
198  } else {
199  str = s;
200  str_begin = str.c_str();
201  }
202  U value = strtold(str_begin, &str_end);
203  if (str_begin == str_end) {
204  throw std::runtime_error("Unable to parse " + std::string(s) + " to " +
205  ti.get_type_name());
206  } else if (str_begin + s.size() != str_end) {
207  throw std::runtime_error(std::string("Unexpected character \"") + *str_end +
208  "\" encountered in " + ti.get_type_name() + " value " +
209  std::string(s));
210  }
211  value = std::round(value);
212  if (!std::isfinite(value)) {
213  throw std::runtime_error("Invalid conversion from \"" + std::string(s) + "\" to " +
214  ti.get_type_name());
215  } else if (value < static_cast<U>(std::numeric_limits<T>::min()) ||
216  static_cast<U>(std::numeric_limits<T>::max()) < value) {
217  throw std::runtime_error("Integer " + std::string(s) + " is out of range for " +
218  ti.get_type_name());
219  }
220  return static_cast<T>(value);
221 }
222 
223 // String ends in either "." or ".0".
224 inline bool hasCommonSuffix(char const* const ptr, char const* const end) {
225  return *ptr == '.' && (ptr + 1 == end || (ptr[1] == '0' && ptr + 2 == end));
226 }
227 
228 template <typename T>
229 T parseInteger(std::string_view s, SQLTypeInfo const& ti) {
230  T retval{0};
231  char const* const end = s.data() + s.size();
232  auto [ptr, error_code] = std::from_chars(s.data(), end, retval);
233  if (ptr != end) {
234  if (error_code != std::errc() || !hasCommonSuffix(ptr, end)) {
235  retval = parseFloatAsInteger<T>(s, ti);
236  }
237  } else if (error_code != std::errc()) {
238  if (error_code == std::errc::result_out_of_range) {
239  throw std::runtime_error("Integer " + std::string(s) + " is out of range for " +
240  ti.get_type_name());
241  }
242  throw std::runtime_error("Invalid conversion from \"" + std::string(s) + "\" to " +
243  ti.get_type_name());
244  }
245  // Bounds checking based on SQLTypeInfo.
246  unsigned const fieldsize =
247  ti.get_compression() == kENCODING_FIXED ? ti.get_comp_param() : 8 * sizeof(T);
248  if (fieldsize < 8 * sizeof(T)) {
249  if (maxValue<T>(fieldsize) < retval) {
250  throw std::runtime_error("Integer " + std::string(s) +
251  " exceeds maximum value for " + toString(ti, fieldsize));
252  } else if (ti.get_notnull()) {
253  if (retval < minValue<T>(fieldsize)) {
254  throw std::runtime_error("Integer " + std::string(s) +
255  " exceeds minimum value for " + toString(ti, fieldsize));
256  }
257  } else {
258  if (retval <= minValue<T>(fieldsize)) {
259  throw std::runtime_error("Integer " + std::string(s) +
260  " exceeds minimum value for nullable " +
261  toString(ti, fieldsize));
262  }
263  }
264  } else if (!ti.get_notnull() && retval == std::numeric_limits<T>::min()) {
265  throw std::runtime_error("Integer " + std::string(s) +
266  " exceeds minimum value for nullable " +
267  toString(ti, fieldsize));
268  }
269  return retval;
270 }
271 
273  SQLTypes type;
274  if (ti.is_decimal()) {
275  type = decimal_to_int_type(ti);
276  } else if (ti.is_dict_encoded_string()) {
277  type = string_dict_to_int_type(ti);
278  } else {
279  type = ti.get_type();
280  }
281  return type;
282 }
283 
284 } // namespace
285 
287  Datum d;
288  const auto type = get_type_for_datum(ti);
289  switch (type) {
290  case kBOOLEAN:
292  break;
293  case kBIGINT:
295  break;
296  case kINT:
298  break;
299  case kSMALLINT:
301  break;
302  case kTINYINT:
304  break;
305  case kFLOAT:
306  d.floatval = NULL_FLOAT;
307  break;
308  case kDOUBLE:
310  break;
311  case kTIME:
312  case kTIMESTAMP:
313  case kDATE:
315  break;
316  case kPOINT:
317  case kMULTIPOINT:
318  case kLINESTRING:
319  case kMULTILINESTRING:
320  case kPOLYGON:
321  case kMULTIPOLYGON:
322  throw std::runtime_error("Internal error: geometry type in NullDatum.");
323  default:
324  throw std::runtime_error("Internal error: invalid type in NullDatum.");
325  }
326  return d;
327 }
328 
329 bool IsNullDatum(const Datum datum, const SQLTypeInfo& ti) {
330  const Datum null_datum = NullDatum(ti);
331  return DatumEqual(datum, null_datum, ti);
332 }
333 
334 /*
335  * @brief convert string to a datum
336  */
337 Datum StringToDatum(const std::string_view s, SQLTypeInfo& ti) {
338  Datum d;
339  try {
340  switch (ti.get_type()) {
341  case kARRAY:
342  case kCOLUMN:
343  case kCOLUMN_LIST:
344  break;
345  case kBOOLEAN:
346  if (s == "t" || s == "T" || s == "1" || to_upper(std::string(s)) == "TRUE") {
347  d.boolval = true;
348  } else if (s == "f" || s == "F" || s == "0" ||
349  to_upper(std::string(s)) == "FALSE") {
350  d.boolval = false;
351  } else {
352  throw std::runtime_error("Invalid string for boolean " + std::string(s));
353  }
354  break;
355  case kNUMERIC:
356  case kDECIMAL:
357  d.bigintval = parse_numeric(s, ti);
358  break;
359  case kBIGINT:
360  d.bigintval = parseInteger<int64_t>(s, ti);
361  break;
362  case kINT:
363  d.intval = parseInteger<int32_t>(s, ti);
364  break;
365  case kSMALLINT:
366  d.smallintval = parseInteger<int16_t>(s, ti);
367  break;
368  case kTINYINT:
369  d.tinyintval = parseInteger<int8_t>(s, ti);
370  break;
371  case kFLOAT:
372  d.floatval = std::stof(std::string(s));
373  break;
374  case kDOUBLE:
375  d.doubleval = std::stod(std::string(s));
376  break;
377  case kTIME:
378  d.bigintval = dateTimeParse<kTIME>(s, ti.get_dimension());
379  break;
380  case kTIMESTAMP:
381  d.bigintval = dateTimeParse<kTIMESTAMP>(s, ti.get_dimension());
382  break;
383  case kDATE:
384  d.bigintval = dateTimeParse<kDATE>(s, ti.get_dimension());
385  break;
386  case kPOINT:
387  case kMULTIPOINT:
388  case kLINESTRING:
389  case kMULTILINESTRING:
390  case kPOLYGON:
391  case kMULTIPOLYGON:
392  throw std::runtime_error("Internal error: geometry type in StringToDatum.");
393  default:
394  throw std::runtime_error("Internal error: invalid type in StringToDatum: " +
395  ti.get_type_name());
396  }
397  } catch (const std::invalid_argument&) {
398  throw std::runtime_error("Invalid conversion from string to " + ti.get_type_name());
399  } catch (const std::out_of_range&) {
400  throw std::runtime_error("Got out of range error during conversion from string to " +
401  ti.get_type_name());
402  }
403  return d;
404 }
405 
406 bool DatumEqual(const Datum a, const Datum b, const SQLTypeInfo& ti) {
407  switch (ti.get_type()) {
408  case kBOOLEAN:
409  return a.boolval == b.boolval;
410  case kBIGINT:
411  case kNUMERIC:
412  case kDECIMAL:
413  return a.bigintval == b.bigintval;
414  case kINT:
415  return a.intval == b.intval;
416  case kSMALLINT:
417  return a.smallintval == b.smallintval;
418  case kTINYINT:
419  return a.tinyintval == b.tinyintval;
420  case kFLOAT:
421  return a.floatval == b.floatval;
422  case kDOUBLE:
423  return a.doubleval == b.doubleval;
424  case kTIME:
425  case kTIMESTAMP:
426  case kDATE:
427  case kINTERVAL_DAY_TIME:
429  return a.bigintval == b.bigintval;
430  case kTEXT:
431  case kVARCHAR:
432  case kCHAR:
433  case kPOINT:
434  case kMULTIPOINT:
435  case kLINESTRING:
436  case kMULTILINESTRING:
437  case kPOLYGON:
438  case kMULTIPOLYGON:
439  if (ti.get_compression() == kENCODING_DICT) {
440  return a.intval == b.intval;
441  }
442  if (a.stringval == nullptr && b.stringval == nullptr) {
443  return true;
444  }
445  if (a.stringval == nullptr || b.stringval == nullptr) {
446  return false;
447  }
448  return *a.stringval == *b.stringval;
449  default:
450  return false;
451  }
452  return false;
453 }
454 
455 /*
456  * @brief convert datum to string
457  */
458 std::string DatumToString(Datum d, const SQLTypeInfo& ti) {
459  constexpr size_t buf_size = 64;
460  char buf[buf_size]; // Hold "2000-03-01 12:34:56.123456789" and large years.
461  switch (ti.get_type()) {
462  case kBOOLEAN:
463  if (d.boolval) {
464  return "t";
465  }
466  return "f";
467  case kNUMERIC:
468  case kDECIMAL: {
469  double v = (double)d.bigintval / pow(10, ti.get_scale());
470  int size = snprintf(buf, buf_size, "%*.*f", ti.get_dimension(), ti.get_scale(), v);
471  CHECK_LE(0, size) << v << ' ' << ti.to_string();
472  CHECK_LT(size_t(size), buf_size) << v << ' ' << ti.to_string();
473  return buf;
474  }
475  case kINT:
476  return std::to_string(d.intval);
477  case kSMALLINT:
478  return std::to_string(d.smallintval);
479  case kTINYINT:
480  return std::to_string(d.tinyintval);
481  case kBIGINT:
482  return std::to_string(d.bigintval);
483  case kFLOAT:
484  return std::to_string(d.floatval);
485  case kDOUBLE:
486  return std::to_string(d.doubleval);
487  case kTIME: {
488  size_t const len = shared::formatHMS(buf, buf_size, d.bigintval);
489  CHECK_EQ(8u, len); // 8 == strlen("HH:MM:SS")
490  return buf;
491  }
492  case kTIMESTAMP: {
493  unsigned const dim = ti.get_dimension(); // assumes dim <= 9
494  size_t const len = shared::formatDateTime(buf, buf_size, d.bigintval, dim);
495  CHECK_LE(19u + bool(dim) + dim, len); // 19 = strlen("YYYY-MM-DD HH:MM:SS")
496  return buf;
497  }
498  case kDATE: {
499  size_t const len = shared::formatDate(buf, buf_size, d.bigintval);
500  CHECK_LE(10u, len); // 10 == strlen("YYYY-MM-DD")
501  return buf;
502  }
503  case kINTERVAL_DAY_TIME:
504  return std::to_string(d.bigintval) + " ms (day-time interval)";
506  return std::to_string(d.bigintval) + " month(s) (year-month interval)";
507  case kTEXT:
508  case kVARCHAR:
509  case kCHAR:
510  if (d.stringval == nullptr) {
511  return "NULL";
512  }
513  return *d.stringval;
514  default:
515  throw std::runtime_error("Internal error: invalid type " + ti.get_type_name() +
516  " in DatumToString.");
517  }
518  return "";
519 }
520 
521 int64_t extract_int_type_from_datum(const Datum datum, const SQLTypeInfo& ti) {
522  const auto type = ti.is_decimal() ? decimal_to_int_type(ti) : ti.get_type();
523  switch (type) {
524  case kBOOLEAN:
525  return datum.tinyintval;
526  case kTINYINT:
527  return datum.tinyintval;
528  case kSMALLINT:
529  return datum.smallintval;
530  case kCHAR:
531  case kVARCHAR:
532  case kTEXT:
534  case kINT:
535  return datum.intval;
536  case kBIGINT:
537  return datum.bigintval;
538  case kTIME:
539  case kTIMESTAMP:
540  case kDATE:
541  return datum.bigintval;
542  default:
543  abort();
544  }
545 }
546 
547 double extract_fp_type_from_datum(const Datum datum, const SQLTypeInfo& ti) {
548  const auto type = ti.get_type();
549  switch (type) {
550  case kFLOAT:
551  return datum.floatval;
552  case kDOUBLE:
553  return datum.doubleval;
554  default:
555  abort();
556  }
557 }
558 
560  return get_int_type_by_size(ti.get_size());
561 }
562 
565  switch (ti.get_size()) {
566  case 1:
567  return kTINYINT;
568  case 2:
569  return kSMALLINT;
570  case 4:
571  return kINT;
572  default:
573  UNREACHABLE() << "Unexpected string dictionary encoding size: " << ti.get_size();
574  }
575  return kNULLT;
576 }
577 
578 int8_t* append_datum(int8_t* buf, const Datum& d, const SQLTypeInfo& ti) {
579  SQLTypes type;
580  if (ti.is_dict_encoded_string()) {
581  type = string_dict_to_int_type(ti);
582  } else {
583  type = ti.get_type();
584  }
585  switch (type) {
586  case kBOOLEAN:
587  *(int8_t*)buf = d.boolval;
588  return buf + sizeof(int8_t);
589  case kNUMERIC:
590  case kDECIMAL:
591  case kBIGINT:
592  *(int64_t*)buf = d.bigintval;
593  return buf + sizeof(int64_t);
594  case kINT:
595  *(int32_t*)buf = d.intval;
596  return buf + sizeof(int32_t);
597  case kSMALLINT:
598  *(int16_t*)buf = d.smallintval;
599  return buf + sizeof(int16_t);
600  case kTINYINT:
601  *(int8_t*)buf = d.tinyintval;
602  return buf + sizeof(int8_t);
603  case kFLOAT:
604  *(float*)buf = d.floatval;
605  return buf + sizeof(float);
606  case kDOUBLE:
607  *(double*)buf = d.doubleval;
608  return buf + sizeof(double);
609  case kTIME:
610  case kTIMESTAMP:
611  case kDATE:
612  *reinterpret_cast<int64_t*>(buf) = d.bigintval;
613  return buf + sizeof(int64_t);
614  default:
615  UNREACHABLE() << "Unexpected type: " << type;
616  return nullptr;
617  }
618 }
619 
620 // Return decimal_value * 10^dscale
621 // where dscale = new_type_info.get_scale() - type_info.get_scale()
622 int64_t convert_decimal_value_to_scale(const int64_t decimal_value,
623  const SQLTypeInfo& type_info,
624  const SQLTypeInfo& new_type_info) {
625  int const dscale = new_type_info.get_scale() - type_info.get_scale();
626  return convert_decimal_value_to_scale_internal(decimal_value, dscale);
627 }
int8_t tinyintval
Definition: Datum.h:69
static constexpr int32_t kMaxRepresentableNumericPrecision
Definition: sqltypes.h:50
#define CHECK_EQ(x, y)
Definition: Logger.h:301
#define NULL_DOUBLE
HOST DEVICE int get_size() const
Definition: sqltypes.h:393
int8_t * append_datum(int8_t *buf, const Datum &d, const SQLTypeInfo &ti)
Definition: Datum.cpp:578
std::string DatumToString(Datum d, const SQLTypeInfo &ti)
Definition: Datum.cpp:458
Definition: sqltypes.h:66
T parseInteger(std::string_view s, SQLTypeInfo const &ti)
Definition: Datum.cpp:229
T maxValue(unsigned const fieldsize)
Definition: Datum.cpp:173
SQLTypes
Definition: sqltypes.h:55
int64_t parse_numeric(const std::string_view s, SQLTypeInfo &ti)
Definition: Datum.cpp:110
#define NULL_FLOAT
HOST DEVICE int get_scale() const
Definition: sqltypes.h:386
int8_t boolval
Definition: Datum.h:68
#define UNREACHABLE()
Definition: Logger.h:337
Constants for Builtin SQL Types supported by HEAVY.AI.
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
int32_t intval
Definition: Datum.h:71
std::string to_string(char const *&&v)
size_t formatHMS(char *buf, size_t const max, int64_t const unixtime)
Definition: misc.cpp:96
constexpr double a
Definition: Utm.h:32
float floatval
Definition: Datum.h:73
std::string to_string() const
Definition: sqltypes.h:547
T minValue(unsigned const fieldsize)
Definition: Datum.cpp:167
bool DatumEqual(const Datum a, const Datum b, const SQLTypeInfo &ti)
Definition: Datum.cpp:406
static std::string type_name[kSQLTYPE_LAST]
Definition: sqltypes.h:1045
int64_t extract_int_type_from_datum(const Datum datum, const SQLTypeInfo &ti)
Definition: Datum.cpp:521
void set_scale(int s)
Definition: sqltypes.h:498
int64_t bigintval
Definition: Datum.h:72
int16_t smallintval
Definition: Datum.h:70
Datum StringToDatum(const std::string_view s, SQLTypeInfo &ti)
Definition: Datum.cpp:337
std::string toString(const ExecutorDeviceType &device_type)
bool IsNullDatum(const Datum datum, const SQLTypeInfo &ti)
Definition: Datum.cpp:329
Datum NullDatum(const SQLTypeInfo &ti)
Definition: Datum.cpp:286
std::string * stringval
Definition: Datum.h:77
std::string to_upper(const std::string &str)
SQLTypes decimal_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:559
size_t formatDate(char *buf, size_t const max, int64_t const unixtime)
Definition: misc.cpp:27
#define CHECK_LT(x, y)
Definition: Logger.h:303
Definition: sqltypes.h:69
Definition: sqltypes.h:70
static std::string comp_name[kENCODING_LAST]
Definition: sqltypes.h:1046
#define CHECK_LE(x, y)
Definition: Logger.h:304
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:389
int64_t convert_decimal_value_to_scale(const int64_t decimal_value, const SQLTypeInfo &type_info, const SQLTypeInfo &new_type_info)
Definition: Datum.cpp:622
void set_dimension(int d)
Definition: sqltypes.h:495
SQLTypes get_int_type_by_size(size_t const nbytes)
Definition: sqltypes.h:1217
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:383
std::string get_type_name() const
Definition: sqltypes.h:507
size_t formatDateTime(char *buf, size_t const max, int64_t const timestamp, int const dimension, bool use_iso_format)
Definition: misc.cpp:45
Definition: sqltypes.h:58
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:392
void set_notnull(bool n)
Definition: sqltypes.h:500
#define CHECK(condition)
Definition: Logger.h:291
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)
int64_t convert_decimal_value_to_scale_internal(const int64_t decimal_value, int const dscale)
Definition: Datum.cpp:79
double extract_fp_type_from_datum(const Datum datum, const SQLTypeInfo &ti)
Definition: Datum.cpp:547
bool is_dict_encoded_string() const
Definition: sqltypes.h:632
Definition: sqltypes.h:62
bool hasCommonSuffix(char const *const ptr, char const *const end)
Definition: Datum.cpp:224
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:388
SQLTypes get_type_for_datum(const SQLTypeInfo &ti)
Definition: Importer.cpp:259
Definition: Datum.h:67
bool is_decimal() const
Definition: sqltypes.h:583
T parseFloatAsInteger(std::string_view s, SQLTypeInfo const &ti)
Definition: Datum.cpp:187
double doubleval
Definition: Datum.h:74
SQLTypes string_dict_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:563