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

Constants for Builtin SQL Types supported by HEAVY.AI. More...

#include "../Logger/Logger.h"
#include "Datum.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 "../QueryEngine/Utils/FlatBuffer.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  DoNothingDeleter
 
struct  FreeDeleter
 
struct  HostArrayDatum
 
struct  DeviceArrayDatum
 
union  DataBlockPtr
 
class  SQLTypeInfo
 
struct  SqlLiteralArg
 

Namespaces

 sql_constants
 

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)
 
#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 IS_GEO_LINE(T)   (((T) == kLINESTRING) || ((T) == kMULTILINESTRING))
 
#define IS_GEO_MULTI(T)   (((T) == kMULTIPOLYGON) || ((T) == kMULTILINESTRING)) || ((T) == kMULTIPOINT))
 
#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, kMULTILINESTRING = 30, kMULTIPOINT = 31,
  kSQLTYPE_LAST = 32
}
 
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_ARRAY = 8, kENCODING_ARRAY_DICT = 9, kENCODING_LAST = 10
}
 

Functions

std::string toString (const SQLTypes &type)
 
std::ostream & operator<< (std::ostream &os, SQLTypes const sql_type)
 
DEVICE constexpr bool is_cuda_compiler ()
 
std::ostream & operator<< (std::ostream &os, EncodingType const type)
 
std::string toString (const EncodingType &type)
 
constexpr auto is_datetime (SQLTypes type)
 
SQLTypes decimal_to_int_type (const SQLTypeInfo &)
 
SQLTypes string_dict_to_int_type (const SQLTypeInfo &)
 
Datum NullDatum (const SQLTypeInfo &ti)
 
bool IsNullDatum (const Datum d, const SQLTypeInfo &ti)
 
Datum StringToDatum (const std::string_view s, SQLTypeInfo &ti)
 
std::string DatumToString (const 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_column_type (const SQLTypeInfo &elem_ti)
 
auto generate_column_list_type (const SQLTypeInfo &elem_ti)
 
int64_t getVarlenArrayBufferSize (int64_t items_count, int64_t max_nof_values, const SQLTypeInfo &ti)
 
void initializeVarlenArray (FlatBufferManager &m, int64_t items_count, int64_t max_nof_values, const SQLTypeInfo &ti)
 

Variables

static constexpr int32_t sql_constants::kMaxNumericPrecision
 
static constexpr int32_t sql_constants::kMaxRepresentableNumericPrecision
 

Detailed Description

Constants for Builtin SQL Types supported by HEAVY.AI.

Definition in file sqltypes.h.

Macro Definition Documentation

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

Definition at line 302 of file sqltypes.h.

#define IS_GEO_LINE (   T)    (((T) == kLINESTRING) || ((T) == kMULTILINESTRING))

Definition at line 304 of file sqltypes.h.

#define IS_GEO_MULTI (   T)    (((T) == kMULTIPOLYGON) || ((T) == kMULTILINESTRING)) || ((T) == kMULTIPOINT))

Definition at line 305 of file sqltypes.h.

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

Definition at line 301 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:60

Definition at line 294 of file sqltypes.h.

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

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

Definition at line 311 of file sqltypes.h.

Referenced by RowSetMemoryOwner::getOrAddStringDictProxy().

Typedef Documentation

Definition at line 217 of file sqltypes.h.

using ArrayOffsetT = int32_t

Definition at line 1225 of file sqltypes.h.

using StringOffsetT = int32_t

Definition at line 1224 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_ARRAY 
kENCODING_ARRAY_DICT 
kENCODING_LAST 

Definition at line 228 of file sqltypes.h.

228  {
229  kENCODING_NONE = 0, // no encoding
230  kENCODING_FIXED = 1, // Fixed-bit encoding
231  kENCODING_RL = 2, // Run Length encoding
232  kENCODING_DIFF = 3, // Differential encoding
233  kENCODING_DICT = 4, // Dictionary encoding
234  kENCODING_SPARSE = 5, // Null encoding for sparse columns
235  kENCODING_GEOINT = 6, // Encoding coordinates as intergers
236  kENCODING_DATE_IN_DAYS = 7, // Date encoding in days
237  kENCODING_ARRAY = 8, // Array encoding for columns of arrays
238  kENCODING_ARRAY_DICT = 9, // Array encoding for columns of text encoding dict arrays
239  kENCODING_LAST = 10
240 };
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 
kMULTILINESTRING 
kMULTIPOINT 
kSQLTYPE_LAST 

Definition at line 53 of file sqltypes.h.

53  {
54  kNULLT = 0, // type for null values
55  kBOOLEAN = 1,
56  kCHAR = 2,
57  kVARCHAR = 3,
58  kNUMERIC = 4,
59  kDECIMAL = 5,
60  kINT = 6,
61  kSMALLINT = 7,
62  kFLOAT = 8,
63  kDOUBLE = 9,
64  kTIME = 10,
65  kTIMESTAMP = 11,
66  kBIGINT = 12,
67  kTEXT = 13,
68  kDATE = 14,
69  kARRAY = 15,
70  kINTERVAL_DAY_TIME = 16,
72  kPOINT = 18,
73  kLINESTRING = 19,
74  kPOLYGON = 20,
75  kMULTIPOLYGON = 21,
76  kTINYINT = 22,
77  kGEOMETRY = 23,
78  kGEOGRAPHY = 24,
79  kEVAL_CONTEXT_TYPE = 25, // Placeholder Type for ANY
80  kVOID = 26,
81  kCURSOR = 27,
82  kCOLUMN = 28,
83  kCOLUMN_LIST = 29,
84  kMULTILINESTRING = 30,
85  kMULTIPOINT = 31,
86  kSQLTYPE_LAST = 32
87 };
Definition: sqltypes.h:64
Definition: sqltypes.h:80
Definition: sqltypes.h:67
Definition: sqltypes.h:68
Definition: sqltypes.h:56
Definition: sqltypes.h:60

Function Documentation

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

Definition at line 578 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().

578  {
579  SQLTypes type;
580  if (ti.is_dict_encoded_string()) {
581  type = string_dict_to_int_type(ti);
582  } else {
583  type = ti.get_type();
584  }
585  switch (type) {
586  case kBOOLEAN:
587  *(int8_t*)buf = d.boolval;
588  return buf + sizeof(int8_t);
589  case kNUMERIC:
590  case kDECIMAL:
591  case kBIGINT:
592  *(int64_t*)buf = d.bigintval;
593  return buf + sizeof(int64_t);
594  case kINT:
595  *(int32_t*)buf = d.intval;
596  return buf + sizeof(int32_t);
597  case kSMALLINT:
598  *(int16_t*)buf = d.smallintval;
599  return buf + sizeof(int16_t);
600  case kTINYINT:
601  *(int8_t*)buf = d.tinyintval;
602  return buf + sizeof(int8_t);
603  case kFLOAT:
604  *(float*)buf = d.floatval;
605  return buf + sizeof(float);
606  case kDOUBLE:
607  *(double*)buf = d.doubleval;
608  return buf + sizeof(double);
609  case kTIME:
610  case kTIMESTAMP:
611  case kDATE:
612  *reinterpret_cast<int64_t*>(buf) = d.bigintval;
613  return buf + sizeof(int64_t);
614  default:
615  UNREACHABLE() << "Unexpected type: " << type;
616  return nullptr;
617  }
618 }
int8_t tinyintval
Definition: Datum.h:46
Definition: sqltypes.h:64
SQLTypes
Definition: sqltypes.h:53
int8_t boolval
Definition: Datum.h:45
#define UNREACHABLE()
Definition: Logger.h:266
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
int32_t intval
Definition: Datum.h:48
float floatval
Definition: Datum.h:50
int64_t bigintval
Definition: Datum.h:49
int16_t smallintval
Definition: Datum.h:47
Definition: sqltypes.h:68
bool is_dict_encoded_string() const
Definition: sqltypes.h:627
Definition: sqltypes.h:60
double doubleval
Definition: Datum.h:51
SQLTypes string_dict_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:563

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

624  {
625  int const dscale = new_type_info.get_scale() - type_info.get_scale();
626  return convert_decimal_value_to_scale_internal(decimal_value, dscale);
627 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:384
int64_t convert_decimal_value_to_scale_internal(const int64_t decimal_value, int const dscale)
Definition: Datum.cpp:79

+ 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 406 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, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, Datum::smallintval, Datum::stringval, and Datum::tinyintval.

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

406  {
407  switch (ti.get_type()) {
408  case kBOOLEAN:
409  return a.boolval == b.boolval;
410  case kBIGINT:
411  case kNUMERIC:
412  case kDECIMAL:
413  return a.bigintval == b.bigintval;
414  case kINT:
415  return a.intval == b.intval;
416  case kSMALLINT:
417  return a.smallintval == b.smallintval;
418  case kTINYINT:
419  return a.tinyintval == b.tinyintval;
420  case kFLOAT:
421  return a.floatval == b.floatval;
422  case kDOUBLE:
423  return a.doubleval == b.doubleval;
424  case kTIME:
425  case kTIMESTAMP:
426  case kDATE:
427  case kINTERVAL_DAY_TIME:
429  return a.bigintval == b.bigintval;
430  case kTEXT:
431  case kVARCHAR:
432  case kCHAR:
433  case kPOINT:
434  case kMULTIPOINT:
435  case kLINESTRING:
436  case kMULTILINESTRING:
437  case kPOLYGON:
438  case kMULTIPOLYGON:
439  if (ti.get_compression() == kENCODING_DICT) {
440  return a.intval == b.intval;
441  }
442  if (a.stringval == nullptr && b.stringval == nullptr) {
443  return true;
444  }
445  if (a.stringval == nullptr || b.stringval == nullptr) {
446  return false;
447  }
448  return *a.stringval == *b.stringval;
449  default:
450  return false;
451  }
452  return false;
453 }
Definition: sqltypes.h:64
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
constexpr double a
Definition: Utm.h:32
Definition: sqltypes.h:67
Definition: sqltypes.h:68
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:387
Definition: sqltypes.h:56
Definition: sqltypes.h:60

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 458 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(), foreign_storage::TypedParquetInPlaceEncoder< V, V >::integralTypeToString(), anonymous_namespace{ArrowImporter.h}::ArrowValue< int64_t >::operator DATA_TYPE(), operator<<(), import_export::anonymous_namespace{QueryExporterCSV.cpp}::target_value_to_string(), Analyzer::Constant::toString(), Fragmenter_Namespace::InsertOrderFragmenter::updateChunkStats(), and ScalarExprToSql::visitConstant().

458  {
459  constexpr size_t buf_size = 64;
460  char buf[buf_size]; // Hold "2000-03-01 12:34:56.123456789" and large years.
461  switch (ti.get_type()) {
462  case kBOOLEAN:
463  if (d.boolval) {
464  return "t";
465  }
466  return "f";
467  case kNUMERIC:
468  case kDECIMAL: {
469  double v = (double)d.bigintval / pow(10, ti.get_scale());
470  int size = snprintf(buf, buf_size, "%*.*f", ti.get_dimension(), ti.get_scale(), v);
471  CHECK_LE(0, size) << v << ' ' << ti.to_string();
472  CHECK_LT(size_t(size), buf_size) << v << ' ' << ti.to_string();
473  return buf;
474  }
475  case kINT:
476  return std::to_string(d.intval);
477  case kSMALLINT:
478  return std::to_string(d.smallintval);
479  case kTINYINT:
480  return std::to_string(d.tinyintval);
481  case kBIGINT:
482  return std::to_string(d.bigintval);
483  case kFLOAT:
484  return std::to_string(d.floatval);
485  case kDOUBLE:
486  return std::to_string(d.doubleval);
487  case kTIME: {
488  size_t const len = shared::formatHMS(buf, buf_size, d.bigintval);
489  CHECK_EQ(8u, len); // 8 == strlen("HH:MM:SS")
490  return buf;
491  }
492  case kTIMESTAMP: {
493  unsigned const dim = ti.get_dimension(); // assumes dim <= 9
494  size_t const len = shared::formatDateTime(buf, buf_size, d.bigintval, dim);
495  CHECK_LE(19u + bool(dim) + dim, len); // 19 = strlen("YYYY-MM-DD HH:MM:SS")
496  return buf;
497  }
498  case kDATE: {
499  size_t const len = shared::formatDate(buf, buf_size, d.bigintval);
500  CHECK_LE(10u, len); // 10 == strlen("YYYY-MM-DD")
501  return buf;
502  }
503  case kINTERVAL_DAY_TIME:
504  return std::to_string(d.bigintval) + " ms (day-time interval)";
506  return std::to_string(d.bigintval) + " month(s) (year-month interval)";
507  case kTEXT:
508  case kVARCHAR:
509  case kCHAR:
510  if (d.stringval == nullptr) {
511  return "NULL";
512  }
513  return *d.stringval;
514  default:
515  throw std::runtime_error("Internal error: invalid type " + ti.get_type_name() +
516  " in DatumToString.");
517  }
518  return "";
519 }
int8_t tinyintval
Definition: Datum.h:46
#define CHECK_EQ(x, y)
Definition: Logger.h:230
Definition: sqltypes.h:64
HOST DEVICE int get_scale() const
Definition: sqltypes.h:384
int8_t boolval
Definition: Datum.h:45
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
int32_t intval
Definition: Datum.h:48
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: Datum.h:50
std::string to_string() const
Definition: sqltypes.h:543
int64_t bigintval
Definition: Datum.h:49
int16_t smallintval
Definition: Datum.h:47
std::string * stringval
Definition: Datum.h:54
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:232
Definition: sqltypes.h:67
Definition: sqltypes.h:68
#define CHECK_LE(x, y)
Definition: Logger.h:233
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:381
std::string get_type_name() const
Definition: sqltypes.h:503
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:56
Definition: sqltypes.h:60
double doubleval
Definition: Datum.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double extract_fp_type_from_datum ( const Datum  datum,
const SQLTypeInfo ti 
)

Definition at line 547 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().

547  {
548  const auto type = ti.get_type();
549  switch (type) {
550  case kFLOAT:
551  return datum.floatval;
552  case kDOUBLE:
553  return datum.doubleval;
554  default:
555  abort();
556  }
557 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
float floatval
Definition: Datum.h:50
double doubleval
Definition: Datum.h:51

+ 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 521 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(), ChunkMetadata::isPlaceholder(), and StringOps_Namespace::operator<<().

521  {
522  const auto type = ti.is_decimal() ? decimal_to_int_type(ti) : ti.get_type();
523  switch (type) {
524  case kBOOLEAN:
525  return datum.tinyintval;
526  case kTINYINT:
527  return datum.tinyintval;
528  case kSMALLINT:
529  return datum.smallintval;
530  case kCHAR:
531  case kVARCHAR:
532  case kTEXT:
534  case kINT:
535  return datum.intval;
536  case kBIGINT:
537  return datum.bigintval;
538  case kTIME:
539  case kTIMESTAMP:
540  case kDATE:
541  return datum.bigintval;
542  default:
543  abort();
544  }
545 }
int8_t tinyintval
Definition: Datum.h:46
#define CHECK_EQ(x, y)
Definition: Logger.h:230
Definition: sqltypes.h:64
int32_t intval
Definition: Datum.h:48
int64_t bigintval
Definition: Datum.h:49
int16_t smallintval
Definition: Datum.h:47
SQLTypes decimal_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:559
Definition: sqltypes.h:67
Definition: sqltypes.h:68
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:387
Definition: sqltypes.h:56
Definition: sqltypes.h:60
bool is_decimal() const
Definition: sqltypes.h:578

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

auto generate_column_list_type ( const SQLTypeInfo elem_ti)
inline

Definition at line 1401 of file sqltypes.h.

References generate_column_type(), kCOLUMN_LIST, kNULLT, and kTIMESTAMP.

Referenced by bind_function().

1401  {
1402  auto type_info = generate_column_type(elem_ti);
1403  if (type_info.get_subtype() != kNULLT) {
1404  type_info.set_type(kCOLUMN_LIST);
1405  }
1406  if (type_info.get_subtype() == kTIMESTAMP) {
1407  // ColumnList<Timestamp> is not supported, see QE-472
1408  type_info.set_subtype(kNULLT);
1409  }
1410  return type_info;
1411 }
auto generate_column_type(const SQLTypeInfo &elem_ti)
Definition: sqltypes.h:1353

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

auto generate_column_type ( const SQLTypeInfo elem_ti)
inline

Definition at line 1353 of file sqltypes.h.

References SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_compression(), SQLTypeInfo::get_dimension(), SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), IS_NUMBER, kARRAY, kBIGINT, kBOOLEAN, kCOLUMN, kDOUBLE, kENCODING_ARRAY, kENCODING_ARRAY_DICT, kENCODING_DICT, kENCODING_NONE, kFLOAT, kINT, kNULLT, kSMALLINT, kTEXT, kTIMESTAMP, and kTINYINT.

Referenced by bind_function(), and generate_column_list_type().

1353  {
1354  SQLTypes elem_type = elem_ti.get_type();
1355  if (elem_type == kCOLUMN) {
1356  return elem_ti;
1357  }
1358  auto c = elem_ti.get_compression();
1359  auto d = elem_ti.get_dimension();
1360  auto p = elem_ti.get_comp_param();
1361  switch (elem_type) {
1362  case kBOOLEAN:
1363  case kTINYINT:
1364  case kSMALLINT:
1365  case kINT:
1366  case kBIGINT:
1367  case kFLOAT:
1368  case kDOUBLE:
1369  if (c == kENCODING_NONE && p == 0) {
1370  break; // here and below `break` means supported element type
1371  // for extension functions
1372  }
1373  case kTEXT:
1374  if (c == kENCODING_DICT && p != 0) {
1375  break;
1376  }
1377  case kTIMESTAMP:
1378  if (c == kENCODING_NONE && p == 0 && (d == 9 || d == 6 || d == 0)) {
1379  break;
1380  }
1381  case kARRAY:
1382  elem_type = elem_ti.get_subtype();
1383  if (IS_NUMBER(elem_type) || elem_type == kBOOLEAN || elem_type == kTEXT) {
1384  if (c == kENCODING_NONE && p == 0) {
1385  c = kENCODING_ARRAY;
1386  break;
1387  } else if (c == kENCODING_DICT && p != 0) {
1389  break;
1390  }
1391  }
1392  default:
1393  elem_type = kNULLT; // indicates unsupported element type that
1394  // the caller needs to handle accordingly
1395  }
1396  auto ti = SQLTypeInfo(kCOLUMN, c, p, elem_type);
1397  ti.set_dimension(d);
1398  return ti;
1399 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:380
SQLTypes
Definition: sqltypes.h:53
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
Definition: sqltypes.h:67
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:387
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:381
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:388
Definition: sqltypes.h:60
#define IS_NUMBER(T)
Definition: sqltypes.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SQLTypes get_int_type_by_size ( size_t const  nbytes)
inline

Definition at line 1180 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().

1180  {
1181  switch (nbytes) {
1182  case 1:
1183  return kTINYINT;
1184  case 2:
1185  return kSMALLINT;
1186  case 4:
1187  return kINT;
1188  case 8:
1189  return kBIGINT;
1190  default:
1191 #if !(defined(__CUDACC__) || defined(NO_BOOST))
1192  UNREACHABLE() << "Invalid number of bytes=" << nbytes;
1193 #endif
1194  return {};
1195  }
1196 }
#define UNREACHABLE()
Definition: Logger.h:266
Definition: sqltypes.h:60

+ Here is the caller graph for this function:

SQLTypeInfo get_logical_type_info ( const SQLTypeInfo type_info)
inline

Definition at line 1198 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(), target_info::get_target_info_impl(), TableOptimizer::getDeletedColumnStats(), PerfectJoinHashTable::getHashJoinArgs(), getLeafColumnRange(), Parser::CaseExpr::normalize(), TableOptimizer::recomputeColumnMetadata(), Fragmenter_Namespace::InsertOrderFragmenter::updateChunkStats(), and Fragmenter_Namespace::InsertOrderFragmenter::updateColumns().

1198  {
1199  EncodingType encoding = type_info.get_compression();
1200  if (encoding == kENCODING_DATE_IN_DAYS ||
1201  (encoding == kENCODING_FIXED && type_info.get_type() != kARRAY)) {
1202  encoding = kENCODING_NONE;
1203  }
1204  return SQLTypeInfo(type_info.get_type(),
1205  type_info.get_dimension(),
1206  type_info.get_scale(),
1207  type_info.get_notnull(),
1208  encoding,
1209  type_info.get_comp_param(),
1210  type_info.get_subtype());
1211 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:380
HOST DEVICE int get_scale() const
Definition: sqltypes.h:384
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
EncodingType
Definition: sqltypes.h:228
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:387
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:381
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:388
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:386

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

1219  {
1220  SQLTypeInfo nullable_type_info = get_logical_type_info(type_info);
1221  return get_nullable_type_info(nullable_type_info);
1222 }
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:1198
SQLTypeInfo get_nullable_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:1213

+ 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 1213 of file sqltypes.h.

References SQLTypeInfo::set_notnull().

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

1213  {
1214  SQLTypeInfo nullable_type_info = type_info;
1215  nullable_type_info.set_notnull(false);
1216  return nullable_type_info;
1217 }
void set_notnull(bool n)
Definition: sqltypes.h:496

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t getVarlenArrayBufferSize ( int64_t  items_count,
int64_t  max_nof_values,
const SQLTypeInfo ti 
)
inline

Definition at line 1417 of file sqltypes.h.

References CHECK, SQLTypeInfo::get_elem_type(), SQLTypeInfo::get_size(), FlatBufferManager::get_VarlenArray_flatbuffer_size(), SQLTypeInfo::is_array(), and SQLTypeInfo::is_text_encoding_dict_array().

Referenced by TableFunctionManager::allocate_output_buffers(), and ColumnarResults::ColumnarResults().

1419  {
1420  CHECK(ti.is_array());
1421  const size_t array_item_size = ti.get_elem_type().get_size();
1422  if (ti.is_text_encoding_dict_array()) {
1424  items_count,
1425  max_nof_values,
1426  array_item_size,
1427  FlatBufferManager::DTypeMetadataKind::SIZE_DICTID);
1428  } else {
1430  items_count,
1431  max_nof_values,
1432  array_item_size,
1433  FlatBufferManager::DTypeMetadataKind::SIZE);
1434  }
1435 }
HOST DEVICE int get_size() const
Definition: sqltypes.h:389
bool is_text_encoding_dict_array() const
Definition: sqltypes.h:604
static int64_t get_VarlenArray_flatbuffer_size(int64_t items_count, int64_t max_nof_values, int64_t dtype_size, DTypeMetadataKind dtype_metadata_kind)
Definition: FlatBuffer.h:316
#define CHECK(condition)
Definition: Logger.h:222
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:956
bool is_array() const
Definition: sqltypes.h:583

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void initializeVarlenArray ( FlatBufferManager m,
int64_t  items_count,
int64_t  max_nof_values,
const SQLTypeInfo ti 
)
inline

Definition at line 1437 of file sqltypes.h.

References CHECK, SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_elem_type(), SQLTypeInfo::get_size(), FlatBufferManager::initializeVarlenArray(), SQLTypeInfo::is_array(), SQLTypeInfo::is_text_encoding_dict_array(), and FlatBufferManager::setDTypeMetadataDictId().

Referenced by TableFunctionManager::allocate_output_buffers(), and ColumnarResults::ColumnarResults().

1440  {
1441  CHECK(ti.is_array());
1442  const size_t array_item_size = ti.get_elem_type().get_size();
1443  if (ti.is_text_encoding_dict_array()) {
1444  m.initializeVarlenArray(items_count,
1445  max_nof_values,
1446  array_item_size,
1447  FlatBufferManager::DTypeMetadataKind::SIZE_DICTID);
1449  } else {
1450  m.initializeVarlenArray(items_count,
1451  max_nof_values,
1452  array_item_size,
1453  FlatBufferManager::DTypeMetadataKind::SIZE);
1454  }
1455 }
void initializeVarlenArray(int64_t items_count, int64_t max_nof_values, int64_t dtype_size, DTypeMetadataKind dtype_metadata_kind)
Definition: FlatBuffer.h:336
HOST DEVICE int get_size() const
Definition: sqltypes.h:389
bool is_text_encoding_dict_array() const
Definition: sqltypes.h:604
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:388
void setDTypeMetadataDictId(int32_t dict_id)
Definition: FlatBuffer.h:288
#define CHECK(condition)
Definition: Logger.h:222
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:956
bool is_array() const
Definition: sqltypes.h:583

+ 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 208 of file sqltypes.h.

208  {
209 #ifdef __CUDACC__
210  return true;
211 #else
212  return false;
213 #endif
214 }
constexpr auto is_datetime ( SQLTypes  type)

Definition at line 313 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().

313  {
314  return type == kTIME || type == kTIMESTAMP || type == kDATE;
315 }
Definition: sqltypes.h:64
Definition: sqltypes.h:68

+ Here is the caller graph for this function:

bool IsNullDatum ( const Datum  d,
const SQLTypeInfo ti 
)

Definition at line 329 of file Datum.cpp.

References DatumEqual(), and NullDatum().

Referenced by anonymous_namespace{ExpressionRewrite.cpp}::ConstantFoldingVisitor::visitStringOper().

329  {
330  const Datum null_datum = NullDatum(ti);
331  return DatumEqual(datum, null_datum, ti);
332 }
bool DatumEqual(const Datum a, const Datum b, const SQLTypeInfo &ti)
Definition: Datum.cpp:406
Datum NullDatum(const SQLTypeInfo &ti)
Definition: Datum.cpp:286
Definition: Datum.h:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Datum NullDatum ( const SQLTypeInfo ti)

Definition at line 286 of file Datum.cpp.

References Datum::bigintval, Datum::boolval, Datum::doubleval, Datum::floatval, import_export::anonymous_namespace{Importer.cpp}::get_type_for_datum(), inline_fixed_encoding_null_val(), Datum::intval, kBIGINT, kBOOLEAN, kDATE, kDOUBLE, kFLOAT, kINT, kLINESTRING, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, kPOINT, kPOLYGON, kSMALLINT, kTIME, kTIMESTAMP, kTINYINT, NULL_DOUBLE, NULL_FLOAT, Datum::smallintval, Datum::tinyintval, and run_benchmark_import::type.

Referenced by IsNullDatum(), import_export::NullArray(), and import_export::StringToArray().

286  {
287  Datum d;
288  const auto type = get_type_for_datum(ti);
289  switch (type) {
290  case kBOOLEAN:
292  break;
293  case kBIGINT:
295  break;
296  case kINT:
298  break;
299  case kSMALLINT:
301  break;
302  case kTINYINT:
304  break;
305  case kFLOAT:
306  d.floatval = NULL_FLOAT;
307  break;
308  case kDOUBLE:
310  break;
311  case kTIME:
312  case kTIMESTAMP:
313  case kDATE:
315  break;
316  case kPOINT:
317  case kMULTIPOINT:
318  case kLINESTRING:
319  case kMULTILINESTRING:
320  case kPOLYGON:
321  case kMULTIPOLYGON:
322  throw std::runtime_error("Internal error: geometry type in NullDatum.");
323  default:
324  throw std::runtime_error("Internal error: invalid type in NullDatum.");
325  }
326  return d;
327 }
int8_t tinyintval
Definition: Datum.h:46
#define NULL_DOUBLE
Definition: sqltypes.h:64
#define NULL_FLOAT
int8_t boolval
Definition: Datum.h:45
int32_t intval
Definition: Datum.h:48
float floatval
Definition: Datum.h:50
int64_t bigintval
Definition: Datum.h:49
int16_t smallintval
Definition: Datum.h:47
Definition: sqltypes.h:68
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:60
SQLTypes get_type_for_datum(const SQLTypeInfo &ti)
Definition: Importer.cpp:255
Definition: Datum.h:44
double doubleval
Definition: Datum.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 164 of file sqltypes.h.

References toString().

164  {
165  os << toString(sql_type);
166  return os;
167 }
std::string toString(const QueryDescriptionType &type)
Definition: Types.h:64

+ Here is the call graph for this function:

std::ostream& operator<< ( std::ostream &  os,
EncodingType const  type 
)
inline

Definition at line 244 of file sqltypes.h.

References logger::FATAL, kENCODING_ARRAY, kENCODING_ARRAY_DICT, kENCODING_DATE_IN_DAYS, kENCODING_DICT, kENCODING_DIFF, kENCODING_FIXED, kENCODING_GEOINT, kENCODING_LAST, kENCODING_NONE, kENCODING_RL, kENCODING_SPARSE, LOG, and run_benchmark_import::type.

244  {
245  switch (type) {
246  case kENCODING_NONE:
247  os << "NONE";
248  break;
249  case kENCODING_FIXED:
250  os << "FIXED";
251  break;
252  case kENCODING_RL:
253  os << "RL";
254  break;
255  case kENCODING_DIFF:
256  os << "DIFF";
257  break;
258  case kENCODING_DICT:
259  os << "DICT";
260  break;
261  case kENCODING_SPARSE:
262  os << "SPARSE";
263  break;
264  case kENCODING_GEOINT:
265  os << "GEOINT";
266  break;
268  os << "DATE_IN_DAYS";
269  break;
270  case kENCODING_ARRAY:
271  os << "ARRAY";
272  break;
274  os << "ARRAY_DICT";
275  break;
276  case kENCODING_LAST:
277  break;
278  default:
279  LOG(FATAL) << "Invalid EncodingType: " << type;
280  }
281  return os;
282 }
#define LOG(tag)
Definition: Logger.h:216
SQLTypes string_dict_to_int_type ( const SQLTypeInfo )

Definition at line 563 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(), anonymous_namespace{Datum.cpp}::get_type_for_datum(), and foreign_storage::ParquetFixedLengthArrayEncoder::setNullFixedLengthArraySentinel().

563  {
564  CHECK(ti.is_dict_encoded_string());
565  switch (ti.get_size()) {
566  case 1:
567  return kTINYINT;
568  case 2:
569  return kSMALLINT;
570  case 4:
571  return kINT;
572  default:
573  UNREACHABLE() << "Unexpected string dictionary encoding size: " << ti.get_size();
574  }
575  return kNULLT;
576 }
#define UNREACHABLE()
Definition: Logger.h:266
#define CHECK(condition)
Definition: Logger.h:222
Definition: sqltypes.h:60

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 337 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, kMULTILINESTRING, kMULTIPOINT, 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().

337  {
338  Datum d;
339  try {
340  switch (ti.get_type()) {
341  case kARRAY:
342  case kCOLUMN:
343  case kCOLUMN_LIST:
344  break;
345  case kBOOLEAN:
346  if (s == "t" || s == "T" || s == "1" || to_upper(std::string(s)) == "TRUE") {
347  d.boolval = true;
348  } else if (s == "f" || s == "F" || s == "0" ||
349  to_upper(std::string(s)) == "FALSE") {
350  d.boolval = false;
351  } else {
352  throw std::runtime_error("Invalid string for boolean " + std::string(s));
353  }
354  break;
355  case kNUMERIC:
356  case kDECIMAL:
357  d.bigintval = parse_numeric(s, ti);
358  break;
359  case kBIGINT:
360  d.bigintval = parseInteger<int64_t>(s, ti);
361  break;
362  case kINT:
363  d.intval = parseInteger<int32_t>(s, ti);
364  break;
365  case kSMALLINT:
366  d.smallintval = parseInteger<int16_t>(s, ti);
367  break;
368  case kTINYINT:
369  d.tinyintval = parseInteger<int8_t>(s, ti);
370  break;
371  case kFLOAT:
372  d.floatval = std::stof(std::string(s));
373  break;
374  case kDOUBLE:
375  d.doubleval = std::stod(std::string(s));
376  break;
377  case kTIME:
378  d.bigintval = dateTimeParse<kTIME>(s, ti.get_dimension());
379  break;
380  case kTIMESTAMP:
381  d.bigintval = dateTimeParse<kTIMESTAMP>(s, ti.get_dimension());
382  break;
383  case kDATE:
384  d.bigintval = dateTimeParse<kDATE>(s, ti.get_dimension());
385  break;
386  case kPOINT:
387  case kMULTIPOINT:
388  case kLINESTRING:
389  case kMULTILINESTRING:
390  case kPOLYGON:
391  case kMULTIPOLYGON:
392  throw std::runtime_error("Internal error: geometry type in StringToDatum.");
393  default:
394  throw std::runtime_error("Internal error: invalid type in StringToDatum: " +
395  ti.get_type_name());
396  }
397  } catch (const std::invalid_argument&) {
398  throw std::runtime_error("Invalid conversion from string to " + ti.get_type_name());
399  } catch (const std::out_of_range&) {
400  throw std::runtime_error("Got out of range error during conversion from string to " +
401  ti.get_type_name());
402  }
403  return d;
404 }
int8_t tinyintval
Definition: Datum.h:46
Definition: sqltypes.h:64
int64_t parse_numeric(const std::string_view s, SQLTypeInfo &ti)
Definition: Datum.cpp:110
int8_t boolval
Definition: Datum.h:45
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
int32_t intval
Definition: Datum.h:48
float floatval
Definition: Datum.h:50
int64_t bigintval
Definition: Datum.h:49
int16_t smallintval
Definition: Datum.h:47
std::string to_upper(const std::string &str)
Definition: sqltypes.h:68
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:381
std::string get_type_name() const
Definition: sqltypes.h:503
Definition: sqltypes.h:60
Definition: Datum.h:44
double doubleval
Definition: Datum.h:51

+ 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 91 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, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, kNULLT, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kSQLTYPE_LAST, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, kVOID, LOG, and run_benchmark_import::type.

91  {
92  switch (type) {
93  case kNULLT:
94  return "NULL";
95  case kBOOLEAN:
96  return "BOOL";
97  case kCHAR:
98  return "CHAR";
99  case kVARCHAR:
100  return "VARCHAR";
101  case kNUMERIC:
102  return "NUMERIC";
103  case kDECIMAL:
104  return "DECIMAL";
105  case kINT:
106  return "INT";
107  case kSMALLINT:
108  return "SMALLINT";
109  case kFLOAT:
110  return "FLOAT";
111  case kDOUBLE:
112  return "DOUBLE";
113  case kTIME:
114  return "TIME";
115  case kTIMESTAMP:
116  return "TIMESTAMP";
117  case kBIGINT:
118  return "BIGINT";
119  case kTEXT:
120  return "TEXT";
121  case kDATE:
122  return "DATE";
123  case kARRAY:
124  return "ARRAY";
125  case kINTERVAL_DAY_TIME:
126  return "DAY TIME INTERVAL";
128  return "YEAR MONTH INTERVAL";
129  case kPOINT:
130  return "POINT";
131  case kMULTIPOINT:
132  return "MULTIPOINT";
133  case kLINESTRING:
134  return "LINESTRING";
135  case kMULTILINESTRING:
136  return "MULTILINESTRING";
137  case kPOLYGON:
138  return "POLYGON";
139  case kMULTIPOLYGON:
140  return "MULTIPOLYGON";
141  case kTINYINT:
142  return "TINYINT";
143  case kGEOMETRY:
144  return "GEOMETRY";
145  case kGEOGRAPHY:
146  return "GEOGRAPHY";
147  case kEVAL_CONTEXT_TYPE:
148  return "UNEVALUATED ANY";
149  case kVOID:
150  return "VOID";
151  case kCURSOR:
152  return "CURSOR";
153  case kCOLUMN:
154  return "COLUMN";
155  case kCOLUMN_LIST:
156  return "COLUMN_LIST";
157  case kSQLTYPE_LAST:
158  break;
159  }
160  LOG(FATAL) << "Invalid SQL type: " << type;
161  return "";
162 }
Definition: sqltypes.h:64
#define LOG(tag)
Definition: Logger.h:216
Definition: sqltypes.h:80
Definition: sqltypes.h:67
Definition: sqltypes.h:68
Definition: sqltypes.h:56
Definition: sqltypes.h:60
std::string toString ( const EncodingType type)
inline

Definition at line 284 of file sqltypes.h.

References run_benchmark_import::type.

284  {
285  std::ostringstream ss;
286  ss << type;
287  return ss.str();
288 }