OmniSciDB  0fdbebe030
 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 "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 "../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< isCudaCC(), 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,
  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

constexpr auto is_datetime (SQLTypes 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 ()
 
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 166 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 165 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:46

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

Referenced by FixedLengthArrayNoneEncoder::is_null().

#define NULL_ARRAY_COMPRESSED_32   0x80000000U

Definition at line 185 of file sqltypes.h.

Referenced by SQLTypeInfo::is_null_point_coord_array().

#define NULL_ARRAY_FLOAT   (FLT_MIN * 2.0)
#define NULL_ARRAY_INT   (INT32_MIN + 1)
#define NULL_ARRAY_SMALLINT   (INT16_MIN + 1)
#define NULL_ARRAY_TINYINT   (INT8_MIN + 1)
#define REGULAR_DICT (   TRANSIENTID)    (-(TRANSIENTID))

Definition at line 189 of file sqltypes.h.

Referenced by Executor::getStringDictionaryProxy().

Typedef Documentation

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

Definition at line 120 of file sqltypes.h.

using ArrayOffsetT = int32_t

Definition at line 840 of file sqltypes.h.

using StringOffsetT = int32_t

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

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

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

Function Documentation

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

Definition at line 842 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(), Importer_NS::NullArray(), Importer_NS::StringToArray(), and Importer_NS::TDatumToArrayDatum().

842  {
843  switch (ti.get_type()) {
844  case kBOOLEAN:
845  *(bool*)buf = d.boolval;
846  return buf + sizeof(bool);
847  case kNUMERIC:
848  case kDECIMAL:
849  case kBIGINT:
850  *(int64_t*)buf = d.bigintval;
851  return buf + sizeof(int64_t);
852  case kINT:
853  *(int32_t*)buf = d.intval;
854  return buf + sizeof(int32_t);
855  case kSMALLINT:
856  *(int16_t*)buf = d.smallintval;
857  return buf + sizeof(int16_t);
858  case kTINYINT:
859  *(int8_t*)buf = d.tinyintval;
860  return buf + sizeof(int8_t);
861  case kFLOAT:
862  *(float*)buf = d.floatval;
863  return buf + sizeof(float);
864  case kDOUBLE:
865  *(double*)buf = d.doubleval;
866  return buf + sizeof(double);
867  case kTIME:
868  case kTIMESTAMP:
869  case kDATE:
870  *reinterpret_cast<int64_t*>(buf) = d.bigintval;
871  return buf + sizeof(int64_t);
872  default:
873  return nullptr;
874  }
875 }
int8_t tinyintval
Definition: sqltypes.h:124
Definition: sqltypes.h:50
bool boolval
Definition: sqltypes.h:123
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:248
int32_t intval
Definition: sqltypes.h:126
float floatval
Definition: sqltypes.h:128
int64_t bigintval
Definition: sqltypes.h:127
int16_t smallintval
Definition: sqltypes.h:125
Definition: sqltypes.h:54
Definition: sqltypes.h:46
double doubleval
Definition: sqltypes.h:129

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

References SQLTypeInfo::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().

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

+ 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 184 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, kNUMERIC, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, Datum::smallintval, Datum::stringval, and Datum::tinyintval.

Referenced by ChunkMetadata::operator==().

184  {
185  switch (ti.get_type()) {
186  case kBOOLEAN:
187  return a.boolval == b.boolval;
188  case kBIGINT:
189  case kNUMERIC:
190  case kDECIMAL:
191  return a.bigintval == b.bigintval;
192  case kINT:
193  return a.intval == b.intval;
194  case kSMALLINT:
195  return a.smallintval == b.smallintval;
196  case kTINYINT:
197  return a.tinyintval == b.tinyintval;
198  case kFLOAT:
199  return a.floatval == b.floatval;
200  case kDOUBLE:
201  return a.doubleval == b.doubleval;
202  case kTIME:
203  case kTIMESTAMP:
204  case kDATE:
205  case kINTERVAL_DAY_TIME:
207  return a.bigintval == b.bigintval;
208  case kTEXT:
209  case kVARCHAR:
210  case kCHAR:
211  if (ti.get_compression() == kENCODING_DICT) {
212  return a.intval == b.intval;
213  }
214  return *a.stringval == *b.stringval;
215  default:
216  return false;
217  }
218  return false;
219 }
Definition: sqltypes.h:50
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:248
Definition: sqltypes.h:53
Definition: sqltypes.h:54
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:256
Definition: sqltypes.h:42
Definition: sqltypes.h:46

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

References Datum::bigintval, Datum::boolval, Datum::doubleval, Datum::floatval, 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, 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(), Fragmenter_Namespace::InsertOrderFragmenter::updateChunkStats(), and ScalarExprToSql::visitConstant().

224  {
225  switch (ti.get_type()) {
226  case kBOOLEAN:
227  if (d.boolval) {
228  return "t";
229  }
230  return "f";
231  case kNUMERIC:
232  case kDECIMAL: {
233  char str[ti.get_dimension() + 1];
234  double v = (double)d.bigintval / pow(10, ti.get_scale());
235  sprintf(str, "%*.*f", ti.get_dimension(), ti.get_scale(), v);
236  return std::string(str);
237  }
238  case kINT:
239  return std::to_string(d.intval);
240  case kSMALLINT:
241  return std::to_string(d.smallintval);
242  case kTINYINT:
243  return std::to_string(d.tinyintval);
244  case kBIGINT:
245  return std::to_string(d.bigintval);
246  case kFLOAT:
247  return std::to_string(d.floatval);
248  case kDOUBLE:
249  return std::to_string(d.doubleval);
250  case kTIME: {
251  std::tm tm_struct;
252  gmtime_r(reinterpret_cast<time_t*>(&d.bigintval), &tm_struct);
253  char buf[9];
254  strftime(buf, 9, "%T", &tm_struct);
255  return std::string(buf);
256  }
257  case kTIMESTAMP: {
258  std::tm tm_struct{0};
259  if (ti.get_dimension() > 0) {
260  std::string t = std::to_string(d.bigintval);
261  int cp = t.length() - ti.get_dimension();
262  time_t sec = std::stoll(t.substr(0, cp));
263  t = t.substr(cp);
264  gmtime_r(&sec, &tm_struct);
265  char buf[21];
266  strftime(buf, 21, "%F %T.", &tm_struct);
267  return std::string(buf) += t;
268  } else {
269  time_t sec = static_cast<time_t>(d.bigintval);
270  gmtime_r(&sec, &tm_struct);
271  char buf[20];
272  strftime(buf, 20, "%F %T", &tm_struct);
273  return std::string(buf);
274  }
275  }
276  case kDATE: {
277  std::tm tm_struct;
278  time_t ntimeval = static_cast<time_t>(d.bigintval);
279  gmtime_r(&ntimeval, &tm_struct);
280  char buf[11];
281  strftime(buf, 11, "%F", &tm_struct);
282  return std::string(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  return *d.stringval;
292  default:
293  throw std::runtime_error("Internal error: invalid type " + ti.get_type_name() +
294  " in DatumToString.");
295  }
296  return "";
297 }
int8_t tinyintval
Definition: sqltypes.h:124
Definition: sqltypes.h:50
bool boolval
Definition: sqltypes.h:123
HOST DEVICE int get_scale() const
Definition: sqltypes.h:253
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:248
int32_t intval
Definition: sqltypes.h:126
std::string to_string(char const *&&v)
float floatval
Definition: sqltypes.h:128
int64_t bigintval
Definition: sqltypes.h:127
int16_t smallintval
Definition: sqltypes.h:125
std::string * stringval
Definition: sqltypes.h:132
Definition: sqltypes.h:53
Definition: sqltypes.h:54
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:250
std::string get_type_name() const
Definition: sqltypes.h:351
Definition: sqltypes.h:42
Definition: sqltypes.h:46
double doubleval
Definition: sqltypes.h:129

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

References CHECK(), SQLTypeInfo::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().

299  {
300  switch (ti.get_size()) {
301  case 1:
302  return kTINYINT;
303  case 2:
304  return kSMALLINT;
305  case 4:
306  return kINT;
307  case 8:
308  return kBIGINT;
309  default:
310  CHECK(false);
311  }
312  return kNULLT;
313 }
CHECK(cgen_state)
Definition: sqltypes.h:46

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

796  {
797  EncodingType encoding = type_info.get_compression();
798  if (encoding == kENCODING_DATE_IN_DAYS ||
799  (encoding == kENCODING_FIXED && type_info.get_type() != kARRAY)) {
800  encoding = kENCODING_NONE;
801  }
802  return SQLTypeInfo(type_info.get_type(),
803  type_info.get_dimension(),
804  type_info.get_scale(),
805  type_info.get_notnull(),
806  encoding,
807  type_info.get_comp_param(),
808  type_info.get_subtype());
809 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:249
EncodingType
Definition: encodetypes.h:22
HOST DEVICE int get_scale() const
Definition: sqltypes.h:253
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:248
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:256
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:250
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:257
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:255

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

References get_logical_type_info(), and SQLTypeInfo::set_notnull().

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::get_logical_type_for_expr(), and RelAlgTranslator::translateArrayFunction().

811  {
812  SQLTypeInfo nullable_type_info = get_logical_type_info(type_info);
813  nullable_type_info.set_notnull(false);
814  return nullable_type_info;
815 }
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:796
void set_notnull(bool n)
Definition: sqltypes.h:345

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

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

Definition at line 818 of file sqltypes.h.

818  {
819  return std::is_signed<T>::value ? std::numeric_limits<T>::min()
820  : std::numeric_limits<T>::max();
821 }
constexpr auto is_datetime ( SQLTypes  type)

Definition at line 191 of file sqltypes.h.

References kDATE, kTIME, and kTIMESTAMP.

Referenced by SQLTypeInfo::is_time(), DateTimeStringValidate< SQL_TYPE >::operator()(), and RexLiteral::RexLiteral().

191  {
192  return type == kTIME || type == kTIMESTAMP || type == kDATE;
193 }
Definition: sqltypes.h:50
Definition: sqltypes.h:54

+ Here is the caller graph for this function:

template<class T >
constexpr int64_t max_valid_int_value ( )
inline

Definition at line 832 of file sqltypes.h.

832  {
833  return std::is_signed<T>::value ? std::numeric_limits<T>::max()
834  : std::numeric_limits<T>::max() - 1;
835 }
Datum StringToDatum ( const std::string &  s,
SQLTypeInfo ti 
)

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

121  {
122  Datum d;
123  try {
124  switch (ti.get_type()) {
125  case kARRAY:
126  break;
127  case kBOOLEAN:
128  if (s == "t" || s == "T" || s == "1" || to_upper(s) == "TRUE") {
129  d.boolval = true;
130  } else if (s == "f" || s == "F" || s == "0" || to_upper(s) == "FALSE") {
131  d.boolval = false;
132  } else {
133  throw std::runtime_error("Invalid string for boolean " + s);
134  }
135  break;
136  case kNUMERIC:
137  case kDECIMAL:
138  d.bigintval = parse_numeric(s, ti);
139  break;
140  case kBIGINT:
141  d.bigintval = std::stoll(s);
142  break;
143  case kINT:
144  d.intval = std::stoi(s);
145  break;
146  case kSMALLINT:
147  d.smallintval = std::stoi(s);
148  break;
149  case kTINYINT:
150  d.tinyintval = std::stoi(s);
151  break;
152  case kFLOAT:
153  d.floatval = std::stof(s);
154  break;
155  case kDOUBLE:
156  d.doubleval = std::stod(s);
157  break;
158  case kTIME:
160  break;
161  case kTIMESTAMP:
163  break;
164  case kDATE:
166  break;
167  case kPOINT:
168  case kLINESTRING:
169  case kPOLYGON:
170  case kMULTIPOLYGON:
171  throw std::runtime_error("Internal error: geometry type in StringToDatum.");
172  default:
173  throw std::runtime_error("Internal error: invalid type in StringToDatum.");
174  }
175  } catch (const std::invalid_argument&) {
176  throw std::runtime_error("Invalid conversion from string to " + ti.get_type_name());
177  } catch (const std::out_of_range&) {
178  throw std::runtime_error("Got out of range error during conversion from string to " +
179  ti.get_type_name());
180  }
181  return d;
182 }
int8_t tinyintval
Definition: sqltypes.h:124
Definition: sqltypes.h:50
bool boolval
Definition: sqltypes.h:123
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:248
int32_t intval
Definition: sqltypes.h:126
int64_t parse_numeric(const std::string &s, SQLTypeInfo &ti)
Definition: Datum.cpp:68
float floatval
Definition: sqltypes.h:128
int64_t bigintval
Definition: sqltypes.h:127
int16_t smallintval
Definition: sqltypes.h:125
std::string to_upper(const std::string &str)
Definition: sqltypes.h:54
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:250
std::string get_type_name() const
Definition: sqltypes.h:351
Definition: sqltypes.h:46
double doubleval
Definition: sqltypes.h:129

+ Here is the call graph for this function:

+ Here is the caller graph for this function: