OmniSciDB  21ac014ffc
 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 <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)
 
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 248 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 247 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:44

Definition at line 241 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 255 of file sqltypes.h.

Referenced by RowSetMemoryOwner::getOrAddStringDictProxy().

Typedef Documentation

Definition at line 202 of file sqltypes.h.

using ArrayOffsetT = int32_t

Definition at line 952 of file sqltypes.h.

using StringOffsetT = int32_t

Definition at line 951 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 227 of file sqltypes.h.

227  {
228  kENCODING_NONE = 0, // no encoding
229  kENCODING_FIXED = 1, // Fixed-bit encoding
230  kENCODING_RL = 2, // Run Length encoding
231  kENCODING_DIFF = 3, // Differential encoding
232  kENCODING_DICT = 4, // Dictionary encoding
233  kENCODING_SPARSE = 5, // Null encoding for sparse columns
234  kENCODING_GEOINT = 6, // Encoding coordinates as intergers
235  kENCODING_DATE_IN_DAYS = 7, // Date encoding in days
236  kENCODING_LAST = 8
237 };
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 37 of file sqltypes.h.

37  {
38  kNULLT = 0, // type for null values
39  kBOOLEAN = 1,
40  kCHAR = 2,
41  kVARCHAR = 3,
42  kNUMERIC = 4,
43  kDECIMAL = 5,
44  kINT = 6,
45  kSMALLINT = 7,
46  kFLOAT = 8,
47  kDOUBLE = 9,
48  kTIME = 10,
49  kTIMESTAMP = 11,
50  kBIGINT = 12,
51  kTEXT = 13,
52  kDATE = 14,
53  kARRAY = 15,
54  kINTERVAL_DAY_TIME = 16,
56  kPOINT = 18,
57  kLINESTRING = 19,
58  kPOLYGON = 20,
59  kMULTIPOLYGON = 21,
60  kTINYINT = 22,
61  kGEOMETRY = 23,
62  kGEOGRAPHY = 24,
63  kEVAL_CONTEXT_TYPE = 25, // Placeholder Type for ANY
64  kVOID = 26,
65  kCURSOR = 27,
66  kCOLUMN = 28,
67  kCOLUMN_LIST = 29,
68  kSQLTYPE_LAST = 30
69 };
Definition: sqltypes.h:48
Definition: sqltypes.h:64
Definition: sqltypes.h:51
Definition: sqltypes.h:52
Definition: sqltypes.h:40
Definition: sqltypes.h:44

Function Documentation

int8_t* appendDatum ( int8_t *  buf,
Datum  d,
const SQLTypeInfo ti 
)
inline

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

954  {
955  switch (ti.get_type()) {
956  case kBOOLEAN:
957  *(int8_t*)buf = d.boolval;
958  return buf + sizeof(int8_t);
959  case kNUMERIC:
960  case kDECIMAL:
961  case kBIGINT:
962  *(int64_t*)buf = d.bigintval;
963  return buf + sizeof(int64_t);
964  case kINT:
965  *(int32_t*)buf = d.intval;
966  return buf + sizeof(int32_t);
967  case kSMALLINT:
968  *(int16_t*)buf = d.smallintval;
969  return buf + sizeof(int16_t);
970  case kTINYINT:
971  *(int8_t*)buf = d.tinyintval;
972  return buf + sizeof(int8_t);
973  case kFLOAT:
974  *(float*)buf = d.floatval;
975  return buf + sizeof(float);
976  case kDOUBLE:
977  *(double*)buf = d.doubleval;
978  return buf + sizeof(double);
979  case kTIME:
980  case kTIMESTAMP:
981  case kDATE:
982  *reinterpret_cast<int64_t*>(buf) = d.bigintval;
983  return buf + sizeof(int64_t);
984  default:
985  return nullptr;
986  }
987 }
int8_t tinyintval
Definition: sqltypes.h:206
Definition: sqltypes.h:48
int8_t boolval
Definition: sqltypes.h:205
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:323
int32_t intval
Definition: sqltypes.h:208
float floatval
Definition: sqltypes.h:210
int64_t bigintval
Definition: sqltypes.h:209
int16_t smallintval
Definition: sqltypes.h:207
Definition: sqltypes.h:52
Definition: sqltypes.h:44
double doubleval
Definition: sqltypes.h:211

+ 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 437 of file Datum.cpp.

References SQLTypeInfo::get_scale().

Referenced by import_export::TypedImportBuffer::add_value(), Analyzer::Constant::cast_number(), anonymous_namespace{ArrowImporter.h}::ArrowValue< arrow::Decimal128 >::operator DATA_TYPE(), and anonymous_namespace{TypedDataAccessors.h}::put_scalar().

439  {
440  constexpr int max_scale = std::numeric_limits<uint64_t>::digits10; // 19
441  constexpr auto pow10 = shared::powersOf<uint64_t, max_scale + 1>(10);
442  int const dscale = new_type_info.get_scale() - type_info.get_scale();
443  if (dscale < 0) {
444  if (dscale < -max_scale) {
445  return 0; // +/- 0.09223372036854775807 rounds to 0
446  }
447  uint64_t const u = std::abs(decimal_value);
448  uint64_t const pow = pow10[-dscale];
449  uint64_t div = u / pow;
450  uint64_t rem = u % pow;
451  div += pow / 2 <= rem;
452  return decimal_value < 0 ? -div : div;
453  } else if (dscale < max_scale) {
454  int64_t retval;
455  if (!__builtin_mul_overflow(decimal_value, pow10[dscale], &retval)) {
456  return retval;
457  }
458  }
459  if (decimal_value == 0) {
460  return 0;
461  }
462  throw std::runtime_error("Overflow in DECIMAL-to-DECIMAL conversion.");
463 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:328

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

306  {
307  switch (ti.get_type()) {
308  case kBOOLEAN:
309  return a.boolval == b.boolval;
310  case kBIGINT:
311  case kNUMERIC:
312  case kDECIMAL:
313  return a.bigintval == b.bigintval;
314  case kINT:
315  return a.intval == b.intval;
316  case kSMALLINT:
317  return a.smallintval == b.smallintval;
318  case kTINYINT:
319  return a.tinyintval == b.tinyintval;
320  case kFLOAT:
321  return a.floatval == b.floatval;
322  case kDOUBLE:
323  return a.doubleval == b.doubleval;
324  case kTIME:
325  case kTIMESTAMP:
326  case kDATE:
327  case kINTERVAL_DAY_TIME:
329  return a.bigintval == b.bigintval;
330  case kTEXT:
331  case kVARCHAR:
332  case kCHAR:
333  case kPOINT:
334  case kLINESTRING:
335  case kPOLYGON:
336  case kMULTIPOLYGON:
337  if (ti.get_compression() == kENCODING_DICT) {
338  return a.intval == b.intval;
339  }
340  if (a.stringval == nullptr && b.stringval == nullptr) {
341  return true;
342  }
343  if (a.stringval == nullptr || b.stringval == nullptr) {
344  return false;
345  }
346  return *a.stringval == *b.stringval;
347  default:
348  return false;
349  }
350  return false;
351 }
Definition: sqltypes.h:48
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:323
Definition: sqltypes.h:51
Definition: sqltypes.h:52
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:331
Definition: sqltypes.h:40
Definition: sqltypes.h:44

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

356  {
357  constexpr size_t buf_size = 64;
358  char buf[buf_size]; // Hold "2000-03-01 12:34:56.123456789" and large years.
359  switch (ti.get_type()) {
360  case kBOOLEAN:
361  if (d.boolval) {
362  return "t";
363  }
364  return "f";
365  case kNUMERIC:
366  case kDECIMAL: {
367  double v = (double)d.bigintval / pow(10, ti.get_scale());
368  int size = snprintf(buf, buf_size, "%*.*f", ti.get_dimension(), ti.get_scale(), v);
369  CHECK_LE(0, size) << v << ' ' << ti.to_string();
370  CHECK_LT(size_t(size), buf_size) << v << ' ' << ti.to_string();
371  return buf;
372  }
373  case kINT:
374  return std::to_string(d.intval);
375  case kSMALLINT:
376  return std::to_string(d.smallintval);
377  case kTINYINT:
378  return std::to_string(d.tinyintval);
379  case kBIGINT:
380  return std::to_string(d.bigintval);
381  case kFLOAT:
382  return std::to_string(d.floatval);
383  case kDOUBLE:
384  return std::to_string(d.doubleval);
385  case kTIME: {
386  size_t const len = shared::formatHMS(buf, buf_size, d.bigintval);
387  CHECK_EQ(8u, len); // 8 == strlen("HH:MM:SS")
388  return buf;
389  }
390  case kTIMESTAMP: {
391  unsigned const dim = ti.get_dimension(); // assumes dim <= 9
392  size_t const len = shared::formatDateTime(buf, buf_size, d.bigintval, dim);
393  CHECK_LE(19u + bool(dim) + dim, len); // 19 = strlen("YYYY-MM-DD HH:MM:SS")
394  return buf;
395  }
396  case kDATE: {
397  size_t const len = shared::formatDate(buf, buf_size, d.bigintval);
398  CHECK_LE(10u, len); // 10 == strlen("YYYY-MM-DD")
399  return buf;
400  }
401  case kINTERVAL_DAY_TIME:
402  return std::to_string(d.bigintval) + " ms (day-time interval)";
404  return std::to_string(d.bigintval) + " month(s) (year-month interval)";
405  case kTEXT:
406  case kVARCHAR:
407  case kCHAR:
408  if (d.stringval == nullptr) {
409  return "NULL";
410  }
411  return *d.stringval;
412  default:
413  throw std::runtime_error("Internal error: invalid type " + ti.get_type_name() +
414  " in DatumToString.");
415  }
416  return "";
417 }
int8_t tinyintval
Definition: sqltypes.h:206
#define CHECK_EQ(x, y)
Definition: Logger.h:214
Definition: sqltypes.h:48
HOST DEVICE int get_scale() const
Definition: sqltypes.h:328
int8_t boolval
Definition: sqltypes.h:205
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:323
int32_t intval
Definition: sqltypes.h:208
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:210
std::string to_string() const
Definition: sqltypes.h:466
int64_t bigintval
Definition: sqltypes.h:209
int16_t smallintval
Definition: sqltypes.h:207
std::string * stringval
Definition: sqltypes.h:214
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:216
Definition: sqltypes.h:51
Definition: sqltypes.h:52
#define CHECK_LE(x, y)
Definition: Logger.h:217
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:325
std::string get_type_name() const
Definition: sqltypes.h:426
Definition: sqltypes.h:40
Definition: sqltypes.h:44
double doubleval
Definition: sqltypes.h:211

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

419  {
420  switch (ti.get_size()) {
421  case 1:
422  return kTINYINT;
423  case 2:
424  return kSMALLINT;
425  case 4:
426  return kINT;
427  case 8:
428  return kBIGINT;
429  default:
430  CHECK(false);
431  }
432  return kNULLT;
433 }
#define CHECK(condition)
Definition: Logger.h:206
Definition: sqltypes.h:44

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

References kARRAY.

Referenced by ext_arg_type_to_type_info().

989  {
990  auto ti = SQLTypeInfo(kARRAY, false);
991  ti.set_subtype(subtype);
992  return ti;
993 }

+ Here is the caller graph for this function:

auto generate_column_list_type ( const SQLTypes  subtype)
inline

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

1009  {
1010  auto ti = SQLTypeInfo(kCOLUMN_LIST, false);
1011  ti.set_subtype(subtype);
1012  return ti;
1013 }

+ Here is the caller graph for this function:

auto generate_column_type ( const SQLTypes  subtype)
inline

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

995  {
996  auto ti = SQLTypeInfo(kCOLUMN, false);
997  ti.set_subtype(subtype);
998  return ti;
999 }

+ Here is the caller graph for this function:

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

Definition at line 1001 of file sqltypes.h.

References kCOLUMN.

1001  {
1002  auto ti = SQLTypeInfo(kCOLUMN, false);
1003  ti.set_subtype(subtype);
1004  ti.set_compression(c);
1005  ti.set_comp_param(p);
1006  return ti;
1007 }
SQLTypeInfo get_logical_type_info ( const SQLTypeInfo type_info)
inline

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

925  {
926  EncodingType encoding = type_info.get_compression();
927  if (encoding == kENCODING_DATE_IN_DAYS ||
928  (encoding == kENCODING_FIXED && type_info.get_type() != kARRAY)) {
929  encoding = kENCODING_NONE;
930  }
931  return SQLTypeInfo(type_info.get_type(),
932  type_info.get_dimension(),
933  type_info.get_scale(),
934  type_info.get_notnull(),
935  encoding,
936  type_info.get_comp_param(),
937  type_info.get_subtype());
938 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:324
HOST DEVICE int get_scale() const
Definition: sqltypes.h:328
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:323
EncodingType
Definition: sqltypes.h:227
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:331
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:325
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:332
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:330

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

946  {
947  SQLTypeInfo nullable_type_info = get_logical_type_info(type_info);
948  return get_nullable_type_info(nullable_type_info);
949 }
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:925
SQLTypeInfo get_nullable_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:940

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

References SQLTypeInfo::set_notnull().

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

940  {
941  SQLTypeInfo nullable_type_info = type_info;
942  nullable_type_info.set_notnull(false);
943  return nullable_type_info;
944 }
void set_notnull(bool n)
Definition: sqltypes.h:420

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

193  {
194 #ifdef __CUDACC__
195  return true;
196 #else
197  return false;
198 #endif
199 }
constexpr auto is_datetime ( SQLTypes  type)

Definition at line 257 of file sqltypes.h.

References kDATE, kTIME, and kTIMESTAMP.

Referenced by ArrowForeignStorageBase::generateNullValues(), ArrowForeignStorageBase::generateSentinelValues(), SQLTypeInfo::is_time(), RexLiteral::RexLiteral(), and ddl_utils::validate_and_set_fixed_encoding().

257  {
258  return type == kTIME || type == kTIMESTAMP || type == kDATE;
259 }
Definition: sqltypes.h:48
Definition: sqltypes.h:52

+ Here is the caller graph for this function:

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

Definition at line 239 of file Datum.cpp.

References Datum::bigintval, Datum::boolval, test_fsi::d, 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(), Parser::FixedPtLiteral::analyze(), Analyzer::Constant::cast_from_string(), anonymous_namespace{ArrowImporter.h}::ArrowValue< std::string >::operator DATA_TYPE(), populate_TColumn(), and import_export::StringToArray().

239  {
240  Datum d;
241  try {
242  switch (ti.get_type()) {
243  case kARRAY:
244  case kCOLUMN:
245  case kCOLUMN_LIST:
246  break;
247  case kBOOLEAN:
248  if (s == "t" || s == "T" || s == "1" || to_upper(std::string(s)) == "TRUE") {
249  d.boolval = true;
250  } else if (s == "f" || s == "F" || s == "0" ||
251  to_upper(std::string(s)) == "FALSE") {
252  d.boolval = false;
253  } else {
254  throw std::runtime_error("Invalid string for boolean " + std::string(s));
255  }
256  break;
257  case kNUMERIC:
258  case kDECIMAL:
259  d.bigintval = parse_numeric(s, ti);
260  break;
261  case kBIGINT:
262  d.bigintval = parseInteger<int64_t>(s, ti);
263  break;
264  case kINT:
265  d.intval = parseInteger<int32_t>(s, ti);
266  break;
267  case kSMALLINT:
268  d.smallintval = parseInteger<int16_t>(s, ti);
269  break;
270  case kTINYINT:
271  d.tinyintval = parseInteger<int8_t>(s, ti);
272  break;
273  case kFLOAT:
274  d.floatval = std::stof(std::string(s));
275  break;
276  case kDOUBLE:
277  d.doubleval = std::stod(std::string(s));
278  break;
279  case kTIME:
280  d.bigintval = dateTimeParse<kTIME>(s, ti.get_dimension());
281  break;
282  case kTIMESTAMP:
283  d.bigintval = dateTimeParse<kTIMESTAMP>(s, ti.get_dimension());
284  break;
285  case kDATE:
286  d.bigintval = dateTimeParse<kDATE>(s, ti.get_dimension());
287  break;
288  case kPOINT:
289  case kLINESTRING:
290  case kPOLYGON:
291  case kMULTIPOLYGON:
292  throw std::runtime_error("Internal error: geometry type in StringToDatum.");
293  default:
294  throw std::runtime_error("Internal error: invalid type in StringToDatum: " +
295  ti.get_type_name());
296  }
297  } catch (const std::invalid_argument&) {
298  throw std::runtime_error("Invalid conversion from string to " + ti.get_type_name());
299  } catch (const std::out_of_range&) {
300  throw std::runtime_error("Got out of range error during conversion from string to " +
301  ti.get_type_name());
302  }
303  return d;
304 }
int8_t tinyintval
Definition: sqltypes.h:206
Definition: sqltypes.h:48
tuple d
Definition: test_fsi.py:9
int64_t parse_numeric(const std::string_view s, SQLTypeInfo &ti)
Definition: Datum.cpp:75
int8_t boolval
Definition: sqltypes.h:205
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:323
int32_t intval
Definition: sqltypes.h:208
float floatval
Definition: sqltypes.h:210
int64_t bigintval
Definition: sqltypes.h:209
int16_t smallintval
Definition: sqltypes.h:207
std::string to_upper(const std::string &str)
Definition: sqltypes.h:52
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:325
std::string get_type_name() const
Definition: sqltypes.h:426
Definition: sqltypes.h:44
double doubleval
Definition: sqltypes.h:211

+ 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 73 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.

73  {
74  switch (type) {
75  case kNULLT:
76  return "NULL";
77  case kBOOLEAN:
78  return "BOOL";
79  case kCHAR:
80  return "CHAR";
81  case kVARCHAR:
82  return "VARCHAR";
83  case kNUMERIC:
84  return "NUMERIC";
85  case kDECIMAL:
86  return "DECIMAL";
87  case kINT:
88  return "INT";
89  case kSMALLINT:
90  return "SMALLINT";
91  case kFLOAT:
92  return "FLOAT";
93  case kDOUBLE:
94  return "DOUBLE";
95  case kTIME:
96  return "TIME";
97  case kTIMESTAMP:
98  return "TIMESTAMP";
99  case kBIGINT:
100  return "BIGINT";
101  case kTEXT:
102  return "TEXT";
103  case kDATE:
104  return "DATE";
105  case kARRAY:
106  return "ARRAY";
107  case kINTERVAL_DAY_TIME:
108  return "DAY TIME INTERVAL";
110  return "YEAR MONTH INTERVAL";
111  case kPOINT:
112  return "POINT";
113  case kLINESTRING:
114  return "LINESTRING";
115  case kPOLYGON:
116  return "POLYGON";
117  case kMULTIPOLYGON:
118  return "MULTIPOLYGON";
119  case kTINYINT:
120  return "TINYINT";
121  case kGEOMETRY:
122  return "GEOMETRY";
123  case kGEOGRAPHY:
124  return "GEOGRAPHY";
125  case kEVAL_CONTEXT_TYPE:
126  return "UNEVALUATED ANY";
127  case kVOID:
128  return "VOID";
129  case kCURSOR:
130  return "CURSOR";
131  case kCOLUMN:
132  return "COLUMN";
133  case kCOLUMN_LIST:
134  return "COLUMN_LIST";
135  case kSQLTYPE_LAST:
136  break;
137  }
138  LOG(FATAL) << "Invalid SQL type: " << type;
139  return "";
140 }
Definition: sqltypes.h:48
#define LOG(tag)
Definition: Logger.h:200
Definition: sqltypes.h:64
Definition: sqltypes.h:51
Definition: sqltypes.h:52
Definition: sqltypes.h:40
Definition: sqltypes.h:44