OmniSciDB  6686921089
 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 "StringTransform.h"
#include "funcannotations.h"
#include <cassert>
#include <ctime>
#include <memory>
#include <ostream>
#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
 

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 &)
 
Datum StringToDatum (std::string_view s, SQLTypeInfo &ti)
 
std::string DatumToString (Datum d, 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)
 
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 * appendDatum (int8_t *buf, 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_INTEGER (   T)    (((T) == kINT) || ((T) == kSMALLINT) || ((T) == kBIGINT) || ((T) == kTINYINT))
#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 1076 of file sqltypes.h.

using StringOffsetT = int32_t

Definition at line 1075 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* appendDatum ( int8_t *  buf,
Datum  d,
const SQLTypeInfo ti 
)
inline

Definition at line 1078 of file sqltypes.h.

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

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

1078  {
1079  switch (ti.get_type()) {
1080  case kBOOLEAN:
1081  *(int8_t*)buf = d.boolval;
1082  return buf + sizeof(int8_t);
1083  case kNUMERIC:
1084  case kDECIMAL:
1085  case kBIGINT:
1086  *(int64_t*)buf = d.bigintval;
1087  return buf + sizeof(int64_t);
1088  case kINT:
1089  *(int32_t*)buf = d.intval;
1090  return buf + sizeof(int32_t);
1091  case kSMALLINT:
1092  *(int16_t*)buf = d.smallintval;
1093  return buf + sizeof(int16_t);
1094  case kTINYINT:
1095  *(int8_t*)buf = d.tinyintval;
1096  return buf + sizeof(int8_t);
1097  case kFLOAT:
1098  *(float*)buf = d.floatval;
1099  return buf + sizeof(float);
1100  case kDOUBLE:
1101  *(double*)buf = d.doubleval;
1102  return buf + sizeof(double);
1103  case kTIME:
1104  case kTIMESTAMP:
1105  case kDATE:
1106  *reinterpret_cast<int64_t*>(buf) = d.bigintval;
1107  return buf + sizeof(int64_t);
1108  default:
1109  return nullptr;
1110  }
1111 }
int8_t tinyintval
Definition: sqltypes.h:212
Definition: sqltypes.h:49
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
Definition: sqltypes.h:53
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:

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

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

475  {
476  int const dscale = new_type_info.get_scale() - type_info.get_scale();
477  return convert_decimal_value_to_scale_internal(decimal_value, dscale);
478 }
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:38
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(), 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:217
Definition: sqltypes.h:49
HOST DEVICE int get_scale() const
Definition: sqltypes.h:334
int8_t boolval
Definition: sqltypes.h:211
size_t formatDateTime(char *buf, size_t const max, int64_t const timestamp, int const dimension)
Definition: misc.cpp:43
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:80
float floatval
Definition: sqltypes.h:216
std::string to_string() const
Definition: sqltypes.h:472
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:25
#define CHECK_LT(x, y)
Definition: Logger.h:219
Definition: sqltypes.h:52
Definition: sqltypes.h:53
#define CHECK_LE(x, y)
Definition: Logger.h:220
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:331
std::string get_type_name() const
Definition: sqltypes.h:432
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 )

Definition at line 455 of file Datum.cpp.

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

Referenced by import_export::TypedImportBuffer::add_value(), CodeGenerator::codegen(), CodeGenerator::codegenIntConst(), anonymous_namespace{LogicalIR.cpp}::contains_unsafe_division(), extract_from_datum(), import_export::Loader::fillShardRow(), anonymous_namespace{ColumnIR.cpp}::get_col_decoder(), CgenState::getOrAddLiteral(), ResultSet::makeTargetValue(), import_export::NullArrayDatum(), import_export::NullDatum(), import_export::TypedImportBuffer::pop_value(), import_export::TDatumToDatum(), anonymous_namespace{ExpressionRewrite.cpp}::ConstantFoldingVisitor::visitBinOper(), and anonymous_namespace{ExpressionRewrite.cpp}::ConstantFoldingVisitor::visitUOper().

455  {
456  switch (ti.get_size()) {
457  case 1:
458  return kTINYINT;
459  case 2:
460  return kSMALLINT;
461  case 4:
462  return kINT;
463  case 8:
464  return kBIGINT;
465  default:
466  CHECK(false);
467  }
468  return kNULLT;
469 }
#define CHECK(condition)
Definition: Logger.h:209
Definition: sqltypes.h:45

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

References kARRAY.

Referenced by ext_arg_type_to_type_info().

1113  {
1114  auto ti = SQLTypeInfo(kARRAY, false);
1115  ti.set_subtype(subtype);
1116  return ti;
1117 }

+ Here is the caller graph for this function:

auto generate_column_list_type ( const SQLTypes  subtype)
inline

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

1133  {
1134  auto ti = SQLTypeInfo(kCOLUMN_LIST, false);
1135  ti.set_subtype(subtype);
1136  return ti;
1137 }

+ Here is the caller graph for this function:

auto generate_column_type ( const SQLTypes  subtype)
inline

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

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

+ Here is the caller graph for this function:

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

Definition at line 1125 of file sqltypes.h.

References kCOLUMN.

1125  {
1126  auto ti = SQLTypeInfo(kCOLUMN, false);
1127  ti.set_subtype(subtype);
1128  ti.set_compression(c);
1129  ti.set_comp_param(p);
1130  return ti;
1131 }
SQLTypeInfo get_logical_type_info ( const SQLTypeInfo type_info)
inline

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

1049  {
1050  EncodingType encoding = type_info.get_compression();
1051  if (encoding == kENCODING_DATE_IN_DAYS ||
1052  (encoding == kENCODING_FIXED && type_info.get_type() != kARRAY)) {
1053  encoding = kENCODING_NONE;
1054  }
1055  return SQLTypeInfo(type_info.get_type(),
1056  type_info.get_dimension(),
1057  type_info.get_scale(),
1058  type_info.get_notnull(),
1059  encoding,
1060  type_info.get_comp_param(),
1061  type_info.get_subtype());
1062 }
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 1070 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().

1070  {
1071  SQLTypeInfo nullable_type_info = get_logical_type_info(type_info);
1072  return get_nullable_type_info(nullable_type_info);
1073 }
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:1049
SQLTypeInfo get_nullable_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:1064

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

References SQLTypeInfo::set_notnull().

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

1064  {
1065  SQLTypeInfo nullable_type_info = type_info;
1066  nullable_type_info.set_notnull(false);
1067  return nullable_type_info;
1068 }
void set_notnull(bool n)
Definition: sqltypes.h:426

+ 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 ArrowForeignStorageBase::generateNullValues(), ArrowForeignStorageBase::generateSentinelValues(), ColumnDescriptor::getDefaultValueLiteral(), SQLTypeInfo::is_time(), 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 ExtArgumentType &sig_type)

+ Here is the call 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:432
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:203
Definition: sqltypes.h:65
Definition: sqltypes.h:52
Definition: sqltypes.h:53
Definition: sqltypes.h:41
Definition: sqltypes.h:45