OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 <cfloat>
#include <cstdint>
#include <ctime>
#include <limits>
#include <memory>
#include <string>
#include <type_traits>
#include <vector>
#include <string_view>
#include "../QueryEngine/DateAdd.h"
#include "../QueryEngine/DateTruncate.h"
#include "../QueryEngine/ExtractFromTime.h"
#include "InlineNullValues.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 NULL_BOOLEAN   INT8_MIN
 
#define NULL_TINYINT   INT8_MIN
 
#define NULL_SMALLINT   INT16_MIN
 
#define NULL_INT   INT32_MIN
 
#define NULL_BIGINT   INT64_MIN
 
#define NULL_FLOAT   FLT_MIN
 
#define NULL_DOUBLE   DBL_MIN
 
#define NULL_ARRAY_BOOLEAN   (INT8_MIN + 1)
 
#define NULL_ARRAY_TINYINT   (INT8_MIN + 1)
 
#define NULL_ARRAY_SMALLINT   (INT16_MIN + 1)
 
#define NULL_ARRAY_INT   (INT32_MIN + 1)
 
#define NULL_ARRAY_BIGINT   (INT64_MIN + 1)
 
#define NULL_ARRAY_FLOAT   (FLT_MIN * 2.0)
 
#define NULL_ARRAY_DOUBLE   (DBL_MIN * 2.0)
 
#define NULL_ARRAY_COMPRESSED_32   0x80000000U
 
#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, kSQLTYPE_LAST = 29
}
 
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)
 
template<class T >
constexpr int64_t inline_int_null_value ()
 
template<class T >
constexpr int64_t inline_int_null_array_value ()
 
template<class T >
constexpr int64_t max_valid_int_value ()
 
int8_t * appendDatum (int8_t *buf, Datum d, const SQLTypeInfo &ti)
 

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_GEO_POLY (   T)    (((T) == kPOLYGON) || ((T) == kMULTIPOLYGON))
#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:47

Definition at line 241 of file sqltypes.h.

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

#define NULL_ARRAY_BIGINT   (INT64_MIN + 1)
#define NULL_ARRAY_BOOLEAN   (INT8_MIN + 1)

Definition at line 259 of file sqltypes.h.

Referenced by FixedLengthArrayNoneEncoder::is_null().

#define NULL_ARRAY_COMPRESSED_32   0x80000000U

Definition at line 267 of file sqltypes.h.

Referenced by SQLTypeInfo::is_null_point_coord_array().

#define NULL_ARRAY_INT   (INT32_MIN + 1)
#define NULL_ARRAY_SMALLINT   (INT16_MIN + 1)
#define NULL_ARRAY_TINYINT   (INT8_MIN + 1)
#define NULL_DOUBLE   DBL_MIN

Definition at line 257 of file sqltypes.h.

Referenced by import_export::TypedImportBuffer::add_value(), import_export::TypedImportBuffer::add_values(), Parser::InsertValuesStmt::analyze(), CodeGenerator::codegenDiv(), CodeGenerator::codegenFpArith(), CodeGenerator::codegenIsNullNumber(), Geospatial::compress_null_point(), GeoPointValueConverter::convertToColumnarFormat(), GeoLinestringValueConverter::convertToColumnarFormat(), GeoPolygonValueConverter::convertToColumnarFormat(), GeoMultiPolygonValueConverter::convertToColumnarFormat(), import_export::QueryExporterCSV::exportResults(), float_to_double_bin(), Geospatial::GeoPoint::getColumns(), Geospatial::GeoLineString::getColumns(), Geospatial::GeoPolygon::getColumns(), Geospatial::GeoMultiPolygon::getColumns(), Geospatial::GeoTypesFactory::getNullGeoColumns(), inline_fp_null_value< double >(), CgenState::inlineFpNull(), import_export::anonymous_namespace{QueryExporterGDAL.cpp}::insert_array_column(), import_export::anonymous_namespace{QueryExporterGDAL.cpp}::insert_scalar_column(), SQLTypeInfo::is_null(), Analyzer::anonymous_namespace{Analyzer.cpp}::is_null_value(), ResultSet::isNull(), ResultSet::makeTargetValue(), import_export::NullDatum(), import_export::Importer::set_geo_physical_import_buffer(), import_export::Importer::set_geo_physical_import_buffer_columnar(), Analyzer::Constant::set_null_value(), import_export::TDatumToDatum(), FixedLengthArrayNoneEncoder::update_elem_stats(), ArrayNoneEncoder::update_elem_stats(), DBHandler::value_to_thrift(), and DBHandler::value_to_thrift_column().

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

Definition at line 271 of file sqltypes.h.

Referenced by Executor::getStringDictionaryProxy().

Typedef Documentation

Definition at line 202 of file sqltypes.h.

using ArrayOffsetT = int32_t

Definition at line 948 of file sqltypes.h.

using StringOffsetT = int32_t

Definition at line 947 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 
kSQLTYPE_LAST 

Definition at line 40 of file sqltypes.h.

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

Function Documentation

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

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

950  {
951  switch (ti.get_type()) {
952  case kBOOLEAN:
953  *(bool*)buf = d.boolval;
954  return buf + sizeof(bool);
955  case kNUMERIC:
956  case kDECIMAL:
957  case kBIGINT:
958  *(int64_t*)buf = d.bigintval;
959  return buf + sizeof(int64_t);
960  case kINT:
961  *(int32_t*)buf = d.intval;
962  return buf + sizeof(int32_t);
963  case kSMALLINT:
964  *(int16_t*)buf = d.smallintval;
965  return buf + sizeof(int16_t);
966  case kTINYINT:
967  *(int8_t*)buf = d.tinyintval;
968  return buf + sizeof(int8_t);
969  case kFLOAT:
970  *(float*)buf = d.floatval;
971  return buf + sizeof(float);
972  case kDOUBLE:
973  *(double*)buf = d.doubleval;
974  return buf + sizeof(double);
975  case kTIME:
976  case kTIMESTAMP:
977  case kDATE:
978  *reinterpret_cast<int64_t*>(buf) = d.bigintval;
979  return buf + sizeof(int64_t);
980  default:
981  return nullptr;
982  }
983 }
int8_t tinyintval
Definition: sqltypes.h:206
Definition: sqltypes.h:51
bool boolval
Definition: sqltypes.h:205
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
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:55
Definition: sqltypes.h:47
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 318 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 const DATA_TYPE(), and anonymous_namespace{TypedDataAccessors.h}::put_scalar().

320  {
321  auto converted_decimal_value = decimal_value;
322  if (new_type_info.get_scale() > type_info.get_scale()) {
323  for (int i = 0; i < new_type_info.get_scale() - type_info.get_scale(); i++) {
324  converted_decimal_value *= 10;
325  }
326  } else if (new_type_info.get_scale() < type_info.get_scale()) {
327  for (int i = 0; i < type_info.get_scale() - new_type_info.get_scale(); i++) {
328  if (converted_decimal_value > 0) {
329  converted_decimal_value = (converted_decimal_value + 5) / 10;
330  } else {
331  converted_decimal_value = (converted_decimal_value - 5) / 10;
332  }
333  }
334  }
335  return converted_decimal_value;
336 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:335

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

189  {
190  switch (ti.get_type()) {
191  case kBOOLEAN:
192  return a.boolval == b.boolval;
193  case kBIGINT:
194  case kNUMERIC:
195  case kDECIMAL:
196  return a.bigintval == b.bigintval;
197  case kINT:
198  return a.intval == b.intval;
199  case kSMALLINT:
200  return a.smallintval == b.smallintval;
201  case kTINYINT:
202  return a.tinyintval == b.tinyintval;
203  case kFLOAT:
204  return a.floatval == b.floatval;
205  case kDOUBLE:
206  return a.doubleval == b.doubleval;
207  case kTIME:
208  case kTIMESTAMP:
209  case kDATE:
210  case kINTERVAL_DAY_TIME:
212  return a.bigintval == b.bigintval;
213  case kTEXT:
214  case kVARCHAR:
215  case kCHAR:
216  case kPOINT:
217  case kLINESTRING:
218  case kPOLYGON:
219  case kMULTIPOLYGON:
220  if (ti.get_compression() == kENCODING_DICT) {
221  return a.intval == b.intval;
222  }
223  if (a.stringval == nullptr && b.stringval == nullptr) {
224  return true;
225  }
226  if (a.stringval == nullptr || b.stringval == nullptr) {
227  return false;
228  }
229  return *a.stringval == *b.stringval;
230  default:
231  return false;
232  }
233  return false;
234 }
Definition: sqltypes.h:51
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
Definition: sqltypes.h:54
Definition: sqltypes.h:55
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:338
Definition: sqltypes.h:43
Definition: sqltypes.h:47

+ 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 239 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(), datum_to_string(), ChunkMetadata::dump(), anonymous_namespace{ArrowImporter.h}::ArrowValue< int64_t >::operator const std::string(), Analyzer::Constant::toString(), Fragmenter_Namespace::InsertOrderFragmenter::updateChunkStats(), and ScalarExprToSql::visitConstant().

239  {
240  constexpr size_t buf_size = 64;
241  char buf[buf_size]; // Hold "2000-03-01 12:34:56.123456789" and large years.
242  switch (ti.get_type()) {
243  case kBOOLEAN:
244  if (d.boolval) {
245  return "t";
246  }
247  return "f";
248  case kNUMERIC:
249  case kDECIMAL: {
250  double v = (double)d.bigintval / pow(10, ti.get_scale());
251  int size = snprintf(buf, buf_size, "%*.*f", ti.get_dimension(), ti.get_scale(), v);
252  CHECK_LE(0, size) << v << ' ' << ti.to_string();
253  CHECK_LT(size_t(size), buf_size) << v << ' ' << ti.to_string();
254  return buf;
255  }
256  case kINT:
257  return std::to_string(d.intval);
258  case kSMALLINT:
259  return std::to_string(d.smallintval);
260  case kTINYINT:
261  return std::to_string(d.tinyintval);
262  case kBIGINT:
263  return std::to_string(d.bigintval);
264  case kFLOAT:
265  return std::to_string(d.floatval);
266  case kDOUBLE:
267  return std::to_string(d.doubleval);
268  case kTIME: {
269  size_t const len = shared::formatHMS(buf, buf_size, d.bigintval);
270  CHECK_EQ(8u, len); // 8 == strlen("HH:MM:SS")
271  return buf;
272  }
273  case kTIMESTAMP: {
274  unsigned const dim = ti.get_dimension(); // assumes dim <= 9
275  size_t const len = shared::formatDateTime(buf, buf_size, d.bigintval, dim);
276  CHECK_LE(19u + bool(dim) + dim, len); // 19 = strlen("YYYY-MM-DD HH:MM:SS")
277  return buf;
278  }
279  case kDATE: {
280  size_t const len = shared::formatDate(buf, buf_size, d.bigintval);
281  CHECK_LE(10u, len); // 10 == strlen("YYYY-MM-DD")
282  return buf;
283  }
284  case kINTERVAL_DAY_TIME:
285  return std::to_string(d.bigintval) + " ms (day-time interval)";
287  return std::to_string(d.bigintval) + " month(s) (year-month interval)";
288  case kTEXT:
289  case kVARCHAR:
290  case kCHAR:
291  if (d.stringval == nullptr) {
292  return "NULL";
293  }
294  return *d.stringval;
295  default:
296  throw std::runtime_error("Internal error: invalid type " + ti.get_type_name() +
297  " in DatumToString.");
298  }
299  return "";
300 }
int8_t tinyintval
Definition: sqltypes.h:206
#define CHECK_EQ(x, y)
Definition: Logger.h:205
Definition: sqltypes.h:51
bool boolval
Definition: sqltypes.h:205
HOST DEVICE int get_scale() const
Definition: sqltypes.h:335
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:330
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:465
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:207
Definition: sqltypes.h:54
Definition: sqltypes.h:55
#define CHECK_LE(x, y)
Definition: Logger.h:208
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:332
std::string get_type_name() const
Definition: sqltypes.h:433
Definition: sqltypes.h:43
Definition: sqltypes.h:47
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 302 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(), import_export::Loader::distributeToShards(), extract_from_datum(), 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().

302  {
303  switch (ti.get_size()) {
304  case 1:
305  return kTINYINT;
306  case 2:
307  return kSMALLINT;
308  case 4:
309  return kINT;
310  case 8:
311  return kBIGINT;
312  default:
313  CHECK(false);
314  }
315  return kNULLT;
316 }
#define CHECK(condition)
Definition: Logger.h:197
Definition: sqltypes.h:47

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SQLTypeInfo get_logical_type_info ( const SQLTypeInfo type_info)
inline

Definition at line 899 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{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(), JoinHashTable::getHashJoinArgs(), getLeafColumnRange(), Parser::CaseExpr::normalize(), TableOptimizer::recomputeMetadata(), rows_to_columnar_results(), Fragmenter_Namespace::InsertOrderFragmenter::updateChunkStats(), and Fragmenter_Namespace::InsertOrderFragmenter::updateColumns().

899  {
900  EncodingType encoding = type_info.get_compression();
901  if (encoding == kENCODING_DATE_IN_DAYS ||
902  (encoding == kENCODING_FIXED && type_info.get_type() != kARRAY)) {
903  encoding = kENCODING_NONE;
904  }
905  return SQLTypeInfo(type_info.get_type(),
906  type_info.get_dimension(),
907  type_info.get_scale(),
908  type_info.get_notnull(),
909  encoding,
910  type_info.get_comp_param(),
911  type_info.get_subtype());
912 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:331
HOST DEVICE int get_scale() const
Definition: sqltypes.h:335
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
EncodingType
Definition: sqltypes.h:227
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:338
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:332
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:339
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:337

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

920  {
921  SQLTypeInfo nullable_type_info = get_logical_type_info(type_info);
922  return get_nullable_type_info(nullable_type_info);
923 }
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:899
SQLTypeInfo get_nullable_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:914

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

References SQLTypeInfo::set_notnull().

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

914  {
915  SQLTypeInfo nullable_type_info = type_info;
916  nullable_type_info.set_notnull(false);
917  return nullable_type_info;
918 }
void set_notnull(bool n)
Definition: sqltypes.h:427

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
constexpr int64_t inline_int_null_array_value ( )
inline

Definition at line 932 of file sqltypes.h.

932  {
933  return std::is_signed<T>::value ? std::numeric_limits<T>::min() + 1
934  : std::numeric_limits<T>::max() - 1;
935  // TODO: null_array values in signed types would step on max valid value
936  // in fixlen unsigned arrays, the max valid value may need to be lowered.
937 }
template<class T >
constexpr int64_t inline_int_null_value ( )
inline

Definition at line 926 of file sqltypes.h.

926  {
927  return std::is_signed<T>::value ? std::numeric_limits<T>::min()
928  : std::numeric_limits<T>::max();
929 }
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 273 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().

273  {
274  return type == kTIME || type == kTIMESTAMP || type == kDATE;
275 }
Definition: sqltypes.h:51
Definition: sqltypes.h:55

+ Here is the caller graph for this function:

template<class T >
constexpr int64_t max_valid_int_value ( )
inline

Definition at line 940 of file sqltypes.h.

940  {
941  return std::is_signed<T>::value ? std::numeric_limits<T>::max()
942  : std::numeric_limits<T>::max() - 1;
943 }
Datum StringToDatum ( std::string_view  s,
SQLTypeInfo ti 
)

Definition at line 124 of file Datum.cpp.

References Datum::bigintval, Datum::boolval, dateTimeParse< kDATE >(), dateTimeParse< kTIME >(), dateTimeParse< kTIMESTAMP >(), Datum::doubleval, Datum::floatval, SQLTypeInfo::get_dimension(), SQLTypeInfo::get_type(), SQLTypeInfo::get_type_name(), Datum::intval, kARRAY, kBIGINT, kBOOLEAN, kCOLUMN, 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 const bool(), anonymous_namespace{ArrowImporter.h}::ArrowValue< std::string >::operator const DATA_TYPE(), populate_TColumn(), and import_export::StringToArray().

124  {
125  Datum d;
126  try {
127  switch (ti.get_type()) {
128  case kARRAY:
129  case kCOLUMN:
130  break;
131  case kBOOLEAN:
132  if (s == "t" || s == "T" || s == "1" || to_upper(std::string(s)) == "TRUE") {
133  d.boolval = true;
134  } else if (s == "f" || s == "F" || s == "0" ||
135  to_upper(std::string(s)) == "FALSE") {
136  d.boolval = false;
137  } else {
138  throw std::runtime_error("Invalid string for boolean " + std::string(s));
139  }
140  break;
141  case kNUMERIC:
142  case kDECIMAL:
143  d.bigintval = parse_numeric(s, ti);
144  break;
145  case kBIGINT:
146  d.bigintval = std::stoll(std::string(s));
147  break;
148  case kINT:
149  d.intval = std::stoi(std::string(s));
150  break;
151  case kSMALLINT:
152  d.smallintval = std::stoi(std::string(s));
153  break;
154  case kTINYINT:
155  d.tinyintval = std::stoi(std::string(s));
156  break;
157  case kFLOAT:
158  d.floatval = std::stof(std::string(s));
159  break;
160  case kDOUBLE:
161  d.doubleval = std::stod(std::string(s));
162  break;
163  case kTIME:
165  break;
166  case kTIMESTAMP:
168  break;
169  case kDATE:
171  break;
172  case kPOINT:
173  case kLINESTRING:
174  case kPOLYGON:
175  case kMULTIPOLYGON:
176  throw std::runtime_error("Internal error: geometry type in StringToDatum.");
177  default:
178  throw std::runtime_error("Internal error: invalid type in StringToDatum.");
179  }
180  } catch (const std::invalid_argument&) {
181  throw std::runtime_error("Invalid conversion from string to " + ti.get_type_name());
182  } catch (const std::out_of_range&) {
183  throw std::runtime_error("Got out of range error during conversion from string to " +
184  ti.get_type_name());
185  }
186  return d;
187 }
int8_t tinyintval
Definition: sqltypes.h:206
Definition: sqltypes.h:51
int64_t parse_numeric(const std::string_view s, SQLTypeInfo &ti)
Definition: Datum.cpp:71
bool boolval
Definition: sqltypes.h:205
int64_t dateTimeParse< kTIMESTAMP >(std::string_view str, unsigned const dim)
int64_t dateTimeParse< kDATE >(std::string_view str, unsigned const dim)
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:330
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:55
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:332
std::string get_type_name() const
Definition: sqltypes.h:433
int64_t dateTimeParse< kTIME >(std::string_view str, unsigned const dim)
Definition: sqltypes.h:47
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 75 of file sqltypes.h.

References logger::FATAL, kARRAY, kBIGINT, kBOOLEAN, kCHAR, kCOLUMN, 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.

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