OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sqltypes.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020 OmniSci, 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 #pragma once
24 
25 #include "../Logger/Logger.h"
26 #include "funcannotations.h"
27 
28 #include <cassert>
29 #include <ctime>
30 #include <memory>
31 #include <ostream>
32 #include <sstream>
33 #include <string>
34 #include <type_traits>
35 #include <vector>
36 
37 // must not change because these values persist in catalogs.
38 enum SQLTypes {
39  kNULLT = 0, // type for null values
40  kBOOLEAN = 1,
41  kCHAR = 2,
42  kVARCHAR = 3,
43  kNUMERIC = 4,
44  kDECIMAL = 5,
45  kINT = 6,
46  kSMALLINT = 7,
47  kFLOAT = 8,
48  kDOUBLE = 9,
49  kTIME = 10,
50  kTIMESTAMP = 11,
51  kBIGINT = 12,
52  kTEXT = 13,
53  kDATE = 14,
54  kARRAY = 15,
57  kPOINT = 18,
59  kPOLYGON = 20,
61  kTINYINT = 22,
62  kGEOMETRY = 23,
63  kGEOGRAPHY = 24,
64  kEVAL_CONTEXT_TYPE = 25, // Placeholder Type for ANY
65  kVOID = 26,
66  kCURSOR = 27,
67  kCOLUMN = 28,
70 };
71 
72 #if !(defined(__CUDACC__) || defined(NO_BOOST))
73 
74 inline std::string toString(const SQLTypes& type) {
75  switch (type) {
76  case kNULLT:
77  return "NULL";
78  case kBOOLEAN:
79  return "BOOL";
80  case kCHAR:
81  return "CHAR";
82  case kVARCHAR:
83  return "VARCHAR";
84  case kNUMERIC:
85  return "NUMERIC";
86  case kDECIMAL:
87  return "DECIMAL";
88  case kINT:
89  return "INT";
90  case kSMALLINT:
91  return "SMALLINT";
92  case kFLOAT:
93  return "FLOAT";
94  case kDOUBLE:
95  return "DOUBLE";
96  case kTIME:
97  return "TIME";
98  case kTIMESTAMP:
99  return "TIMESTAMP";
100  case kBIGINT:
101  return "BIGINT";
102  case kTEXT:
103  return "TEXT";
104  case kDATE:
105  return "DATE";
106  case kARRAY:
107  return "ARRAY";
108  case kINTERVAL_DAY_TIME:
109  return "DAY TIME INTERVAL";
111  return "YEAR MONTH INTERVAL";
112  case kPOINT:
113  return "POINT";
114  case kLINESTRING:
115  return "LINESTRING";
116  case kPOLYGON:
117  return "POLYGON";
118  case kMULTIPOLYGON:
119  return "MULTIPOLYGON";
120  case kTINYINT:
121  return "TINYINT";
122  case kGEOMETRY:
123  return "GEOMETRY";
124  case kGEOGRAPHY:
125  return "GEOGRAPHY";
126  case kEVAL_CONTEXT_TYPE:
127  return "UNEVALUATED ANY";
128  case kVOID:
129  return "VOID";
130  case kCURSOR:
131  return "CURSOR";
132  case kCOLUMN:
133  return "COLUMN";
134  case kCOLUMN_LIST:
135  return "COLUMN_LIST";
136  case kSQLTYPE_LAST:
137  break;
138  }
139  LOG(FATAL) << "Invalid SQL type: " << type;
140  return "";
141 }
142 
143 inline std::ostream& operator<<(std::ostream& os, SQLTypes const sql_type) {
144  os << toString(sql_type);
145  return os;
146 }
147 
148 #endif // #if !(defined(__CUDACC__) || defined(NO_BOOST))
149 
150 struct VarlenDatum {
151  size_t length;
152  int8_t* pointer;
153  bool is_null;
154 
155  DEVICE VarlenDatum() : length(0), pointer(nullptr), is_null(true) {}
156  DEVICE virtual ~VarlenDatum() {}
157 
158  VarlenDatum(const size_t l, int8_t* p, const bool n)
159  : length(l), pointer(p), is_null(n) {}
160 };
161 
163  void operator()(int8_t*) {}
164 };
165 struct FreeDeleter {
166  void operator()(int8_t* p) { free(p); }
167 };
168 
169 struct HostArrayDatum : public VarlenDatum {
170  using ManagedPtr = std::shared_ptr<int8_t>;
171 
172  HostArrayDatum() = default;
173 
174  HostArrayDatum(size_t const l, ManagedPtr p, bool const n)
175  : VarlenDatum(l, p.get(), n), data_ptr(p) {}
176 
177  HostArrayDatum(size_t const l, int8_t* p, bool const n)
178  : VarlenDatum(l, p, n), data_ptr(p, FreeDeleter()){};
179 
180  template <typename CUSTOM_DELETER,
181  typename = std::enable_if_t<
182  std::is_void<std::result_of_t<CUSTOM_DELETER(int8_t*)> >::value> >
183  HostArrayDatum(size_t const l, int8_t* p, CUSTOM_DELETER custom_deleter)
184  : VarlenDatum(l, p, 0 == l), data_ptr(p, custom_deleter) {}
185 
186  template <typename CUSTOM_DELETER,
187  typename = std::enable_if_t<
188  std::is_void<std::result_of_t<CUSTOM_DELETER(int8_t*)> >::value> >
189  HostArrayDatum(size_t const l, int8_t* p, bool const n, CUSTOM_DELETER custom_deleter)
190  : VarlenDatum(l, p, n), data_ptr(p, custom_deleter) {}
191 
193 };
194 
195 struct DeviceArrayDatum : public VarlenDatum {
197 };
198 
199 inline DEVICE constexpr bool is_cuda_compiler() {
200 #ifdef __CUDACC__
201  return true;
202 #else
203  return false;
204 #endif
205 }
206 
207 using ArrayDatum =
208  std::conditional_t<is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum>;
209 
210 union Datum {
211  int8_t boolval;
212  int8_t tinyintval;
213  int16_t smallintval;
214  int32_t intval;
215  int64_t bigintval;
216  float floatval;
217  double doubleval;
219 #ifndef __CUDACC__
220  std::string* stringval; // string value
221 #endif
222 };
223 
224 #ifndef __CUDACC__
226  int8_t* numbersPtr;
227  std::vector<std::string>* stringsPtr;
228  std::vector<ArrayDatum>* arraysPtr;
229 };
230 #endif
231 
232 // must not change because these values persist in catalogs.
234  kENCODING_NONE = 0, // no encoding
235  kENCODING_FIXED = 1, // Fixed-bit encoding
236  kENCODING_RL = 2, // Run Length encoding
237  kENCODING_DIFF = 3, // Differential encoding
238  kENCODING_DICT = 4, // Dictionary encoding
239  kENCODING_SPARSE = 5, // Null encoding for sparse columns
240  kENCODING_GEOINT = 6, // Encoding coordinates as intergers
241  kENCODING_DATE_IN_DAYS = 7, // Date encoding in days
243 };
244 
245 #define IS_INTEGER(T) \
246  (((T) == kINT) || ((T) == kSMALLINT) || ((T) == kBIGINT) || ((T) == kTINYINT))
247 #define IS_NUMBER(T) \
248  (((T) == kINT) || ((T) == kSMALLINT) || ((T) == kDOUBLE) || ((T) == kFLOAT) || \
249  ((T) == kBIGINT) || ((T) == kNUMERIC) || ((T) == kDECIMAL) || ((T) == kTINYINT))
250 #define IS_STRING(T) (((T) == kTEXT) || ((T) == kVARCHAR) || ((T) == kCHAR))
251 #define IS_GEO(T) \
252  (((T) == kPOINT) || ((T) == kLINESTRING) || ((T) == kPOLYGON) || ((T) == kMULTIPOLYGON))
253 #define IS_INTERVAL(T) ((T) == kINTERVAL_DAY_TIME || (T) == kINTERVAL_YEAR_MONTH)
254 #define IS_DECIMAL(T) ((T) == kNUMERIC || (T) == kDECIMAL)
255 #define IS_GEO_POLY(T) (((T) == kPOLYGON) || ((T) == kMULTIPOLYGON))
256 
257 #include "InlineNullValues.h"
258 
259 #define TRANSIENT_DICT_ID 0
260 #define TRANSIENT_DICT(ID) (-(ID))
261 #define REGULAR_DICT(TRANSIENTID) (-(TRANSIENTID))
262 
263 constexpr auto is_datetime(SQLTypes type) {
264  return type == kTIME || type == kTIMESTAMP || type == kDATE;
265 }
266 
267 // @type SQLTypeInfo
268 // @brief a structure to capture all type information including
269 // length, precision, scale, etc.
270 class SQLTypeInfo {
271  public:
272  SQLTypeInfo(SQLTypes t, int d, int s, bool n, EncodingType c, int p, SQLTypes st)
273  : type(t)
274  , subtype(st)
275  , dimension(d)
276  , scale(s)
277  , notnull(n)
278  , compression(c)
279  , comp_param(p)
280  , size(get_storage_size()) {}
281  SQLTypeInfo(SQLTypes t, int d, int s, bool n)
282  : type(t)
283  , subtype(kNULLT)
284  , dimension(d)
285  , scale(s)
286  , notnull(n)
288  , comp_param(0)
289  , size(get_storage_size()) {}
291  : type(t)
292  , subtype(st)
293  , dimension(0)
294  , scale(0)
295  , notnull(false)
296  , compression(c)
297  , comp_param(p)
298  , size(get_storage_size()) {}
299  SQLTypeInfo(SQLTypes t, int d, int s) : SQLTypeInfo(t, d, s, false) {}
301  : type(t)
302  , subtype(kNULLT)
303  , dimension(0)
304  , scale(0)
305  , notnull(n)
307  , comp_param(0)
308  , size(get_storage_size()) {}
311  : type(t)
312  , subtype(kNULLT)
313  , dimension(0)
314  , scale(0)
315  , notnull(n)
316  , compression(c)
317  , comp_param(0)
318  , size(get_storage_size()) {}
320  : type(kNULLT)
321  , subtype(kNULLT)
322  , dimension(0)
323  , scale(0)
324  , notnull(false)
326  , comp_param(0)
327  , size(0) {}
328 
329  HOST DEVICE inline SQLTypes get_type() const { return type; }
330  HOST DEVICE inline SQLTypes get_subtype() const { return subtype; }
331  HOST DEVICE inline int get_dimension() const { return dimension; }
332  inline int get_precision() const { return dimension; }
333  HOST DEVICE inline int get_input_srid() const { return dimension; }
334  HOST DEVICE inline int get_scale() const { return scale; }
335  HOST DEVICE inline int get_output_srid() const { return scale; }
336  HOST DEVICE inline bool get_notnull() const { return notnull; }
338  HOST DEVICE inline int get_comp_param() const { return comp_param; }
339  HOST DEVICE inline int get_size() const { return size; }
340 
341  inline int is_logical_geo_type() const {
342  if (type == kPOINT || type == kLINESTRING || type == kPOLYGON ||
343  type == kMULTIPOLYGON) {
344  return true;
345  }
346  return false;
347  }
348 
349  inline int get_logical_size() const {
352  return ti.get_size();
353  }
354  if (compression == kENCODING_DICT) {
355  return 4;
356  }
357  return get_size();
358  }
359 
360  inline int get_physical_cols() const {
361  switch (type) {
362  case kPOINT:
363  return 1; // coords
364  case kLINESTRING:
365  return 2; // coords, bounds
366  case kPOLYGON:
367  return 4; // coords, ring_sizes, bounds, render_group
368  case kMULTIPOLYGON:
369  return 5; // coords, ring_sizes, poly_rings, bounds, render_group
370  default:
371  break;
372  }
373  return 0;
374  }
375  inline int get_physical_coord_cols() const {
376  // @TODO dmitri/simon rename this function?
377  // It needs to return the number of extra columns
378  // which need to go through the executor, as opposed
379  // to those which are only needed by CPU for poly
380  // cache building or what-not. For now, we just omit
381  // the Render Group column. If we add Bounding Box
382  // or something this may require rethinking. Perhaps
383  // these two functions need to return an array of
384  // offsets rather than just a number to loop over,
385  // so that executor and non-executor columns can
386  // be mixed.
387  // NOTE(adb): In binding to extension functions, we need to know some pretty specific
388  // type info about each of the physical coords cols for each geo type. I added checks
389  // there to ensure the physical coords col for the geo type match what we expect. If
390  // these values are ever changed, corresponding values in
391  // ExtensionFunctionsBinding.cpp::compute_narrowing_conv_scores and
392  // ExtensionFunctionsBinding.cpp::compute_widening_conv_scores will also need to be
393  // changed.
394  switch (type) {
395  case kPOINT:
396  return 1;
397  case kLINESTRING:
398  return 1; // omit bounds
399  case kPOLYGON:
400  return 2; // omit bounds, render group
401  case kMULTIPOLYGON:
402  return 3; // omit bounds, render group
403  default:
404  break;
405  }
406  return 0;
407  }
408  inline bool has_bounds() const {
409  switch (type) {
410  case kLINESTRING:
411  case kPOLYGON:
412  case kMULTIPOLYGON:
413  return true;
414  default:
415  break;
416  }
417  return false;
418  }
419  inline bool has_render_group() const {
420  switch (type) {
421  case kPOLYGON:
422  case kMULTIPOLYGON:
423  return true;
424  default:
425  break;
426  }
427  return false;
428  }
429  HOST DEVICE inline void set_type(SQLTypes t) { type = t; }
430  HOST DEVICE inline void set_subtype(SQLTypes st) { subtype = st; }
431  inline void set_dimension(int d) { dimension = d; }
432  inline void set_precision(int d) { dimension = d; }
433  inline void set_input_srid(int d) { dimension = d; }
434  inline void set_scale(int s) { scale = s; }
435  inline void set_output_srid(int s) { scale = s; }
436  inline void set_notnull(bool n) { notnull = n; }
437  inline void set_size(int s) { size = s; }
438  inline void set_fixed_size() { size = get_storage_size(); }
439  inline void set_dict_intersection() { dict_intersection = true; }
440  inline void set_compression(EncodingType c) { compression = c; }
441  inline void set_comp_param(int p) { comp_param = p; }
442 #ifndef __CUDACC__
443  inline std::string get_type_name() const {
444  if (IS_GEO(type)) {
445  std::string srid_string = "";
446  if (get_output_srid() > 0) {
447  srid_string = ", " + std::to_string(get_output_srid());
448  }
449  CHECK_LT(static_cast<int>(subtype), kSQLTYPE_LAST);
450  return type_name[static_cast<int>(subtype)] + "(" +
451  type_name[static_cast<int>(type)] + srid_string + ")";
452  }
453  std::string ps = "";
454  if (type == kDECIMAL || type == kNUMERIC) {
455  ps = "(" + std::to_string(dimension) + "," + std::to_string(scale) + ")";
456  } else if (type == kTIMESTAMP) {
457  ps = "(" + std::to_string(dimension) + ")";
458  }
459  if (type == kARRAY) {
460  auto elem_ti = get_elem_type();
461  auto num_elems = (size > 0) ? std::to_string(size / elem_ti.get_size()) : "";
462  CHECK_LT(static_cast<int>(subtype), kSQLTYPE_LAST);
463  return elem_ti.get_type_name() + ps + "[" + num_elems + "]";
464  }
465  if (type == kCOLUMN) {
466  auto elem_ti = get_elem_type();
467  auto num_elems =
468  (size > 0) ? "[" + std::to_string(size / elem_ti.get_size()) + "]" : "";
469  CHECK_LT(static_cast<int>(subtype), kSQLTYPE_LAST);
470  return "COLUMN<" + type_name[static_cast<int>(subtype)] + ps + ">" + num_elems;
471  }
472  if (type == kCOLUMN_LIST) {
473  auto elem_ti = get_elem_type();
474  auto num_elems =
475  (size > 0) ? "[" + std::to_string(size / elem_ti.get_size()) + "]" : "";
476  CHECK_LT(static_cast<int>(subtype), kSQLTYPE_LAST);
477  return "COLUMN_LIST<" + type_name[static_cast<int>(subtype)] + ps + ">" + num_elems;
478  }
479  return type_name[static_cast<int>(type)] + ps;
480  }
481  inline std::string get_compression_name() const { return comp_name[(int)compression]; }
482  std::string toString() const { return to_string(); } // for PRINT macro
483  inline std::string to_string() const {
484  std::ostringstream oss;
485  oss << "(type=" << type_name[static_cast<int>(type)]
486  << ", dimension=" << get_dimension() << ", scale=" << get_scale()
487  << ", null=" << (get_notnull() ? "not nullable" : "nullable")
488  << ", name=" << get_compression_name() << ", comp=" << get_comp_param()
489  << ", subtype=" << type_name[static_cast<int>(subtype)] << ", size=" << get_size()
490  << ", element_size=" << get_elem_type().get_size() << ")";
491  return oss.str();
492  }
493 
494  inline std::string get_buffer_name() const {
495  if (is_array()) {
496  return "Array";
497  }
498  if (is_bytes()) {
499  return "Bytes";
500  }
501 
502  if (is_column()) {
503  return "Column";
504  }
505 
506  assert(false);
507  return "";
508  }
509 #endif
510  inline bool is_string() const { return IS_STRING(type); }
511  inline bool is_string_array() const { return (type == kARRAY) && IS_STRING(subtype); }
512  inline bool is_integer() const { return IS_INTEGER(type); }
513  inline bool is_decimal() const { return type == kDECIMAL || type == kNUMERIC; }
514  inline bool is_fp() const { return type == kFLOAT || type == kDOUBLE; }
515  inline bool is_number() const { return IS_NUMBER(type); }
516  inline bool is_time() const { return is_datetime(type); }
517  inline bool is_boolean() const { return type == kBOOLEAN; }
518  inline bool is_array() const { return type == kARRAY; } // rbc Array
519  inline bool is_varlen_array() const { return type == kARRAY && size <= 0; }
520  inline bool is_fixlen_array() const { return type == kARRAY && size > 0; }
521  inline bool is_timeinterval() const { return IS_INTERVAL(type); }
522  inline bool is_geometry() const { return IS_GEO(type); }
523  inline bool is_column() const { return type == kCOLUMN; } // rbc Column
524  inline bool is_column_list() const { return type == kCOLUMN_LIST; } // rbc ColumnList
525  inline bool is_bytes() const {
526  return type == kTEXT && get_compression() == kENCODING_NONE;
527  } // rbc Bytes
528  inline bool is_buffer() const {
529  return is_array() || is_column() || is_column_list() || is_bytes();
530  }
531  inline bool transforms() const {
532  return IS_GEO(type) && get_input_srid() > 0 && get_output_srid() > 0 &&
534  }
535 
536  inline bool is_varlen() const { // TODO: logically this should ignore fixlen arrays
537  return (IS_STRING(type) && compression != kENCODING_DICT) || type == kARRAY ||
538  IS_GEO(type);
539  }
540 
541  // need this here till is_varlen can be fixed w/o negative impact to existing code
542  inline bool is_varlen_indeed() const {
543  // SQLTypeInfo.is_varlen() is broken with fixedlen array now
544  // and seems left broken for some concern, so fix it locally
545  return is_varlen() && !is_fixlen_array();
546  }
547 
548  inline bool is_dict_encoded_string() const {
549  return is_string() && compression == kENCODING_DICT;
550  }
551 
552  inline bool is_none_encoded_string() const {
553  return is_string() && compression == kENCODING_NONE;
554  }
555 
556  inline bool is_subtype_dict_encoded_string() const {
558  }
559 
560  inline bool is_dict_encoded_type() const {
561  return is_dict_encoded_string() ||
563  }
564 
565  inline bool is_dict_intersection() const { return dict_intersection; }
566 
567  HOST DEVICE inline bool operator!=(const SQLTypeInfo& rhs) const {
568  return type != rhs.get_type() || subtype != rhs.get_subtype() ||
569  dimension != rhs.get_dimension() || scale != rhs.get_scale() ||
570  compression != rhs.get_compression() ||
573  notnull != rhs.get_notnull();
574  }
575  HOST DEVICE inline bool operator==(const SQLTypeInfo& rhs) const {
576  return type == rhs.get_type() && subtype == rhs.get_subtype() &&
577  dimension == rhs.get_dimension() && scale == rhs.get_scale() &&
578  compression == rhs.get_compression() &&
581  notnull == rhs.get_notnull();
582  }
583 
584  inline int get_array_context_logical_size() const {
585  if (is_string()) {
586  auto comp_type(get_compression());
587  if (comp_type == kENCODING_DICT || comp_type == kENCODING_FIXED ||
588  comp_type == kENCODING_NONE) {
589  return sizeof(int32_t);
590  }
591  }
592  return get_logical_size();
593  }
594 
595  HOST DEVICE inline void operator=(const SQLTypeInfo& rhs) {
596  type = rhs.get_type();
597  subtype = rhs.get_subtype();
598  dimension = rhs.get_dimension();
599  scale = rhs.get_scale();
600  notnull = rhs.get_notnull();
602  comp_param = rhs.get_comp_param();
603  size = rhs.get_size();
604  }
605 
606  inline bool is_castable(const SQLTypeInfo& new_type_info) const {
607  // can always cast between the same type but different precision/scale/encodings
608  if (type == new_type_info.get_type()) {
609  return true;
610  // can always cast between strings
611  } else if (is_string() && new_type_info.is_string()) {
612  return true;
613  } else if (is_string() && !new_type_info.is_string()) {
614  return false;
615  } else if (!is_string() && new_type_info.is_string()) {
616  return false;
617  // can cast between numbers
618  } else if (is_number() && new_type_info.is_number()) {
619  return true;
620  // can cast from timestamp or date to number (epoch)
621  } else if ((type == kTIMESTAMP || type == kDATE) && new_type_info.is_number()) {
622  return true;
623  // can cast from number (epoch) to timestamp, date, or time
624  } else if (is_number() && new_type_info.is_time()) {
625  return true;
626  // can cast from date to timestamp
627  } else if (type == kDATE && new_type_info.get_type() == kTIMESTAMP) {
628  return true;
629  } else if (type == kTIMESTAMP && new_type_info.get_type() == kDATE) {
630  return true;
631  } else if (type == kBOOLEAN && new_type_info.is_number()) {
632  return true;
633  } else if (type == kARRAY && new_type_info.get_type() == kARRAY) {
634  return get_elem_type().is_castable(new_type_info.get_elem_type());
635  } else if (type == kCOLUMN && new_type_info.get_type() == kCOLUMN) {
636  return get_elem_type().is_castable(new_type_info.get_elem_type());
637  } else if (type == kCOLUMN_LIST && new_type_info.get_type() == kCOLUMN_LIST) {
638  return get_elem_type().is_castable(new_type_info.get_elem_type());
639  } else {
640  return false;
641  }
642  }
643 
652  inline bool is_numeric_scalar_auto_castable(const SQLTypeInfo& new_type_info) const {
653  const auto& new_type = new_type_info.get_type();
654  switch (type) {
655  case kBOOLEAN:
656  return new_type == kBOOLEAN;
657  case kTINYINT:
658  case kSMALLINT:
659  case kINT:
660  if (!new_type_info.is_number()) {
661  return false;
662  }
663  if (new_type_info.is_fp()) {
664  // We can lose precision here, but preserving existing behavior
665  return true;
666  }
667  return new_type_info.get_logical_size() >= get_logical_size();
668  case kBIGINT:
669  return new_type == kBIGINT || new_type == kDOUBLE || new_type == kFLOAT;
670  case kFLOAT:
671  case kDOUBLE:
672  if (!new_type_info.is_fp()) {
673  return false;
674  }
675  return (new_type_info.get_logical_size() >= get_logical_size());
676  case kDECIMAL:
677  case kNUMERIC:
678  switch (new_type) {
679  case kDECIMAL:
680  case kNUMERIC:
681  return new_type_info.get_dimension() >= get_dimension();
682  case kDOUBLE:
683  return true;
684  case kFLOAT:
685  return get_dimension() <= 7;
686  default:
687  return false;
688  }
689  case kTIMESTAMP:
690  if (new_type != kTIMESTAMP) {
691  return false;
692  }
693  return new_type_info.get_dimension() >= get_dimension();
694  case kDATE:
695  return new_type == kDATE;
696  case kTIME:
697  return new_type == kTIME;
698  default:
699  UNREACHABLE();
700  return false;
701  }
702  }
703 
713  inline int32_t get_numeric_scalar_scale() const {
714  CHECK(type == kBOOLEAN || type == kTINYINT || type == kSMALLINT || type == kINT ||
715  type == kBIGINT || type == kFLOAT || type == kDOUBLE || type == kDECIMAL ||
716  type == kNUMERIC || type == kTIMESTAMP || type == kDATE || type == kTIME);
717  switch (type) {
718  case kBOOLEAN:
719  return 1;
720  case kTINYINT:
721  case kSMALLINT:
722  case kINT:
723  case kBIGINT:
724  case kFLOAT:
725  case kDOUBLE:
726  return get_logical_size();
727  case kDECIMAL:
728  case kNUMERIC:
729  if (get_dimension() > 7) {
730  return 8;
731  } else {
732  return 4;
733  }
734  case kTIMESTAMP:
735  switch (get_dimension()) {
736  case 9:
737  return 8;
738  case 6:
739  return 4;
740  case 3:
741  return 2;
742  case 0:
743  return 1;
744  default:
745  UNREACHABLE();
746  }
747  case kDATE:
748  return 1;
749  case kTIME:
750  return 1;
751  default:
752  UNREACHABLE();
753  return 0;
754  }
755  }
756 
757  HOST DEVICE inline bool is_null(const Datum& d) const {
758  // assuming Datum is always uncompressed
759  switch (type) {
760  case kBOOLEAN:
761  return (int8_t)d.boolval == NULL_BOOLEAN;
762  case kTINYINT:
763  return d.tinyintval == NULL_TINYINT;
764  case kSMALLINT:
765  return d.smallintval == NULL_SMALLINT;
766  case kINT:
767  return d.intval == NULL_INT;
768  case kBIGINT:
769  case kNUMERIC:
770  case kDECIMAL:
771  return d.bigintval == NULL_BIGINT;
772  case kFLOAT:
773  return d.floatval == NULL_FLOAT;
774  case kDOUBLE:
775  return d.doubleval == NULL_DOUBLE;
776  case kTIME:
777  case kTIMESTAMP:
778  case kDATE:
779  return d.bigintval == NULL_BIGINT;
780  case kTEXT:
781  case kVARCHAR:
782  case kCHAR:
783  // @TODO handle null strings
784  break;
785  case kNULLT:
786  return true;
787  case kARRAY:
788  return d.arrayval == NULL || d.arrayval->is_null;
789  default:
790  break;
791  }
792  return false;
793  }
794  HOST DEVICE inline bool is_null(const int8_t* val) const {
795  if (type == kFLOAT) {
796  return *(float*)val == NULL_FLOAT;
797  }
798  if (type == kDOUBLE) {
799  return *(double*)val == NULL_DOUBLE;
800  }
801  // val can be either compressed or uncompressed
802  switch (size) {
803  case 1:
804  return *val == NULL_TINYINT;
805  case 2:
806  return *(int16_t*)val == NULL_SMALLINT;
807  case 4:
808  return *(int32_t*)val == NULL_INT;
809  case 8:
810  return *(int64_t*)val == NULL_BIGINT;
811  case kNULLT:
812  return true;
813  default:
814  // @TODO(wei) handle null strings
815  break;
816  }
817  return false;
818  }
819  HOST DEVICE inline bool is_null_fixlen_array(const int8_t* val, int array_size) const {
820  // Check if fixed length array has a NULL_ARRAY sentinel as the first element
821  if (type == kARRAY && val && array_size > 0 && array_size == size) {
822  // Need to create element type to get the size, but can't call get_elem_type()
823  // since this is a HOST DEVICE function. Going through copy constructor instead.
824  auto elem_ti{*this};
825  elem_ti.set_type(subtype);
826  elem_ti.set_subtype(kNULLT);
827  auto elem_size = elem_ti.get_storage_size();
828  if (elem_size < 1) {
829  return false;
830  }
831  if (subtype == kFLOAT) {
832  return *(float*)val == NULL_ARRAY_FLOAT;
833  }
834  if (subtype == kDOUBLE) {
835  return *(double*)val == NULL_ARRAY_DOUBLE;
836  }
837  switch (elem_size) {
838  case 1:
839  return *val == NULL_ARRAY_TINYINT;
840  case 2:
841  return *(int16_t*)val == NULL_ARRAY_SMALLINT;
842  case 4:
843  return *(int32_t*)val == NULL_ARRAY_INT;
844  case 8:
845  return *(int64_t*)val == NULL_ARRAY_BIGINT;
846  default:
847  return false;
848  }
849  }
850  return false;
851  }
852  HOST DEVICE inline bool is_null_point_coord_array(const int8_t* val,
853  int array_size) const {
854  if (type == kARRAY && subtype == kTINYINT && val && array_size > 0 &&
855  array_size == size) {
856  if (array_size == 2 * sizeof(double)) {
857  return *(double*)val == NULL_ARRAY_DOUBLE;
858  }
859  if (array_size == 2 * sizeof(int32_t)) {
860  return *(uint32_t*)val == NULL_ARRAY_COMPRESSED_32;
861  }
862  }
863  return false;
864  }
865  inline SQLTypeInfo get_elem_type() const {
866  return SQLTypeInfo(
868  }
869  inline SQLTypeInfo get_array_type() const {
871  }
872 
873  inline bool is_date_in_days() const {
874  if (type == kDATE) {
875  const auto comp_type = get_compression();
876  if (comp_type == kENCODING_DATE_IN_DAYS) {
877  return true;
878  }
879  }
880  return false;
881  }
882 
883  inline bool is_date() const { return type == kDATE; }
884 
885  inline bool is_high_precision_timestamp() const {
886  if (type == kTIMESTAMP) {
887  const auto dimension = get_dimension();
888  if (dimension > 0) {
889  return true;
890  }
891  }
892  return false;
893  }
894 
895  inline bool is_timestamp() const { return type == kTIMESTAMP; }
896 
897  private:
898  SQLTypes type; // type id
899  SQLTypes subtype; // element type of arrays or columns
900  int dimension; // VARCHAR/CHAR length or NUMERIC/DECIMAL precision or COLUMN_LIST
901  // length
902  int scale; // NUMERIC/DECIMAL scale
903  bool notnull; // nullable? a hint, not used for type checking
904  EncodingType compression; // compression scheme
905  int comp_param; // compression parameter when applicable for certain schemes
906  int size; // size of the type in bytes. -1 for variable size
907  bool dict_intersection{false};
908 #ifndef __CUDACC__
909  static std::string type_name[kSQLTYPE_LAST];
910  static std::string comp_name[kENCODING_LAST];
911 #endif
912  HOST DEVICE inline int get_storage_size() const {
913  switch (type) {
914  case kBOOLEAN:
915  return sizeof(int8_t);
916  case kTINYINT:
917  return sizeof(int8_t);
918  case kSMALLINT:
919  switch (compression) {
920  case kENCODING_NONE:
921  return sizeof(int16_t);
922  case kENCODING_FIXED:
923  case kENCODING_SPARSE:
924  return comp_param / 8;
925  case kENCODING_RL:
926  case kENCODING_DIFF:
927  break;
928  default:
929  assert(false);
930  }
931  break;
932  case kINT:
933  switch (compression) {
934  case kENCODING_NONE:
935  return sizeof(int32_t);
936  case kENCODING_FIXED:
937  case kENCODING_SPARSE:
938  case kENCODING_GEOINT:
939  return comp_param / 8;
940  case kENCODING_RL:
941  case kENCODING_DIFF:
942  break;
943  default:
944  assert(false);
945  }
946  break;
947  case kBIGINT:
948  case kNUMERIC:
949  case kDECIMAL:
950  switch (compression) {
951  case kENCODING_NONE:
952  return sizeof(int64_t);
953  case kENCODING_FIXED:
954  case kENCODING_SPARSE:
955  return comp_param / 8;
956  case kENCODING_RL:
957  case kENCODING_DIFF:
958  break;
959  default:
960  assert(false);
961  }
962  break;
963  case kFLOAT:
964  switch (compression) {
965  case kENCODING_NONE:
966  return sizeof(float);
967  case kENCODING_FIXED:
968  case kENCODING_RL:
969  case kENCODING_DIFF:
970  case kENCODING_SPARSE:
971  assert(false);
972  break;
973  default:
974  assert(false);
975  }
976  break;
977  case kDOUBLE:
978  switch (compression) {
979  case kENCODING_NONE:
980  return sizeof(double);
981  case kENCODING_FIXED:
982  case kENCODING_RL:
983  case kENCODING_DIFF:
984  case kENCODING_SPARSE:
985  assert(false);
986  break;
987  default:
988  assert(false);
989  }
990  break;
991  case kTIMESTAMP:
992  case kTIME:
993  case kINTERVAL_DAY_TIME:
995  case kDATE:
996  switch (compression) {
997  case kENCODING_NONE:
998  return sizeof(int64_t);
999  case kENCODING_FIXED:
1000  if (type == kTIMESTAMP && dimension > 0) {
1001  assert(false); // disable compression for timestamp precisions
1002  }
1003  return comp_param / 8;
1004  case kENCODING_RL:
1005  case kENCODING_DIFF:
1006  case kENCODING_SPARSE:
1007  assert(false);
1008  break;
1010  switch (comp_param) {
1011  case 0:
1012  return 4; // Default date encoded in days is 32 bits
1013  case 16:
1014  case 32:
1015  return comp_param / 8;
1016  default:
1017  assert(false);
1018  break;
1019  }
1020  default:
1021  assert(false);
1022  }
1023  break;
1024  case kTEXT:
1025  case kVARCHAR:
1026  case kCHAR:
1027  if (compression == kENCODING_DICT) {
1028  return sizeof(int32_t); // @TODO(wei) must check DictDescriptor
1029  }
1030  break;
1031  case kARRAY:
1032  // TODO: return size for fixlen arrays?
1033  break;
1034  case kPOINT:
1035  case kLINESTRING:
1036  case kPOLYGON:
1037  case kMULTIPOLYGON:
1038  case kCOLUMN:
1039  case kCOLUMN_LIST:
1040  break;
1041  default:
1042  break;
1043  }
1044  return -1;
1045  }
1046 };
1047 
1049 
1051 
1052 #ifndef __CUDACC__
1053 #include <string_view>
1054 
1055 Datum StringToDatum(std::string_view s, SQLTypeInfo& ti);
1056 std::string DatumToString(Datum d, const SQLTypeInfo& ti);
1057 int64_t extract_int_type_from_datum(const Datum datum, const SQLTypeInfo& ti);
1058 double extract_fp_type_from_datum(const Datum datum, const SQLTypeInfo& ti);
1059 bool DatumEqual(const Datum, const Datum, const SQLTypeInfo& ti);
1060 int64_t convert_decimal_value_to_scale(const int64_t decimal_value,
1061  const SQLTypeInfo& type_info,
1062  const SQLTypeInfo& new_type_info);
1063 #endif
1064 
1065 #include "../QueryEngine/DateAdd.h"
1066 #include "../QueryEngine/DateTruncate.h"
1067 #include "../QueryEngine/ExtractFromTime.h"
1068 
1069 inline SQLTypes get_int_type_by_size(size_t const nbytes) {
1070  switch (nbytes) {
1071  case 1:
1072  return kTINYINT;
1073  case 2:
1074  return kSMALLINT;
1075  case 4:
1076  return kINT;
1077  case 8:
1078  return kBIGINT;
1079  default:
1080 #if !(defined(__CUDACC__) || defined(NO_BOOST))
1081  UNREACHABLE() << "Invalid number of bytes=" << nbytes;
1082 #endif
1083  return {};
1084  }
1085 }
1086 
1088  EncodingType encoding = type_info.get_compression();
1089  if (encoding == kENCODING_DATE_IN_DAYS ||
1090  (encoding == kENCODING_FIXED && type_info.get_type() != kARRAY)) {
1091  encoding = kENCODING_NONE;
1092  }
1093  return SQLTypeInfo(type_info.get_type(),
1094  type_info.get_dimension(),
1095  type_info.get_scale(),
1096  type_info.get_notnull(),
1097  encoding,
1098  type_info.get_comp_param(),
1099  type_info.get_subtype());
1100 }
1101 
1103  SQLTypeInfo nullable_type_info = type_info;
1104  nullable_type_info.set_notnull(false);
1105  return nullable_type_info;
1106 }
1107 
1109  SQLTypeInfo nullable_type_info = get_logical_type_info(type_info);
1110  return get_nullable_type_info(nullable_type_info);
1111 }
1112 
1113 using StringOffsetT = int32_t;
1114 using ArrayOffsetT = int32_t;
1115 
1116 int8_t* append_datum(int8_t* buf, const Datum& d, const SQLTypeInfo& ti);
1117 
1118 inline auto generate_array_type(const SQLTypes subtype) {
1119  auto ti = SQLTypeInfo(kARRAY, false);
1120  ti.set_subtype(subtype);
1121  return ti;
1122 }
1123 
1124 inline auto generate_column_type(const SQLTypes subtype) {
1125  auto ti = SQLTypeInfo(kCOLUMN, false);
1126  ti.set_subtype(subtype);
1127  return ti;
1128 }
1129 
1130 inline auto generate_column_type(const SQLTypes subtype, EncodingType c, int p) {
1131  auto ti = SQLTypeInfo(kCOLUMN, false);
1132  ti.set_subtype(subtype);
1133  ti.set_compression(c);
1134  ti.set_comp_param(p);
1135  return ti;
1136 }
1137 
1138 inline auto generate_column_list_type(const SQLTypes subtype) {
1139  auto ti = SQLTypeInfo(kCOLUMN_LIST, false);
1140  ti.set_subtype(subtype);
1141  return ti;
1142 }
1143 
1145  size_t index;
1148 };
int8_t tinyintval
Definition: sqltypes.h:212
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:330
void set_compression(EncodingType c)
Definition: sqltypes.h:440
void set_size(int s)
Definition: sqltypes.h:437
#define NULL_DOUBLE
HOST DEVICE int get_size() const
Definition: sqltypes.h:339
HOST DEVICE void operator=(const SQLTypeInfo &rhs)
Definition: sqltypes.h:595
int8_t * append_datum(int8_t *buf, const Datum &d, const SQLTypeInfo &ti)
Definition: Datum.cpp:512
std::string DatumToString(Datum d, const SQLTypeInfo &ti)
Definition: Datum.cpp:392
bool is_varlen_array() const
Definition: sqltypes.h:519
DEVICE VarlenDatum()
Definition: sqltypes.h:155
Definition: sqltypes.h:49
DEVICE constexpr bool is_cuda_compiler()
Definition: sqltypes.h:199
SQLTypes
Definition: sqltypes.h:38
std::vector< std::string > * stringsPtr
Definition: sqltypes.h:227
bool is_timestamp() const
Definition: sqltypes.h:895
std::vector< ArrayDatum > * arraysPtr
Definition: sqltypes.h:228
#define NULL_ARRAY_INT
#define NULL_FLOAT
bool is_null
Definition: sqltypes.h:153
#define NULL_BIGINT
SQLTypeInfo get_nullable_logical_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:1108
#define LOG(tag)
Definition: Logger.h:217
HOST DEVICE bool operator==(const SQLTypeInfo &rhs) const
Definition: sqltypes.h:575
std::ostream & operator<<(std::ostream &os, const SessionInfo &session_info)
Definition: SessionInfo.cpp:57
bool is_fp() const
Definition: sqltypes.h:514
HOST DEVICE int get_scale() const
Definition: sqltypes.h:334
bool is_varlen() const
Definition: sqltypes.h:536
#define NULL_ARRAY_SMALLINT
auto generate_column_type(const SQLTypes subtype)
Definition: sqltypes.h:1124
int8_t boolval
Definition: sqltypes.h:211
std::string get_compression_name() const
Definition: sqltypes.h:481
VarlenDatum * arrayval
Definition: sqltypes.h:218
#define UNREACHABLE()
Definition: Logger.h:267
HOST DEVICE void set_subtype(SQLTypes st)
Definition: sqltypes.h:430
SQLTypeInfo(SQLTypes t, int d, int s)
Definition: sqltypes.h:299
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:1087
Definition: sqltypes.h:65
#define NULL_ARRAY_TINYINT
HOST DEVICE bool is_null_fixlen_array(const int8_t *val, int array_size) const
Definition: sqltypes.h:819
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
bool is_number() const
Definition: sqltypes.h:515
int32_t intval
Definition: sqltypes.h:214
bool is_time() const
Definition: sqltypes.h:516
std::string to_string(char const *&&v)
HostArrayDatum(size_t const l, int8_t *p, bool const n, CUSTOM_DELETER custom_deleter)
Definition: sqltypes.h:189
int8_t * pointer
Definition: sqltypes.h:152
#define NULL_INT
SQLTypeInfo ti
Definition: sqltypes.h:1146
int32_t StringOffsetT
Definition: sqltypes.h:1113
bool has_render_group() const
Definition: sqltypes.h:419
#define DEVICE
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:208
#define HOST
void set_input_srid(int d)
Definition: sqltypes.h:433
float floatval
Definition: sqltypes.h:216
std::string to_string() const
Definition: sqltypes.h:483
EncodingType
Definition: sqltypes.h:233
int get_physical_cols() const
Definition: sqltypes.h:360
bool is_fixlen_array() const
Definition: sqltypes.h:520
bool is_castable(const SQLTypeInfo &new_type_info) const
Definition: sqltypes.h:606
#define IS_INTERVAL(T)
Definition: sqltypes.h:253
void set_fixed_size()
Definition: sqltypes.h:438
std::shared_ptr< int8_t > ManagedPtr
Definition: sqltypes.h:170
HOST DEVICE bool operator!=(const SQLTypeInfo &rhs) const
Definition: sqltypes.h:567
int get_logical_size() const
Definition: sqltypes.h:349
bool DatumEqual(const Datum a, const Datum b, const SQLTypeInfo &ti)
Definition: Datum.cpp:342
static std::string type_name[kSQLTYPE_LAST]
Definition: sqltypes.h:909
bool is_integer() const
Definition: sqltypes.h:512
VarlenDatum(const size_t l, int8_t *p, const bool n)
Definition: sqltypes.h:158
bool is_subtype_dict_encoded_string() const
Definition: sqltypes.h:556
int64_t extract_int_type_from_datum(const Datum datum, const SQLTypeInfo &ti)
Definition: Datum.cpp:455
#define NULL_ARRAY_COMPRESSED_32
SQLTypes subtype
Definition: sqltypes.h:899
void set_scale(int s)
Definition: sqltypes.h:434
bool notnull
Definition: sqltypes.h:903
bool has_bounds() const
Definition: sqltypes.h:408
int64_t bigintval
Definition: sqltypes.h:215
HostArrayDatum(size_t const l, int8_t *p, CUSTOM_DELETER custom_deleter)
Definition: sqltypes.h:183
bool is_timeinterval() const
Definition: sqltypes.h:521
#define NULL_ARRAY_FLOAT
bool is_numeric_scalar_auto_castable(const SQLTypeInfo &new_type_info) const
returns true if the sql_type can be cast to the type specified by new_type_info with no loss of preci...
Definition: sqltypes.h:652
ManagedPtr data_ptr
Definition: sqltypes.h:192
int is_logical_geo_type() const
Definition: sqltypes.h:341
auto generate_column_list_type(const SQLTypes subtype)
Definition: sqltypes.h:1138
HostArrayDatum()=default
int16_t smallintval
Definition: sqltypes.h:213
bool is_dict_intersection() const
Definition: sqltypes.h:565
bool is_dict_encoded_type() const
Definition: sqltypes.h:560
SQLTypeInfo(SQLTypes t, int d, int s, bool n)
Definition: sqltypes.h:281
Datum StringToDatum(std::string_view s, SQLTypeInfo &ti)
Definition: Datum.cpp:275
std::string toString() const
Definition: sqltypes.h:482
bool is_boolean() const
Definition: sqltypes.h:517
HostArrayDatum(size_t const l, int8_t *p, bool const n)
Definition: sqltypes.h:177
bool g_enable_smem_group_by true
std::string toString(const Executor::ExtModuleKinds &kind)
Definition: Execute.h:1453
void operator()(int8_t *p)
Definition: sqltypes.h:166
SQLTypeInfo(SQLTypes t, int d, int s, bool n, EncodingType c, int p, SQLTypes st)
Definition: sqltypes.h:272
SQLTypeInfo(SQLTypes t)
Definition: sqltypes.h:309
#define NULL_BOOLEAN
std::string get_buffer_name() const
Definition: sqltypes.h:494
SQLTypeInfo(SQLTypes t, bool n, EncodingType c)
Definition: sqltypes.h:310
SQLTypeInfo get_array_type() const
Definition: sqltypes.h:869
EncodingType compression
Definition: sqltypes.h:904
int get_precision() const
Definition: sqltypes.h:332
std::string * stringval
Definition: sqltypes.h:220
void set_output_srid(int s)
Definition: sqltypes.h:435
bool is_buffer() const
Definition: sqltypes.h:528
SQLTypes decimal_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:493
auto generate_array_type(const SQLTypes subtype)
Definition: sqltypes.h:1118
bool is_column() const
Definition: sqltypes.h:523
DEVICE DeviceArrayDatum()
Definition: sqltypes.h:196
HOST DEVICE bool is_null(const Datum &d) const
Definition: sqltypes.h:757
void set_comp_param(int p)
Definition: sqltypes.h:441
HOST DEVICE int get_storage_size() const
Definition: sqltypes.h:912
#define CHECK_LT(x, y)
Definition: Logger.h:233
Definition: sqltypes.h:52
Definition: sqltypes.h:53
bool dict_intersection
Definition: sqltypes.h:907
static std::string comp_name[kENCODING_LAST]
Definition: sqltypes.h:910
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:337
bool is_date_in_days() const
Definition: sqltypes.h:873
int get_array_context_logical_size() const
Definition: sqltypes.h:584
int64_t convert_decimal_value_to_scale(const int64_t decimal_value, const SQLTypeInfo &type_info, const SQLTypeInfo &new_type_info)
Definition: Datum.cpp:556
int32_t ArrayOffsetT
Definition: sqltypes.h:1114
void set_dimension(int d)
Definition: sqltypes.h:431
SQLTypes get_int_type_by_size(size_t const nbytes)
Definition: sqltypes.h:1069
bool is_none_encoded_string() const
Definition: sqltypes.h:552
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:331
#define IS_INTEGER(T)
Definition: sqltypes.h:245
std::string get_type_name() const
Definition: sqltypes.h:443
int32_t get_numeric_scalar_scale() const
returns integer between 1 and 8 indicating what is roughly equivalent to the logical byte size of a s...
Definition: sqltypes.h:713
Definition: sqltypes.h:41
#define IS_STRING(T)
Definition: sqltypes.h:250
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:338
HOST DEVICE int get_input_srid() const
Definition: sqltypes.h:333
void set_dict_intersection()
Definition: sqltypes.h:439
#define NULL_TINYINT
#define NULL_ARRAY_DOUBLE
virtual DEVICE ~VarlenDatum()
Definition: sqltypes.h:156
bool is_bytes() const
Definition: sqltypes.h:525
bool is_column_list() const
Definition: sqltypes.h:524
bool g_enable_watchdog false
Definition: Execute.cpp:79
void set_notnull(bool n)
Definition: sqltypes.h:436
#define CHECK(condition)
Definition: Logger.h:223
bool is_geometry() const
Definition: sqltypes.h:522
bool is_high_precision_timestamp() const
Definition: sqltypes.h:885
SQLTypes type
Definition: sqltypes.h:898
#define NULL_SMALLINT
double extract_fp_type_from_datum(const Datum datum, const SQLTypeInfo &ti)
Definition: Datum.cpp:481
HostArrayDatum(size_t const l, ManagedPtr p, bool const n)
Definition: sqltypes.h:174
#define NULL_ARRAY_BIGINT
bool is_dict_encoded_string() const
Definition: sqltypes.h:548
Definition: sqltypes.h:45
bool is_varlen_indeed() const
Definition: sqltypes.h:542
bool is_string() const
Definition: sqltypes.h:510
SQLTypeInfo(SQLTypes t, EncodingType c, int p, SQLTypes st)
Definition: sqltypes.h:290
constexpr double n
Definition: Utm.h:38
bool transforms() const
Definition: sqltypes.h:531
SQLTypeInfo(SQLTypes t, bool n)
Definition: sqltypes.h:300
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:336
int8_t * numbersPtr
Definition: sqltypes.h:226
bool is_string_array() const
Definition: sqltypes.h:511
size_t index
Definition: sqltypes.h:1145
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:865
bool is_decimal() const
Definition: sqltypes.h:513
int get_physical_coord_cols() const
Definition: sqltypes.h:375
#define IS_NUMBER(T)
Definition: sqltypes.h:247
void operator()(int8_t *)
Definition: sqltypes.h:163
#define IS_GEO(T)
Definition: sqltypes.h:251
#define TRANSIENT_DICT(ID)
Definition: sqltypes.h:260
int comp_param
Definition: sqltypes.h:905
bool is_date() const
Definition: sqltypes.h:883
bool is_array() const
Definition: sqltypes.h:518
void set_precision(int d)
Definition: sqltypes.h:432
SQLTypeInfo get_nullable_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:1102
int dimension
Definition: sqltypes.h:900
HOST DEVICE bool is_null_point_coord_array(const int8_t *val, int array_size) const
Definition: sqltypes.h:852
double doubleval
Definition: sqltypes.h:217
HOST DEVICE int get_output_srid() const
Definition: sqltypes.h:335
constexpr auto is_datetime(SQLTypes type)
Definition: sqltypes.h:263
HOST DEVICE bool is_null(const int8_t *val) const
Definition: sqltypes.h:794
size_t length
Definition: sqltypes.h:151
SQLTypes string_dict_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:497
HOST DEVICE void set_type(SQLTypes t)
Definition: sqltypes.h:429