OmniSciDB  c1a53651b2
 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 "Shared/DbObjectKeys.h"
#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)   (-(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)
 
DEVICE void VarlenArray_get_nth (int8_t *buf, int n, ArrayDatum *result, bool *is_end)
 

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

#define IS_GEO (   T)
Value:
(((T) == kPOINT) || ((T) == kLINESTRING) || ((T) == kMULTILINESTRING) || \
((T) == kMULTIPOINT) || ((T) == kPOLYGON) || ((T) == kMULTIPOLYGON))

Definition at line 300 of file sqltypes.h.

Referenced by spatial_type::Distance::codegenLoads(), Catalog_Namespace::Catalog::expandGeoColumn(), SQLTypeInfo::get_type_name(), Executor::getColLazyFetchInfo(), anonymous_namespace{DdlCommandExecutor.cpp}::JsonColumnSqlType::getParam1(), anonymous_namespace{DdlCommandExecutor.cpp}::JsonColumnSqlType::getParam2(), EmbeddedDatabase::DBEngineImpl::getTableDetails(), import_export::import_thread_delimited(), SQLTypeInfo::is_geometry(), SQLTypeInfo::is_varlen(), ResultSet::isGeoColOnGpu(), DBHandler::populateThriftColumnType(), foreign_storage::TextFileBufferParser::processGeoColumn(), foreign_storage::TextFileBufferParser::processInvalidGeoColumn(), ThriftSerializers::target_meta_info_to_thrift(), thrift_to_name(), SQLTypeInfo::transforms(), RelAlgTranslator::translateGeoColumn(), RelAlgTranslator::translateGeoFunctionArg(), RelAlgTranslator::translateUnaryGeoFunction(), type_info_from_thrift(), ThriftSerializers::type_info_to_thrift(), ddl_utils::validate_and_set_type(), and anonymous_namespace{RelAlgExecutor.cpp}::RexUsedInputsVisitor::visitInput().

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

Definition at line 306 of file sqltypes.h.

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

Definition at line 307 of file sqltypes.h.

Referenced by spatial_type::NumGeometries::codegenLoads().

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

Definition at line 303 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:62

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

Referenced by RowSetMemoryOwner::getOrAddStringDictProxy().

Typedef Documentation

Definition at line 219 of file sqltypes.h.

using ArrayOffsetT = int32_t

Definition at line 1259 of file sqltypes.h.

using StringOffsetT = int32_t

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

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

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

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:69
Definition: sqltypes.h:66
SQLTypes
Definition: sqltypes.h:55
int8_t boolval
Definition: Datum.h:68
#define UNREACHABLE()
Definition: Logger.h:337
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
int32_t intval
Definition: Datum.h:71
float floatval
Definition: Datum.h:73
int64_t bigintval
Definition: Datum.h:72
int16_t smallintval
Definition: Datum.h:70
Definition: sqltypes.h:70
bool is_dict_encoded_string() const
Definition: sqltypes.h:632
Definition: sqltypes.h:62
double doubleval
Definition: Datum.h:74
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:386
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:66
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
constexpr double a
Definition: Utm.h:32
Definition: sqltypes.h:69
Definition: sqltypes.h:70
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:389
Definition: sqltypes.h:58
Definition: sqltypes.h:62

+ 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:69
#define CHECK_EQ(x, y)
Definition: Logger.h:301
Definition: sqltypes.h:66
HOST DEVICE int get_scale() const
Definition: sqltypes.h:386
int8_t boolval
Definition: Datum.h:68
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
int32_t intval
Definition: Datum.h:71
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:73
std::string to_string() const
Definition: sqltypes.h:547
int64_t bigintval
Definition: Datum.h:72
int16_t smallintval
Definition: Datum.h:70
std::string * stringval
Definition: Datum.h:77
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:303
Definition: sqltypes.h:69
Definition: sqltypes.h:70
#define CHECK_LE(x, y)
Definition: Logger.h:304
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:383
std::string get_type_name() const
Definition: sqltypes.h:507
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:58
Definition: sqltypes.h:62
double doubleval
Definition: Datum.h:74

+ 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:381
float floatval
Definition: Datum.h:73
double doubleval
Definition: Datum.h:74

+ 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:69
#define CHECK_EQ(x, y)
Definition: Logger.h:301
Definition: sqltypes.h:66
int32_t intval
Definition: Datum.h:71
int64_t bigintval
Definition: Datum.h:72
int16_t smallintval
Definition: Datum.h:70
SQLTypes decimal_to_int_type(const SQLTypeInfo &ti)
Definition: Datum.cpp:559
Definition: sqltypes.h:69
Definition: sqltypes.h:70
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:389
Definition: sqltypes.h:58
Definition: sqltypes.h:62
bool is_decimal() const
Definition: sqltypes.h:583

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

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

Referenced by bind_function().

1445  {
1446  auto type_info = generate_column_type(elem_ti);
1447  if (type_info.get_subtype() != kNULLT) {
1448  type_info.set_type(kCOLUMN_LIST);
1449  }
1450  if (type_info.get_subtype() == kTIMESTAMP) {
1451  // ColumnList<Timestamp> is not supported, see QE-472
1452  type_info.set_subtype(kNULLT);
1453  }
1454  return type_info;
1455 }
auto generate_column_type(const SQLTypeInfo &elem_ti)
Definition: sqltypes.h:1387

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

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

Referenced by bind_function(), and generate_column_list_type().

1387  {
1388  SQLTypes elem_type = elem_ti.get_type();
1389  if (elem_type == kCOLUMN) {
1390  if (elem_ti.get_subtype() == kVARCHAR) {
1391  auto new_elem_ti = elem_ti;
1392  new_elem_ti.set_subtype(kTEXT);
1393  return new_elem_ti;
1394  }
1395  return elem_ti;
1396  }
1397  auto c = elem_ti.get_compression();
1398  auto d = elem_ti.get_dimension();
1399  auto p = elem_ti.get_comp_param();
1400  switch (elem_type) {
1401  case kBOOLEAN:
1402  case kTINYINT:
1403  case kSMALLINT:
1404  case kINT:
1405  case kBIGINT:
1406  case kFLOAT:
1407  case kDOUBLE:
1408  if (c == kENCODING_NONE && p == 0) {
1409  break; // here and below `break` means supported element type
1410  // for extension functions
1411  }
1412  case kTEXT:
1413  case kVARCHAR:
1414  elem_type = kTEXT;
1415  if (c == kENCODING_DICT) {
1416  break;
1417  }
1418  case kTIMESTAMP:
1419  if (c == kENCODING_NONE && p == 0 && (d == 9 || d == 6 || d == 0)) {
1420  break;
1421  }
1422  case kARRAY:
1423  elem_type = elem_ti.get_subtype();
1424  if (IS_NUMBER(elem_type) || elem_type == kBOOLEAN || elem_type == kTEXT) {
1425  if (c == kENCODING_NONE && p == 0) {
1426  c = kENCODING_ARRAY;
1427  break;
1428  } else if (c == kENCODING_DICT && p != 0) {
1430  break;
1431  }
1432  }
1433  default:
1434  elem_type = kNULLT; // indicates unsupported element type that
1435  // the caller needs to handle accordingly
1436  }
1437  auto ti = SQLTypeInfo(kCOLUMN, c, p, elem_type);
1438  ti.set_dimension(d);
1439  if (c == kENCODING_DICT) {
1440  ti.setStringDictKey(elem_ti.getStringDictKey());
1441  }
1442  return ti;
1443 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:382
SQLTypes
Definition: sqltypes.h:55
HOST DEVICE void set_subtype(SQLTypes st)
Definition: sqltypes.h:494
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
Definition: sqltypes.h:69
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:389
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:383
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:392
Definition: sqltypes.h:62
#define IS_NUMBER(T)
Definition: sqltypes.h:296
const shared::StringDictKey & getStringDictKey() const
Definition: sqltypes.h:1021

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

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

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

1217  {
1218  switch (nbytes) {
1219  case 1:
1220  return kTINYINT;
1221  case 2:
1222  return kSMALLINT;
1223  case 4:
1224  return kINT;
1225  case 8:
1226  return kBIGINT;
1227  default:
1228 #if !(defined(__CUDACC__) || defined(NO_BOOST))
1229  UNREACHABLE() << "Invalid number of bytes=" << nbytes;
1230 #endif
1231  return {};
1232  }
1233 }
#define UNREACHABLE()
Definition: Logger.h:337
Definition: sqltypes.h:62

+ Here is the caller graph for this function:

SQLTypeInfo get_logical_type_info ( const SQLTypeInfo type_info)
inline

Definition at line 1235 of file sqltypes.h.

References SQLTypeInfo::get_compression(), SQLTypeInfo::get_type(), kARRAY, kENCODING_DATE_IN_DAYS, kENCODING_FIXED, kENCODING_NONE, and SQLTypeInfo::set_compression().

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

1235  {
1236  EncodingType encoding = type_info.get_compression();
1237  if (encoding == kENCODING_DATE_IN_DAYS ||
1238  (encoding == kENCODING_FIXED && type_info.get_type() != kARRAY)) {
1239  encoding = kENCODING_NONE;
1240  }
1241  auto type_info_copy = type_info;
1242  type_info_copy.set_compression(encoding);
1243  type_info_copy.setStorageSize();
1244  return type_info_copy;
1245 }
void set_compression(EncodingType c)
Definition: sqltypes.h:504
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
EncodingType
Definition: sqltypes.h:230
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:389

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

1253  {
1254  SQLTypeInfo nullable_type_info = get_logical_type_info(type_info);
1255  return get_nullable_type_info(nullable_type_info);
1256 }
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:1235
SQLTypeInfo get_nullable_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:1247

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

References SQLTypeInfo::set_notnull().

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

1247  {
1248  SQLTypeInfo nullable_type_info = type_info;
1249  nullable_type_info.set_notnull(false);
1250  return nullable_type_info;
1251 }
void set_notnull(bool n)
Definition: sqltypes.h:500

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

1463  {
1464  CHECK(ti.is_array());
1465  const size_t array_item_size = ti.get_elem_type().get_size();
1466  if (ti.is_text_encoding_dict_array()) {
1468  items_count,
1469  max_nof_values,
1470  array_item_size,
1471  FlatBufferManager::DTypeMetadataKind::SIZE_DICTID);
1472  } else {
1474  items_count,
1475  max_nof_values,
1476  array_item_size,
1477  FlatBufferManager::DTypeMetadataKind::SIZE);
1478  }
1479 }
HOST DEVICE int get_size() const
Definition: sqltypes.h:393
bool is_text_encoding_dict_array() const
Definition: sqltypes.h:609
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:343
#define CHECK(condition)
Definition: Logger.h:291
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:963
bool is_array() const
Definition: sqltypes.h:588

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

References CHECK, SQLTypeInfo::get_elem_type(), SQLTypeInfo::get_size(), SQLTypeInfo::getStringDictKey(), FlatBufferManager::initializeVarlenArray(), SQLTypeInfo::is_array(), SQLTypeInfo::is_text_encoding_dict_array(), and FlatBufferManager::setDTypeMetadataDictKey().

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

1484  {
1485  CHECK(ti.is_array());
1486  const size_t array_item_size = ti.get_elem_type().get_size();
1487  if (ti.is_text_encoding_dict_array()) {
1488  m.initializeVarlenArray(items_count,
1489  max_nof_values,
1490  array_item_size,
1491  FlatBufferManager::DTypeMetadataKind::SIZE_DICTID);
1492  const auto& dict_key = ti.getStringDictKey();
1493  m.setDTypeMetadataDictKey(dict_key.db_id, dict_key.dict_id);
1494  } else {
1495  m.initializeVarlenArray(items_count,
1496  max_nof_values,
1497  array_item_size,
1498  FlatBufferManager::DTypeMetadataKind::SIZE);
1499  }
1500 }
void initializeVarlenArray(int64_t items_count, int64_t max_nof_values, int64_t dtype_size, DTypeMetadataKind dtype_metadata_kind)
Definition: FlatBuffer.h:363
HOST DEVICE int get_size() const
Definition: sqltypes.h:393
bool is_text_encoding_dict_array() const
Definition: sqltypes.h:609
#define CHECK(condition)
Definition: Logger.h:291
void setDTypeMetadataDictKey(int32_t db_id, int32_t dict_id)
Definition: FlatBuffer.h:300
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:963
bool is_array() const
Definition: sqltypes.h:588
const shared::StringDictKey & getStringDictKey() const
Definition: sqltypes.h:1021

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

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

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

315  {
316  return type == kTIME || type == kTIMESTAMP || type == kDATE;
317 }
Definition: sqltypes.h:66
Definition: sqltypes.h:70

+ 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:67

+ 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:69
#define NULL_DOUBLE
Definition: sqltypes.h:66
#define NULL_FLOAT
int8_t boolval
Definition: Datum.h:68
int32_t intval
Definition: Datum.h:71
float floatval
Definition: Datum.h:73
int64_t bigintval
Definition: Datum.h:72
int16_t smallintval
Definition: Datum.h:70
Definition: sqltypes.h:70
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)
Definition: sqltypes.h:62
SQLTypes get_type_for_datum(const SQLTypeInfo &ti)
Definition: Importer.cpp:259
Definition: Datum.h:67
double doubleval
Definition: Datum.h:74

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

References toString().

166  {
167  os << toString(sql_type);
168  return os;
169 }
std::string toString(const ExecutorDeviceType &device_type)

+ Here is the call graph for this function:

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

Definition at line 246 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.

246  {
247  switch (type) {
248  case kENCODING_NONE:
249  os << "NONE";
250  break;
251  case kENCODING_FIXED:
252  os << "FIXED";
253  break;
254  case kENCODING_RL:
255  os << "RL";
256  break;
257  case kENCODING_DIFF:
258  os << "DIFF";
259  break;
260  case kENCODING_DICT:
261  os << "DICT";
262  break;
263  case kENCODING_SPARSE:
264  os << "SPARSE";
265  break;
266  case kENCODING_GEOINT:
267  os << "GEOINT";
268  break;
270  os << "DATE_IN_DAYS";
271  break;
272  case kENCODING_ARRAY:
273  os << "ARRAY";
274  break;
276  os << "ARRAY_DICT";
277  break;
278  case kENCODING_LAST:
279  break;
280  default:
281  LOG(FATAL) << "Invalid EncodingType: " << type;
282  }
283  return os;
284 }
#define LOG(tag)
Definition: Logger.h:285
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:337
#define CHECK(condition)
Definition: Logger.h:291
Definition: sqltypes.h:62

+ 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:69
Definition: sqltypes.h:66
int64_t parse_numeric(const std::string_view s, SQLTypeInfo &ti)
Definition: Datum.cpp:110
int8_t boolval
Definition: Datum.h:68
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
int32_t intval
Definition: Datum.h:71
float floatval
Definition: Datum.h:73
int64_t bigintval
Definition: Datum.h:72
int16_t smallintval
Definition: Datum.h:70
std::string to_upper(const std::string &str)
Definition: sqltypes.h:70
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:383
std::string get_type_name() const
Definition: sqltypes.h:507
Definition: sqltypes.h:62
Definition: Datum.h:67
double doubleval
Definition: Datum.h:74

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

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

Definition at line 286 of file sqltypes.h.

References run_benchmark_import::type.

286  {
287  std::ostringstream ss;
288  ss << type;
289  return ss.str();
290 }
DEVICE void VarlenArray_get_nth ( int8_t *  buf,
int  n,
ArrayDatum result,
bool *  is_end 
)
inline

Definition at line 1503 of file sqltypes.h.

References CHECK_EQ, and FlatBufferManager::getItem().

Referenced by ChunkIter_get_nth(), ChunkIter_get_nth_varlen(), and ResultSet::makeVarlenTargetValue().

1506  {
1507  FlatBufferManager m{buf};
1508  auto status = m.getItem(n, result->length, result->pointer, result->is_null);
1509  if (status == FlatBufferManager::Status::IndexError) {
1510  *is_end = true;
1511  result->length = 0;
1512  result->pointer = NULL;
1513  result->is_null = true;
1514  } else {
1515  *is_end = false;
1516 #ifndef __CUDACC__
1517  CHECK_EQ(status, FlatBufferManager::Status::Success);
1518 #endif
1519  }
1520 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
HOST DEVICE Status getItem(int64_t index, int64_t &size, int8_t *&dest, bool &is_null)
Definition: FlatBuffer.h:633
constexpr double n
Definition: Utm.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function: