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

Constants for Builtin SQL Types supported by MapD. More...

#include "ConfigResolve.h"
#include "StringTransform.h"
#include <cassert>
#include <cfloat>
#include <cstdint>
#include <ctime>
#include <limits>
#include <memory>
#include <string>
#include <type_traits>
#include <vector>
#include "SQLTypeUtilities.h"
#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  ExecutorTypePackaging< CORE_TYPE >
 
class  ArrayContextTypeSizer< CORE_TYPE >
 
class  DateTimeFacilities< CORE_TYPE >
 
class  SQLTypeInfoCore< TYPE_FACET_PACK >
 

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 TRANSIENT_DICT_ID   0
 
#define TRANSIENT_DICT(ID)   (-(ID))
 
#define REGULAR_DICT(TRANSIENTID)   (-(TRANSIENTID))
 

Typedefs

using ArrayDatum = std::conditional_t< isCudaCC(), DeviceArrayDatum, HostArrayDatum >
 
using SQLTypeInfo = SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities >
 
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,
  kSQLTYPE_LAST = 28
}
 
enum  EncodingType {
  kINT8 = 0, kINT16 = 1, kINT32 = 2, kINT64 = 3,
  kUINT8 = 4, kUINT16 = 5, kUINT32 = 6, kUINT64 = 7,
  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

template<typename T >
constexpr auto is_datetime (T sql_type)
 
SQLTypes decimal_to_int_type (const SQLTypeInfo &)
 
Datum StringToDatum (const std::string &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_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 ()
 

Detailed Description

Constants for Builtin SQL Types supported by MapD.

Author
Wei Hong wei@m.nosp@m.ap-d.nosp@m..com Copyright (c) 2014 MapD Technologies, Inc. All rights reserved.

Definition in file sqltypes.h.

Macro Definition Documentation

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

Definition at line 170 of file sqltypes.h.

#define IS_GEO_POLY (   T)    (((T) == kPOLYGON) || ((T) == kMULTIPOLYGON))
#define IS_INTERVAL (   T)    ((T) == kINTERVAL_DAY_TIME || (T) == kINTERVAL_YEAR_MONTH)
#define IS_NUMBER (   T)
Value:
(((T) == kINT) || ((T) == kSMALLINT) || ((T) == kDOUBLE) || ((T) == kFLOAT) || \
((T) == kBIGINT) || ((T) == kNUMERIC) || ((T) == kDECIMAL) || ((T) == kTINYINT))
Definition: sqltypes.h:48

Definition at line 163 of file sqltypes.h.

Referenced by SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities >::is_number(), and anonymous_namespace{EquiJoinCondition.cpp}::make_composite_equals_impl().

#define NULL_ARRAY_BOOLEAN   (INT8_MIN + 1)

Definition at line 181 of file sqltypes.h.

Referenced by FixedLengthArrayNoneEncoder::is_null().

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

Definition at line 191 of file sqltypes.h.

Referenced by Executor::getStringDictionaryProxy().

Typedef Documentation

using ArrayDatum = std::conditional_t<isCudaCC(), DeviceArrayDatum, HostArrayDatum>

Definition at line 122 of file sqltypes.h.

using ArrayOffsetT = int32_t

Definition at line 913 of file sqltypes.h.

using StringOffsetT = int32_t

Definition at line 912 of file sqltypes.h.

Enumeration Type Documentation

Enumerator
kINT8 
kINT16 
kINT32 
kINT64 
kUINT8 
kUINT16 
kUINT32 
kUINT64 
kENCODING_NONE 
kENCODING_FIXED 
kENCODING_RL 
kENCODING_DIFF 
kENCODING_DICT 
kENCODING_SPARSE 
kENCODING_GEOINT 
kENCODING_DATE_IN_DAYS 
kENCODING_LAST 

Definition at line 147 of file sqltypes.h.

147  {
148  kENCODING_NONE = 0, // no encoding
149  kENCODING_FIXED = 1, // Fixed-bit encoding
150  kENCODING_RL = 2, // Run Length encoding
151  kENCODING_DIFF = 3, // Differential encoding
152  kENCODING_DICT = 4, // Dictionary encoding
153  kENCODING_SPARSE = 5, // Null encoding for sparse columns
154  kENCODING_GEOINT = 6, // Encoding coordinates as intergers
155  kENCODING_DATE_IN_DAYS = 7, // Date encoding in days
156  kENCODING_LAST = 8
157 };
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 
kSQLTYPE_LAST 

Definition at line 41 of file sqltypes.h.

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

Function Documentation

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

Definition at line 284 of file Datum.cpp.

References SQLTypeInfoCore< TYPE_FACET_PACK >::get_scale().

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

286  {
287  auto converted_decimal_value = decimal_value;
288  if (new_type_info.get_scale() > type_info.get_scale()) {
289  for (int i = 0; i < new_type_info.get_scale() - type_info.get_scale(); i++) {
290  converted_decimal_value *= 10;
291  }
292  } else if (new_type_info.get_scale() < type_info.get_scale()) {
293  for (int i = 0; i < type_info.get_scale() - new_type_info.get_scale(); i++) {
294  if (converted_decimal_value > 0) {
295  converted_decimal_value = (converted_decimal_value + 5) / 10;
296  } else {
297  converted_decimal_value = (converted_decimal_value - 5) / 10;
298  }
299  }
300  }
301  return converted_decimal_value;
302 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:331

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

References Datum::bigintval, Datum::boolval, Datum::doubleval, Datum::floatval, SQLTypeInfoCore< TYPE_FACET_PACK >::get_compression(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), Datum::intval, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kENCODING_DICT, kFLOAT, kINT, kINTERVAL_DAY_TIME, kINTERVAL_YEAR_MONTH, kNUMERIC, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, Datum::smallintval, Datum::stringval, and Datum::tinyintval.

Referenced by ChunkMetadata::operator==().

153  {
154  switch (ti.get_type()) {
155  case kBOOLEAN:
156  return a.boolval == b.boolval;
157  case kBIGINT:
158  case kNUMERIC:
159  case kDECIMAL:
160  return a.bigintval == b.bigintval;
161  case kINT:
162  return a.intval == b.intval;
163  case kSMALLINT:
164  return a.smallintval == b.smallintval;
165  case kTINYINT:
166  return a.tinyintval == b.tinyintval;
167  case kFLOAT:
168  return a.floatval == b.floatval;
169  case kDOUBLE:
170  return a.doubleval == b.doubleval;
171  case kTIME:
172  case kTIMESTAMP:
173  case kDATE:
174  case kINTERVAL_DAY_TIME:
176  return a.bigintval == b.bigintval;
177  case kTEXT:
178  case kVARCHAR:
179  case kCHAR:
180  if (ti.get_compression() == kENCODING_DICT) {
181  return a.intval == b.intval;
182  }
183  return *a.stringval == *b.stringval;
184  default:
185  return false;
186  }
187  return false;
188 }
Definition: sqltypes.h:52
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:334
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:326
Definition: sqltypes.h:55
Definition: sqltypes.h:56
Definition: sqltypes.h:44
Definition: sqltypes.h:48

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

References Datum::bigintval, Datum::boolval, Datum::doubleval, Datum::floatval, SQLTypeInfoCore< TYPE_FACET_PACK >::get_dimension(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_scale(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), SQLTypeInfoCore< TYPE_FACET_PACK >::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, and to_string().

Referenced by Analyzer::Constant::cast_to_string(), datum_to_string(), anonymous_namespace{ArrowImporter.h}::ArrowValue< int64_t >::operator const std::string(), Analyzer::Constant::toString(), and Fragmenter_Namespace::InsertOrderFragmenter::updateChunkStats().

193  {
194  switch (ti.get_type()) {
195  case kBOOLEAN:
196  if (d.boolval) {
197  return "t";
198  }
199  return "f";
200  case kNUMERIC:
201  case kDECIMAL: {
202  char str[ti.get_dimension() + 1];
203  double v = (double)d.bigintval / pow(10, ti.get_scale());
204  sprintf(str, "%*.*f", ti.get_dimension(), ti.get_scale(), v);
205  return std::string(str);
206  }
207  case kINT:
208  return std::to_string(d.intval);
209  case kSMALLINT:
210  return std::to_string(d.smallintval);
211  case kTINYINT:
212  return std::to_string(d.tinyintval);
213  case kBIGINT:
214  return std::to_string(d.bigintval);
215  case kFLOAT:
216  return std::to_string(d.floatval);
217  case kDOUBLE:
218  return std::to_string(d.doubleval);
219  case kTIME: {
220  std::tm tm_struct;
221  gmtime_r(reinterpret_cast<time_t*>(&d.bigintval), &tm_struct);
222  char buf[9];
223  strftime(buf, 9, "%T", &tm_struct);
224  return std::string(buf);
225  }
226  case kTIMESTAMP: {
227  std::tm tm_struct{0};
228  if (ti.get_dimension() > 0) {
229  std::string t = std::to_string(d.bigintval);
230  int cp = t.length() - ti.get_dimension();
231  time_t sec = std::stoll(t.substr(0, cp));
232  t = t.substr(cp);
233  gmtime_r(&sec, &tm_struct);
234  char buf[21];
235  strftime(buf, 21, "%F %T.", &tm_struct);
236  return std::string(buf) += t;
237  } else {
238  time_t sec = static_cast<time_t>(d.bigintval);
239  gmtime_r(&sec, &tm_struct);
240  char buf[20];
241  strftime(buf, 20, "%F %T", &tm_struct);
242  return std::string(buf);
243  }
244  }
245  case kDATE: {
246  std::tm tm_struct;
247  time_t ntimeval = static_cast<time_t>(d.bigintval);
248  gmtime_r(&ntimeval, &tm_struct);
249  char buf[11];
250  strftime(buf, 11, "%F", &tm_struct);
251  return std::string(buf);
252  }
253  case kINTERVAL_DAY_TIME:
254  return std::to_string(d.bigintval) + " ms (day-time interval)";
256  return std::to_string(d.bigintval) + " month(s) (year-month interval)";
257  case kTEXT:
258  case kVARCHAR:
259  case kCHAR:
260  return *d.stringval;
261  default:
262  throw std::runtime_error("Internal error: invalid type " + ti.get_type_name() +
263  " in DatumToString.");
264  }
265  return "";
266 }
int8_t tinyintval
Definition: sqltypes.h:126
Definition: sqltypes.h:52
bool boolval
Definition: sqltypes.h:125
HOST DEVICE int get_scale() const
Definition: sqltypes.h:331
int32_t intval
Definition: sqltypes.h:128
std::string to_string(char const *&&v)
std::string get_type_name() const
Definition: sqltypes.h:429
float floatval
Definition: sqltypes.h:130
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:326
int64_t bigintval
Definition: sqltypes.h:129
int16_t smallintval
Definition: sqltypes.h:127
std::string * stringval
Definition: sqltypes.h:134
Definition: sqltypes.h:55
Definition: sqltypes.h:56
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:328
Definition: sqltypes.h:44
Definition: sqltypes.h:48
double doubleval
Definition: sqltypes.h:131

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

References CHECK(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_size(), kBIGINT, kINT, kNULLT, kSMALLINT, and kTINYINT.

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

268  {
269  switch (ti.get_size()) {
270  case 1:
271  return kTINYINT;
272  case 2:
273  return kSMALLINT;
274  case 4:
275  return kINT;
276  case 8:
277  return kBIGINT;
278  default:
279  CHECK(false);
280  }
281  return kNULLT;
282 }
CHECK(cgen_state)
Definition: sqltypes.h:48

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

References SQLTypeInfoCore< TYPE_FACET_PACK >::get_comp_param(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_compression(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_dimension(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_notnull(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_scale(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_subtype(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), kARRAY, kENCODING_DATE_IN_DAYS, kENCODING_FIXED, and kENCODING_NONE.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::cast_to_column_type(), 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(), TableOptimizer::recomputeMetadata(), rows_to_columnar_results(), RelAlgTranslator::translateArrayFunction(), Fragmenter_Namespace::InsertOrderFragmenter::updateChunkStats(), and Fragmenter_Namespace::InsertOrderFragmenter::updateColumns().

869  {
870  EncodingType encoding = type_info.get_compression();
871  if (encoding == kENCODING_DATE_IN_DAYS ||
872  (encoding == kENCODING_FIXED && type_info.get_type() != kARRAY)) {
873  encoding = kENCODING_NONE;
874  }
875  return SQLTypeInfo(type_info.get_type(),
876  type_info.get_dimension(),
877  type_info.get_scale(),
878  type_info.get_notnull(),
879  encoding,
880  type_info.get_comp_param(),
881  type_info.get_subtype());
882 }
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:334
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:335
EncodingType
Definition: encodetypes.h:22
HOST DEVICE int get_scale() const
Definition: sqltypes.h:331
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:326
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:333
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:852
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:328
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:327

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

References get_logical_type_info(), and SQLTypeInfoCore< TYPE_FACET_PACK >::set_notnull().

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::get_logical_type_for_expr().

884  {
885  SQLTypeInfo nullable_type_info = get_logical_type_info(type_info);
886  nullable_type_info.set_notnull(false);
887  return nullable_type_info;
888 }
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:869
void set_notnull(bool n)
Definition: sqltypes.h:423

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

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

Definition at line 891 of file sqltypes.h.

891  {
892  return std::is_signed<T>::value ? std::numeric_limits<T>::min()
893  : std::numeric_limits<T>::max();
894 }
template<typename T >
constexpr auto is_datetime ( sql_type)

Definition at line 194 of file sqltypes.h.

References kDATE, kTIME, and kTIMESTAMP.

Referenced by SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities >::is_time(), DateTimeStringValidate< SQL_TYPE >::operator()(), and RexLiteral::RexLiteral().

194  {
195  return sql_type == kTIME || sql_type == kTIMESTAMP || sql_type == kDATE;
196 }
Definition: sqltypes.h:52
Definition: sqltypes.h:56

+ Here is the caller graph for this function:

template<class T >
constexpr int64_t max_valid_int_value ( )
inline

Definition at line 905 of file sqltypes.h.

905  {
906  return std::is_signed<T>::value ? std::numeric_limits<T>::max()
907  : std::numeric_limits<T>::max() - 1;
908 }
Datum StringToDatum ( const std::string &  s,
SQLTypeInfo ti 
)

Definition at line 90 of file Datum.cpp.

References Datum::bigintval, Datum::boolval, Datum::doubleval, Datum::floatval, SQLTypeInfoCore< TYPE_FACET_PACK >::get_dimension(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type_name(), Datum::intval, kARRAY, kBIGINT, kBOOLEAN, 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 Importer_NS::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 Importer_NS::StringToArray().

90  {
91  Datum d;
92  try {
93  switch (ti.get_type()) {
94  case kARRAY:
95  break;
96  case kBOOLEAN:
97  if (s == "t" || s == "T" || s == "1" || to_upper(s) == "TRUE") {
98  d.boolval = true;
99  } else if (s == "f" || s == "F" || s == "0" || to_upper(s) == "FALSE") {
100  d.boolval = false;
101  } else {
102  throw std::runtime_error("Invalid string for boolean " + s);
103  }
104  break;
105  case kNUMERIC:
106  case kDECIMAL:
107  d.bigintval = parse_numeric(s, ti);
108  break;
109  case kBIGINT:
110  d.bigintval = std::stoll(s);
111  break;
112  case kINT:
113  d.intval = std::stoi(s);
114  break;
115  case kSMALLINT:
116  d.smallintval = std::stoi(s);
117  break;
118  case kTINYINT:
119  d.tinyintval = std::stoi(s);
120  break;
121  case kFLOAT:
122  d.floatval = std::stof(s);
123  break;
124  case kDOUBLE:
125  d.doubleval = std::stod(s);
126  break;
127  case kTIME:
129  break;
130  case kTIMESTAMP:
132  break;
133  case kDATE:
135  break;
136  case kPOINT:
137  case kLINESTRING:
138  case kPOLYGON:
139  case kMULTIPOLYGON:
140  throw std::runtime_error("Internal error: geometry type in StringToDatum.");
141  default:
142  throw std::runtime_error("Internal error: invalid type in StringToDatum.");
143  }
144  } catch (const std::invalid_argument&) {
145  throw std::runtime_error("Invalid conversion from string to " + ti.get_type_name());
146  } catch (const std::out_of_range&) {
147  throw std::runtime_error("Got out of range error during conversion from string to " +
148  ti.get_type_name());
149  }
150  return d;
151 }
int8_t tinyintval
Definition: sqltypes.h:126
Definition: sqltypes.h:52
bool boolval
Definition: sqltypes.h:125
int32_t intval
Definition: sqltypes.h:128
std::string get_type_name() const
Definition: sqltypes.h:429
int64_t parse_numeric(const std::string &s, SQLTypeInfo &ti)
Definition: Datum.cpp:37
float floatval
Definition: sqltypes.h:130
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:326
int64_t bigintval
Definition: sqltypes.h:129
int16_t smallintval
Definition: sqltypes.h:127
std::string to_upper(const std::string &str)
Definition: sqltypes.h:56
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:328
Definition: sqltypes.h:48
double doubleval
Definition: sqltypes.h:131

+ Here is the call graph for this function:

+ Here is the caller graph for this function: