OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sqltypes.h File Reference

Constants for Builtin SQL Types supported by OmniSci. More...

#include "../Logger/Logger.h"
#include "funcannotations.h"
#include <cassert>
#include <ctime>
#include <memory>
#include <ostream>
#include <sstream>
#include <string>
#include <type_traits>
#include <vector>
#include "InlineNullValues.h"
#include <string_view>
#include "../QueryEngine/DateAdd.h"
#include "../QueryEngine/DateTruncate.h"
#include "../QueryEngine/ExtractFromTime.h"
+ Include dependency graph for sqltypes.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  VarlenDatum
 
struct  DoNothingDeleter
 
struct  FreeDeleter
 
struct  HostArrayDatum
 
struct  DeviceArrayDatum
 
union  Datum
 
union  DataBlockPtr
 
class  SQLTypeInfo
 
struct  SqlLiteralArg
 

Macros

#define IS_INTEGER(T)   (((T) == kINT) || ((T) == kSMALLINT) || ((T) == kBIGINT) || ((T) == kTINYINT))
 
#define IS_NUMBER(T)
 
#define IS_STRING(T)   (((T) == kTEXT) || ((T) == kVARCHAR) || ((T) == kCHAR))
 
#define IS_GEO(T)   (((T) == kPOINT) || ((T) == kLINESTRING) || ((T) == kPOLYGON) || ((T) == kMULTIPOLYGON))
 
#define IS_INTERVAL(T)   ((T) == kINTERVAL_DAY_TIME || (T) == kINTERVAL_YEAR_MONTH)
 
#define IS_DECIMAL(T)   ((T) == kNUMERIC || (T) == kDECIMAL)
 
#define IS_GEO_POLY(T)   (((T) == kPOLYGON) || ((T) == kMULTIPOLYGON))
 
#define TRANSIENT_DICT_ID   0
 
#define TRANSIENT_DICT(ID)   (-(ID))
 
#define REGULAR_DICT(TRANSIENTID)   (-(TRANSIENTID))
 

Typedefs

using ArrayDatum = std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum >
 
using StringOffsetT = int32_t
 
using ArrayOffsetT = int32_t
 

Enumerations

enum  SQLTypes {
  kNULLT = 0, kBOOLEAN = 1, kCHAR = 2, kVARCHAR = 3,
  kNUMERIC = 4, kDECIMAL = 5, kINT = 6, kSMALLINT = 7,
  kFLOAT = 8, kDOUBLE = 9, kTIME = 10, kTIMESTAMP = 11,
  kBIGINT = 12, kTEXT = 13, kDATE = 14, kARRAY = 15,
  kINTERVAL_DAY_TIME = 16, kINTERVAL_YEAR_MONTH = 17, kPOINT = 18, kLINESTRING = 19,
  kPOLYGON = 20, kMULTIPOLYGON = 21, kTINYINT = 22, kGEOMETRY = 23,
  kGEOGRAPHY = 24, kEVAL_CONTEXT_TYPE = 25, kVOID = 26, kCURSOR = 27,
  kCOLUMN = 28, kCOLUMN_LIST = 29, kSQLTYPE_LAST = 30
}
 
enum  EncodingType {
  kENCODING_NONE = 0, kENCODING_FIXED = 1, kENCODING_RL = 2, kENCODING_DIFF = 3,
  kENCODING_DICT = 4, kENCODING_SPARSE = 5, kENCODING_GEOINT = 6, kENCODING_DATE_IN_DAYS = 7,
  kENCODING_LAST = 8
}
 

Functions

std::string toString (const SQLTypes &type)
 
std::ostream & operator<< (std::ostream &os, SQLTypes const sql_type)
 
DEVICE constexpr bool is_cuda_compiler ()
 
constexpr auto is_datetime (SQLTypes type)
 
SQLTypes decimal_to_int_type (const SQLTypeInfo &)
 
SQLTypes string_dict_to_int_type (const SQLTypeInfo &)
 
Datum StringToDatum (std::string_view s, SQLTypeInfo &ti)
 
std::string DatumToString (Datum d, const SQLTypeInfo &ti)
 
int64_t extract_int_type_from_datum (const Datum datum, const SQLTypeInfo &ti)
 
double extract_fp_type_from_datum (const Datum datum, const SQLTypeInfo &ti)
 
bool DatumEqual (const Datum, const Datum, const SQLTypeInfo &ti)
 
int64_t convert_decimal_value_to_scale (const int64_t decimal_value, const SQLTypeInfo &type_info, const SQLTypeInfo &new_type_info)
 
SQLTypes get_int_type_by_size (size_t const nbytes)
 
SQLTypeInfo get_logical_type_info (const SQLTypeInfo &type_info)
 
SQLTypeInfo get_nullable_type_info (const SQLTypeInfo &type_info)
 
SQLTypeInfo get_nullable_logical_type_info (const SQLTypeInfo &type_info)
 
int8_t * append_datum (int8_t *buf, const Datum &d, const SQLTypeInfo &ti)
 
auto generate_array_type (const SQLTypes subtype)
 
auto generate_column_type (const SQLTypes subtype)
 
auto generate_column_type (const SQLTypes subtype, EncodingType c, int p)
 
auto generate_column_list_type (const SQLTypes subtype)
 

Detailed Description

Constants for Builtin SQL Types supported by OmniSci.

Author
Wei Hong wei@m.nosp@m.ap-d.nosp@m..com

Definition in file sqltypes.h.

Macro Definition Documentation

#define IS_DECIMAL (   T)    ((T) == kNUMERIC || (T) == kDECIMAL)

Definition at line 254 of file sqltypes.h.

#define IS_INTERVAL (   T)    ((T) == kINTERVAL_DAY_TIME || (T) == kINTERVAL_YEAR_MONTH)

Definition at line 253 of file sqltypes.h.

Referenced by SQLTypeInfo::is_timeinterval().

#define IS_NUMBER (   T)
Value:
(((T) == kINT) || ((T) == kSMALLINT) || ((T) == kDOUBLE) || ((T) == kFLOAT) || \
((T) == kBIGINT) || ((T) == kNUMERIC) || ((T) == kDECIMAL) || ((T) == kTINYINT))
Definition: sqltypes.h:45

Definition at line 247 of file sqltypes.h.

Referenced by SQLTypeInfo::is_number(), and anonymous_namespace{EquiJoinCondition.cpp}::make_composite_equals_impl().

#define REGULAR_DICT (   TRANSIENTID)    (-(TRANSIENTID))

Definition at line 261 of file sqltypes.h.

Referenced by RowSetMemoryOwner::getOrAddStringDictProxy().

Typedef Documentation

Definition at line 208 of file sqltypes.h.

using ArrayOffsetT = int32_t

Definition at line 1114 of file sqltypes.h.

using StringOffsetT = int32_t

Definition at line 1113 of file sqltypes.h.

Enumeration Type Documentation

Enumerator
kENCODING_NONE 
kENCODING_FIXED 
kENCODING_RL 
kENCODING_DIFF 
kENCODING_DICT 
kENCODING_SPARSE 
kENCODING_GEOINT 
kENCODING_DATE_IN_DAYS 
kENCODING_LAST 

Definition at line 233 of file sqltypes.h.

233  {
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
242  kENCODING_LAST = 8
243 };
enum SQLTypes
Enumerator
kNULLT 
kBOOLEAN 
kCHAR 
kVARCHAR 
kNUMERIC 
kDECIMAL 
kINT 
kSMALLINT 
kFLOAT 
kDOUBLE 
kTIME 
kTIMESTAMP 
kBIGINT 
kTEXT 
kDATE 
kARRAY 
kINTERVAL_DAY_TIME 
kINTERVAL_YEAR_MONTH 
kPOINT 
kLINESTRING 
kPOLYGON 
kMULTIPOLYGON 
kTINYINT 
kGEOMETRY 
kGEOGRAPHY 
kEVAL_CONTEXT_TYPE 
kVOID 
kCURSOR 
kCOLUMN 
kCOLUMN_LIST 
kSQLTYPE_LAST 

Definition at line 38 of file sqltypes.h.

38  {
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,
55  kINTERVAL_DAY_TIME = 16,
57  kPOINT = 18,
58  kLINESTRING = 19,
59  kPOLYGON = 20,
60  kMULTIPOLYGON = 21,
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,
68  kCOLUMN_LIST = 29,
69  kSQLTYPE_LAST = 30
70 };
Definition: sqltypes.h:49
Definition: sqltypes.h:65
Definition: sqltypes.h:52
Definition: sqltypes.h:53
Definition: sqltypes.h:41
Definition: sqltypes.h:45

Function Documentation

int8_t* append_datum ( int8_t *  buf,
const Datum d,
const SQLTypeInfo ti 
)

Definition at line 512 of file Datum.cpp.

References Datum::bigintval, Datum::boolval, Datum::doubleval, Datum::floatval, SQLTypeInfo::get_type(), Datum::intval, SQLTypeInfo::is_dict_encoded_string(), kBIGINT, kBOOLEAN, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kINT, kNUMERIC, kSMALLINT, kTIME, kTIMESTAMP, kTINYINT, Datum::smallintval, string_dict_to_int_type(), Datum::tinyintval, run_benchmark_import::type, and UNREACHABLE.

Referenced by RelAlgExecutor::executeSimpleInsert(), import_export::NullArray(), import_export::StringToArray(), and import_export::TDatumToArrayDatum().

512  {
513  SQLTypes type;
514  if (ti.is_dict_encoded_string()) {
515  type = string_dict_to_int_type(ti);
516  } else {
517  type = ti.get_type();
518  }
519  switch (type) {
520  case kBOOLEAN:
521  *(int8_t*)buf = d.boolval;
522  return buf + sizeof(int8_t);
523  case kNUMERIC:
524  case kDECIMAL:
525  case kBIGINT:
526  *(int64_t*)buf = d.bigintval;
527  return buf + sizeof(int64_t);
528  case kINT:
529  *(int32_t*)buf = d.intval;
530  return buf + sizeof(int32_t);
531  case kSMALLINT:
532  *(int16_t*)buf = d.smallintval;
533  return buf + sizeof(int16_t);
534  case kTINYINT:
535  *(int8_t*)buf = d.tinyintval;
536  return buf + sizeof(int8_t);
537  case kFLOAT:
538  *(float*)buf = d.floatval;
539  return buf + sizeof(float);
540  case kDOUBLE:
541  *(double*)buf = d.doubleval;
542  return buf + sizeof(double);
543  case kTIME:
544  case kTIMESTAMP:
545  case kDATE:
546  *reinterpret_cast<int64_t*>(buf) = d.bigintval;
547  return buf + sizeof(int64_t);
548  default:
549  UNREACHABLE() << "Unexpected type: " << type;
550  return nullptr;
551  }
552 }
int8_t tinyintval
Definition: sqltypes.h:212
Definition: sqltypes.h:49
SQLTypes
Definition: sqltypes.h:38
int8_t boolval
Definition: sqltypes.h:211
#define UNREACHABLE()
Definition: Logger.h:267
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
int32_t intval
Definition: sqltypes.h:214
float floatval
Definition: sqltypes.h:216
int64_t bigintval
Definition: sqltypes.h:215
int16_t smallintval
Definition: sqltypes.h:213
Definition: sqltypes.h:53
bool is_dict_encoded_string() const
Definition: sqltypes.h:548
Definition: sqltypes.h:45
double doubleval
Definition: sqltypes.h:217
SQLTypes string_dict_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:497

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t convert_decimal_value_to_scale ( const int64_t  decimal_value,
const SQLTypeInfo type_info,
const SQLTypeInfo new_type_info 
)

Definition at line 556 of file Datum.cpp.

References anonymous_namespace{Datum.cpp}::convert_decimal_value_to_scale_internal(), and SQLTypeInfo::get_scale().

Referenced by import_export::TypedImportBuffer::addDefaultValues(), Analyzer::Constant::cast_number(), anonymous_namespace{ArrowImporter.h}::ArrowValue< arrow::Decimal128 >::operator DATA_TYPE(), parse_numeric(), anonymous_namespace{TypedDataAccessors.h}::put_scalar(), and ddl_utils::anonymous_namespace{DdlUtils.cpp}::validate_literal().

558  {
559  int const dscale = new_type_info.get_scale() - type_info.get_scale();
560  return convert_decimal_value_to_scale_internal(decimal_value, dscale);
561 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:334
int64_t convert_decimal_value_to_scale_internal(const int64_t decimal_value, int const dscale)
Definition: Datum.cpp:77

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool DatumEqual ( const Datum  ,
const Datum  ,
const SQLTypeInfo ti 
)

Definition at line 342 of file Datum.cpp.

References Datum::bigintval, Datum::boolval, Datum::doubleval, Datum::floatval, SQLTypeInfo::get_compression(), SQLTypeInfo::get_type(), Datum::intval, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kENCODING_DICT, kFLOAT, kINT, kINTERVAL_DAY_TIME, kINTERVAL_YEAR_MONTH, kLINESTRING, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, Datum::smallintval, Datum::stringval, and Datum::tinyintval.

Referenced by ChunkMetadata::operator==(), FixedLengthArrayNoneEncoder::resetChunkStats(), and ArrayNoneEncoder::resetChunkStats().

342  {
343  switch (ti.get_type()) {
344  case kBOOLEAN:
345  return a.boolval == b.boolval;
346  case kBIGINT:
347  case kNUMERIC:
348  case kDECIMAL:
349  return a.bigintval == b.bigintval;
350  case kINT:
351  return a.intval == b.intval;
352  case kSMALLINT:
353  return a.smallintval == b.smallintval;
354  case kTINYINT:
355  return a.tinyintval == b.tinyintval;
356  case kFLOAT:
357  return a.floatval == b.floatval;
358  case kDOUBLE:
359  return a.doubleval == b.doubleval;
360  case kTIME:
361  case kTIMESTAMP:
362  case kDATE:
363  case kINTERVAL_DAY_TIME:
365  return a.bigintval == b.bigintval;
366  case kTEXT:
367  case kVARCHAR:
368  case kCHAR:
369  case kPOINT:
370  case kLINESTRING:
371  case kPOLYGON:
372  case kMULTIPOLYGON:
373  if (ti.get_compression() == kENCODING_DICT) {
374  return a.intval == b.intval;
375  }
376  if (a.stringval == nullptr && b.stringval == nullptr) {
377  return true;
378  }
379  if (a.stringval == nullptr || b.stringval == nullptr) {
380  return false;
381  }
382  return *a.stringval == *b.stringval;
383  default:
384  return false;
385  }
386  return false;
387 }
Definition: sqltypes.h:49
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
constexpr double a
Definition: Utm.h:32
Definition: sqltypes.h:52
Definition: sqltypes.h:53
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:337
Definition: sqltypes.h:41
Definition: sqltypes.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string DatumToString ( Datum  d,
const SQLTypeInfo ti 
)

Definition at line 392 of file Datum.cpp.

References Datum::bigintval, Datum::boolval, CHECK_EQ, CHECK_LE, CHECK_LT, Datum::doubleval, Datum::floatval, shared::formatDate(), shared::formatDateTime(), shared::formatHMS(), SQLTypeInfo::get_dimension(), SQLTypeInfo::get_scale(), SQLTypeInfo::get_type(), SQLTypeInfo::get_type_name(), Datum::intval, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kINT, kINTERVAL_DAY_TIME, kINTERVAL_YEAR_MONTH, kNUMERIC, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, Datum::smallintval, Datum::stringval, Datum::tinyintval, to_string(), and SQLTypeInfo::to_string().

Referenced by Analyzer::Constant::cast_to_string(), foreign_storage::datetime_to_string(), ChunkMetadata::dump(), foreign_storage::TypedParquetInPlaceEncoder< V, V >::integralTypeToString(), anonymous_namespace{ArrowImporter.h}::ArrowValue< int64_t >::operator DATA_TYPE(), import_export::anonymous_namespace{QueryExporterCSV.cpp}::target_value_to_string(), Analyzer::Constant::toString(), Fragmenter_Namespace::InsertOrderFragmenter::updateChunkStats(), and ScalarExprToSql::visitConstant().

392  {
393  constexpr size_t buf_size = 64;
394  char buf[buf_size]; // Hold "2000-03-01 12:34:56.123456789" and large years.
395  switch (ti.get_type()) {
396  case kBOOLEAN:
397  if (d.boolval) {
398  return "t";
399  }
400  return "f";
401  case kNUMERIC:
402  case kDECIMAL: {
403  double v = (double)d.bigintval / pow(10, ti.get_scale());
404  int size = snprintf(buf, buf_size, "%*.*f", ti.get_dimension(), ti.get_scale(), v);
405  CHECK_LE(0, size) << v << ' ' << ti.to_string();
406  CHECK_LT(size_t(size), buf_size) << v << ' ' << ti.to_string();
407  return buf;
408  }
409  case kINT:
410  return std::to_string(d.intval);
411  case kSMALLINT:
412  return std::to_string(d.smallintval);
413  case kTINYINT:
414  return std::to_string(d.tinyintval);
415  case kBIGINT:
416  return std::to_string(d.bigintval);
417  case kFLOAT:
418  return std::to_string(d.floatval);
419  case kDOUBLE:
420  return std::to_string(d.doubleval);
421  case kTIME: {
422  size_t const len = shared::formatHMS(buf, buf_size, d.bigintval);
423  CHECK_EQ(8u, len); // 8 == strlen("HH:MM:SS")
424  return buf;
425  }
426  case kTIMESTAMP: {
427  unsigned const dim = ti.get_dimension(); // assumes dim <= 9
428  size_t const len = shared::formatDateTime(buf, buf_size, d.bigintval, dim);
429  CHECK_LE(19u + bool(dim) + dim, len); // 19 = strlen("YYYY-MM-DD HH:MM:SS")
430  return buf;
431  }
432  case kDATE: {
433  size_t const len = shared::formatDate(buf, buf_size, d.bigintval);
434  CHECK_LE(10u, len); // 10 == strlen("YYYY-MM-DD")
435  return buf;
436  }
437  case kINTERVAL_DAY_TIME:
438  return std::to_string(d.bigintval) + " ms (day-time interval)";
440  return std::to_string(d.bigintval) + " month(s) (year-month interval)";
441  case kTEXT:
442  case kVARCHAR:
443  case kCHAR:
444  if (d.stringval == nullptr) {
445  return "NULL";
446  }
447  return *d.stringval;
448  default:
449  throw std::runtime_error("Internal error: invalid type " + ti.get_type_name() +
450  " in DatumToString.");
451  }
452  return "";
453 }
int8_t tinyintval
Definition: sqltypes.h:212
#define CHECK_EQ(x, y)
Definition: Logger.h:231
Definition: sqltypes.h:49
HOST DEVICE int get_scale() const
Definition: sqltypes.h:334
int8_t boolval
Definition: sqltypes.h:211
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
int32_t intval
Definition: sqltypes.h:214
std::string to_string(char const *&&v)
size_t formatHMS(char *buf, size_t const max, int64_t const unixtime)
Definition: misc.cpp:96
float floatval
Definition: sqltypes.h:216
std::string to_string() const
Definition: sqltypes.h:483
int64_t bigintval
Definition: sqltypes.h:215
int16_t smallintval
Definition: sqltypes.h:213
std::string * stringval
Definition: sqltypes.h:220
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:233
Definition: sqltypes.h:52
Definition: sqltypes.h:53
#define CHECK_LE(x, y)
Definition: Logger.h:234
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:331
std::string get_type_name() const
Definition: sqltypes.h:443
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:41
Definition: sqltypes.h:45
double doubleval
Definition: sqltypes.h:217

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SQLTypes decimal_to_int_type ( const SQLTypeInfo )
double extract_fp_type_from_datum ( const Datum  datum,
const SQLTypeInfo ti 
)

Definition at line 481 of file Datum.cpp.

References Datum::doubleval, Datum::floatval, SQLTypeInfo::get_type(), kDOUBLE, kFLOAT, and run_benchmark_import::type.

Referenced by extract_max_stat_fp_type(), and extract_min_stat_fp_type().

481  {
482  const auto type = ti.get_type();
483  switch (type) {
484  case kFLOAT:
485  return datum.floatval;
486  case kDOUBLE:
487  return datum.doubleval;
488  default:
489  abort();
490  }
491 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
float floatval
Definition: sqltypes.h:216
double doubleval
Definition: sqltypes.h:217

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t extract_int_type_from_datum ( const Datum  datum,
const SQLTypeInfo ti 
)

Definition at line 455 of file Datum.cpp.

References Datum::bigintval, CHECK_EQ, decimal_to_int_type(), SQLTypeInfo::get_compression(), SQLTypeInfo::get_type(), Datum::intval, SQLTypeInfo::is_decimal(), kBIGINT, kBOOLEAN, kCHAR, kDATE, kENCODING_DICT, kINT, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, Datum::smallintval, Datum::tinyintval, and run_benchmark_import::type.

Referenced by extract_max_stat_int_type(), extract_min_stat_int_type(), StringOps_Namespace::StringOpInfo::getIntLiteral(), and StringOps_Namespace::operator<<().

455  {
456  const auto type = ti.is_decimal() ? decimal_to_int_type(ti) : ti.get_type();
457  switch (type) {
458  case kBOOLEAN:
459  return datum.tinyintval;
460  case kTINYINT:
461  return datum.tinyintval;
462  case kSMALLINT:
463  return datum.smallintval;
464  case kCHAR:
465  case kVARCHAR:
466  case kTEXT:
468  case kINT:
469  return datum.intval;
470  case kBIGINT:
471  return datum.bigintval;
472  case kTIME:
473  case kTIMESTAMP:
474  case kDATE:
475  return datum.bigintval;
476  default:
477  abort();
478  }
479 }
int8_t tinyintval
Definition: sqltypes.h:212
#define CHECK_EQ(x, y)
Definition: Logger.h:231
Definition: sqltypes.h:49
int32_t intval
Definition: sqltypes.h:214
int64_t bigintval
Definition: sqltypes.h:215
int16_t smallintval
Definition: sqltypes.h:213
SQLTypes decimal_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:493
Definition: sqltypes.h:52
Definition: sqltypes.h:53
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:337
Definition: sqltypes.h:41
Definition: sqltypes.h:45
bool is_decimal() const
Definition: sqltypes.h:513

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

auto generate_array_type ( const SQLTypes  subtype)
inline

Definition at line 1118 of file sqltypes.h.

References kARRAY.

Referenced by ext_arg_type_to_type_info().

1118  {
1119  auto ti = SQLTypeInfo(kARRAY, false);
1120  ti.set_subtype(subtype);
1121  return ti;
1122 }

+ Here is the caller graph for this function:

auto generate_column_list_type ( const SQLTypes  subtype)
inline

Definition at line 1138 of file sqltypes.h.

References kCOLUMN_LIST.

Referenced by bind_function(), and table_functions::anonymous_namespace{TableFunctionsFactory.cpp}::ext_arg_pointer_type_to_type_info().

1138  {
1139  auto ti = SQLTypeInfo(kCOLUMN_LIST, false);
1140  ti.set_subtype(subtype);
1141  return ti;
1142 }

+ Here is the caller graph for this function:

auto generate_column_type ( const SQLTypes  subtype)
inline

Definition at line 1124 of file sqltypes.h.

References kCOLUMN.

Referenced by bind_function(), table_functions::anonymous_namespace{TableFunctionsFactory.cpp}::ext_arg_pointer_type_to_type_info(), and ext_arg_type_to_type_info().

1124  {
1125  auto ti = SQLTypeInfo(kCOLUMN, false);
1126  ti.set_subtype(subtype);
1127  return ti;
1128 }

+ Here is the caller graph for this function:

auto generate_column_type ( const SQLTypes  subtype,
EncodingType  c,
int  p 
)
inline

Definition at line 1130 of file sqltypes.h.

References kCOLUMN.

1130  {
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 }
SQLTypes get_int_type_by_size ( size_t const  nbytes)
inline

Definition at line 1069 of file sqltypes.h.

References kBIGINT, kINT, kSMALLINT, kTINYINT, and UNREACHABLE.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::anonymous_namespace{RelAlgExecutor.cpp}::conditionally_change_arg_to_int_type(), and decimal_to_int_type().

1069  {
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 }
#define UNREACHABLE()
Definition: Logger.h:267
Definition: sqltypes.h:45

+ Here is the caller graph for this function:

SQLTypeInfo get_logical_type_info ( const SQLTypeInfo type_info)
inline

Definition at line 1087 of file sqltypes.h.

References SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_compression(), SQLTypeInfo::get_dimension(), SQLTypeInfo::get_notnull(), SQLTypeInfo::get_scale(), SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), kARRAY, kENCODING_DATE_IN_DAYS, kENCODING_FIXED, and kENCODING_NONE.

Referenced by anonymous_namespace{ColumnFetcher.cpp}::columnarize_result(), anonymous_namespace{ColumnarResults.cpp}::fixed_encoding_nullable_val(), anonymous_namespace{RelAlgExecutor.cpp}::get_logical_type_for_expr(), anonymous_namespace{TypedDataAccessors.h}::NullSentinelSupplier::get_null_sentinel_for_type(), get_nullable_logical_type_info(), get_target_info(), TableOptimizer::getDeletedColumnStats(), PerfectJoinHashTable::getHashJoinArgs(), getLeafColumnRange(), Parser::CaseExpr::normalize(), TableOptimizer::recomputeColumnMetadata(), Fragmenter_Namespace::InsertOrderFragmenter::updateChunkStats(), and Fragmenter_Namespace::InsertOrderFragmenter::updateColumns().

1087  {
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 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:330
HOST DEVICE int get_scale() const
Definition: sqltypes.h:334
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
EncodingType
Definition: sqltypes.h:233
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:337
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:331
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:338
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:336

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SQLTypeInfo get_nullable_logical_type_info ( const SQLTypeInfo type_info)
inline

Definition at line 1108 of file sqltypes.h.

References get_logical_type_info(), and get_nullable_type_info().

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::get_logical_type_for_expr(), and RelAlgTranslator::translateArrayFunction().

1108  {
1109  SQLTypeInfo nullable_type_info = get_logical_type_info(type_info);
1110  return get_nullable_type_info(nullable_type_info);
1111 }
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:1087
SQLTypeInfo get_nullable_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:1102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SQLTypeInfo get_nullable_type_info ( const SQLTypeInfo type_info)
inline

Definition at line 1102 of file sqltypes.h.

References SQLTypeInfo::set_notnull().

Referenced by CodeGenerator::createInValuesBitmap(), Analyzer::Constant::do_cast(), and get_nullable_logical_type_info().

1102  {
1103  SQLTypeInfo nullable_type_info = type_info;
1104  nullable_type_info.set_notnull(false);
1105  return nullable_type_info;
1106 }
void set_notnull(bool n)
Definition: sqltypes.h:436

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE constexpr bool is_cuda_compiler ( )
inline

Definition at line 199 of file sqltypes.h.

199  {
200 #ifdef __CUDACC__
201  return true;
202 #else
203  return false;
204 #endif
205 }
constexpr auto is_datetime ( SQLTypes  type)

Definition at line 263 of file sqltypes.h.

References kDATE, kTIME, and kTIMESTAMP.

Referenced by ColumnDescriptor::getDefaultValueLiteral(), SQLTypeInfo::is_time(), ArrowForeignStorageBase::replaceNullValues(), RexLiteral::RexLiteral(), and ddl_utils::validate_and_set_fixed_encoding().

263  {
264  return type == kTIME || type == kTIMESTAMP || type == kDATE;
265 }
Definition: sqltypes.h:49
Definition: sqltypes.h:53

+ Here is the caller graph for this function:

std::ostream& operator<< ( std::ostream &  os,
SQLTypes const  sql_type 
)
inline

Definition at line 143 of file sqltypes.h.

References toString().

143  {
144  os << toString(sql_type);
145  return os;
146 }
std::string toString(const Executor::ExtModuleKinds &kind)
Definition: Execute.h:1453

+ Here is the call graph for this function:

SQLTypes string_dict_to_int_type ( const SQLTypeInfo )

Definition at line 497 of file Datum.cpp.

References CHECK, SQLTypeInfo::get_size(), SQLTypeInfo::is_dict_encoded_string(), kINT, kNULLT, kSMALLINT, kTINYINT, and UNREACHABLE.

Referenced by append_datum(), import_export::anonymous_namespace{Importer.cpp}::get_type_for_datum(), and foreign_storage::ParquetFixedLengthArrayEncoder::setNullFixedLengthArraySentinel().

497  {
498  CHECK(ti.is_dict_encoded_string());
499  switch (ti.get_size()) {
500  case 1:
501  return kTINYINT;
502  case 2:
503  return kSMALLINT;
504  case 4:
505  return kINT;
506  default:
507  UNREACHABLE() << "Unexpected string dictionary encoding size: " << ti.get_size();
508  }
509  return kNULLT;
510 }
#define UNREACHABLE()
Definition: Logger.h:267
#define CHECK(condition)
Definition: Logger.h:223
Definition: sqltypes.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Datum StringToDatum ( std::string_view  s,
SQLTypeInfo ti 
)

Definition at line 275 of file Datum.cpp.

References Datum::bigintval, Datum::boolval, Datum::doubleval, Datum::floatval, SQLTypeInfo::get_dimension(), SQLTypeInfo::get_type(), SQLTypeInfo::get_type_name(), Datum::intval, kARRAY, kBIGINT, kBOOLEAN, kCOLUMN, kCOLUMN_LIST, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTIME, kTIMESTAMP, kTINYINT, parse_numeric(), Datum::smallintval, Datum::tinyintval, and to_upper().

Referenced by import_export::TypedImportBuffer::add_value(), import_export::TypedImportBuffer::addDefaultValues(), Parser::FixedPtLiteral::analyze(), Analyzer::Constant::cast_from_string(), anonymous_namespace{ArrowImporter.h}::ArrowValue< std::string >::operator DATA_TYPE(), populate_TColumn(), import_export::StringToArray(), and ddl_utils::anonymous_namespace{DdlUtils.cpp}::validate_literal().

275  {
276  Datum d;
277  try {
278  switch (ti.get_type()) {
279  case kARRAY:
280  case kCOLUMN:
281  case kCOLUMN_LIST:
282  break;
283  case kBOOLEAN:
284  if (s == "t" || s == "T" || s == "1" || to_upper(std::string(s)) == "TRUE") {
285  d.boolval = true;
286  } else if (s == "f" || s == "F" || s == "0" ||
287  to_upper(std::string(s)) == "FALSE") {
288  d.boolval = false;
289  } else {
290  throw std::runtime_error("Invalid string for boolean " + std::string(s));
291  }
292  break;
293  case kNUMERIC:
294  case kDECIMAL:
295  d.bigintval = parse_numeric(s, ti);
296  break;
297  case kBIGINT:
298  d.bigintval = parseInteger<int64_t>(s, ti);
299  break;
300  case kINT:
301  d.intval = parseInteger<int32_t>(s, ti);
302  break;
303  case kSMALLINT:
304  d.smallintval = parseInteger<int16_t>(s, ti);
305  break;
306  case kTINYINT:
307  d.tinyintval = parseInteger<int8_t>(s, ti);
308  break;
309  case kFLOAT:
310  d.floatval = std::stof(std::string(s));
311  break;
312  case kDOUBLE:
313  d.doubleval = std::stod(std::string(s));
314  break;
315  case kTIME:
316  d.bigintval = dateTimeParse<kTIME>(s, ti.get_dimension());
317  break;
318  case kTIMESTAMP:
319  d.bigintval = dateTimeParse<kTIMESTAMP>(s, ti.get_dimension());
320  break;
321  case kDATE:
322  d.bigintval = dateTimeParse<kDATE>(s, ti.get_dimension());
323  break;
324  case kPOINT:
325  case kLINESTRING:
326  case kPOLYGON:
327  case kMULTIPOLYGON:
328  throw std::runtime_error("Internal error: geometry type in StringToDatum.");
329  default:
330  throw std::runtime_error("Internal error: invalid type in StringToDatum: " +
331  ti.get_type_name());
332  }
333  } catch (const std::invalid_argument&) {
334  throw std::runtime_error("Invalid conversion from string to " + ti.get_type_name());
335  } catch (const std::out_of_range&) {
336  throw std::runtime_error("Got out of range error during conversion from string to " +
337  ti.get_type_name());
338  }
339  return d;
340 }
int8_t tinyintval
Definition: sqltypes.h:212
Definition: sqltypes.h:49
int64_t parse_numeric(const std::string_view s, SQLTypeInfo &ti)
Definition: Datum.cpp:108
int8_t boolval
Definition: sqltypes.h:211
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
int32_t intval
Definition: sqltypes.h:214
float floatval
Definition: sqltypes.h:216
int64_t bigintval
Definition: sqltypes.h:215
int16_t smallintval
Definition: sqltypes.h:213
std::string to_upper(const std::string &str)
Definition: sqltypes.h:53
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:331
std::string get_type_name() const
Definition: sqltypes.h:443
Definition: sqltypes.h:45
double doubleval
Definition: sqltypes.h:217

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string toString ( const SQLTypes type)
inline

Definition at line 74 of file sqltypes.h.

References logger::FATAL, kARRAY, kBIGINT, kBOOLEAN, kCHAR, kCOLUMN, kCOLUMN_LIST, kCURSOR, kDATE, kDECIMAL, kDOUBLE, kEVAL_CONTEXT_TYPE, kFLOAT, kGEOGRAPHY, kGEOMETRY, kINT, kINTERVAL_DAY_TIME, kINTERVAL_YEAR_MONTH, kLINESTRING, kMULTIPOLYGON, kNULLT, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kSQLTYPE_LAST, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, kVOID, LOG, and run_benchmark_import::type.

74  {
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 }
Definition: sqltypes.h:49
#define LOG(tag)
Definition: Logger.h:217
Definition: sqltypes.h:65
Definition: sqltypes.h:52
Definition: sqltypes.h:53
Definition: sqltypes.h:41
Definition: sqltypes.h:45