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