25 #include "../Logger/Logger.h"
35 #include <type_traits>
40 namespace sql_constants {
49 std::numeric_limits<int64_t>::digits10;
91 #if !(defined(__CUDACC__) || defined(NO_BOOST))
128 return "DAY TIME INTERVAL";
130 return "YEAR MONTH INTERVAL";
138 return "MULTILINESTRING";
142 return "MULTIPOLYGON";
150 return "UNEVALUATED ANY";
158 return "COLUMN_LIST";
171 #endif // #if !(defined(__CUDACC__) || defined(NO_BOOST))
191 template <
typename CUSTOM_DELETER,
192 typename = std::enable_if_t<
193 std::is_void<std::result_of_t<CUSTOM_DELETER(int8_t*)> >::value> >
197 template <
typename CUSTOM_DELETER,
198 typename = std::enable_if_t<
199 std::is_void<std::result_of_t<CUSTOM_DELETER(int8_t*)> >::value> >
200 HostArrayDatum(
size_t const l, int8_t* p,
bool const n, CUSTOM_DELETER custom_deleter)
219 std::conditional_t<is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum>;
244 #if !(defined(__CUDACC__) || defined(NO_BOOST))
270 os <<
"DATE_IN_DAYS";
287 std::ostringstream ss;
292 #endif // #if !(defined(__CUDACC__) || defined(NO_BOOST))
294 #define IS_INTEGER(T) \
295 (((T) == kINT) || ((T) == kSMALLINT) || ((T) == kBIGINT) || ((T) == kTINYINT))
296 #define IS_NUMBER(T) \
297 (((T) == kINT) || ((T) == kSMALLINT) || ((T) == kDOUBLE) || ((T) == kFLOAT) || \
298 ((T) == kBIGINT) || ((T) == kNUMERIC) || ((T) == kDECIMAL) || ((T) == kTINYINT))
299 #define IS_STRING(T) (((T) == kTEXT) || ((T) == kVARCHAR) || ((T) == kCHAR))
301 (((T) == kPOINT) || ((T) == kLINESTRING) || ((T) == kMULTILINESTRING) || \
302 ((T) == kMULTIPOINT) || ((T) == kPOLYGON) || ((T) == kMULTIPOLYGON))
303 #define IS_INTERVAL(T) ((T) == kINTERVAL_DAY_TIME || (T) == kINTERVAL_YEAR_MONTH)
304 #define IS_DECIMAL(T) ((T) == kNUMERIC || (T) == kDECIMAL)
305 #define IS_GEO_POLY(T) (((T) == kPOLYGON) || ((T) == kMULTIPOLYGON))
306 #define IS_GEO_LINE(T) (((T) == kLINESTRING) || ((T) == kMULTILINESTRING))
307 #define IS_GEO_MULTI(T) \
308 (((T) == kMULTIPOLYGON) || ((T) == kMULTILINESTRING) || ((T) == kMULTIPOINT))
312 #define TRANSIENT_DICT(ID) (-(ID))
313 #define REGULAR_DICT(TRANSIENTID) (-(TRANSIENTID))
509 std::string srid_string =
"";
527 return elem_ti.get_type_name() + ps +
"[" + num_elems +
"]";
534 return "COLUMN<" + elem_ti.get_type_name() + ps +
">" + num_elems;
541 return "COLUMN_LIST<" + elem_ti.get_type_name() + ps +
">" + num_elems;
548 std::ostringstream oss;
551 <<
", null=" << (
get_notnull() ?
"not nullable" :
"nullable")
578 return (... || (types ==
type));
683 return sizeof(int32_t);
750 const auto& new_type = new_type_info.
get_type();
760 if (new_type_info.
is_fp()) {
769 if (!new_type_info.
is_fp()) {
792 return new_type ==
kDATE;
794 return new_type ==
kTIME;
918 if (
type ==
kARRAY && val && array_size > 0 && array_size ==
size) {
923 elem_ti.set_subtype(
kNULLT);
924 auto elem_size = elem_ti.get_storage_size();
950 int array_size)
const {
952 array_size ==
size) {
953 if (array_size == 2 *
sizeof(
double)) {
956 if (array_size == 2 *
sizeof(int32_t)) {
1052 return sizeof(int8_t);
1054 return sizeof(int8_t);
1058 return sizeof(int16_t);
1072 return sizeof(int32_t);
1089 return sizeof(int64_t);
1103 return sizeof(float);
1117 return sizeof(double);
1135 return sizeof(int64_t);
1165 return sizeof(int32_t);
1192 #include <string_view>
1206 #ifdef HAVE_TOSTRING
1213 #include "../QueryEngine/DateAdd.h"
1214 #include "../QueryEngine/DateTruncate.h"
1215 #include "../QueryEngine/ExtractFromTime.h"
1228 #if !(defined(__CUDACC__) || defined(NO_BOOST))
1229 UNREACHABLE() <<
"Invalid number of bytes=" << nbytes;
1241 auto type_info_copy = type_info;
1243 type_info_copy.setStorageSize();
1244 return type_info_copy;
1250 return nullable_type_info;
1391 auto new_elem_ti = elem_ti;
1400 switch (elem_type) {
1419 if (c ==
kENCODING_NONE && p == 0 && (d == 9 || d == 6 || d == 0)) {
1438 ti.set_dimension(d);
1447 if (type_info.get_subtype() !=
kNULLT) {
1452 type_info.set_subtype(
kNULLT);
1459 #include "../QueryEngine/Utils/FlatBuffer.h"
1462 int64_t max_nof_values,
1471 FlatBufferManager::DTypeMetadataKind::SIZE_DICTID);
1477 FlatBufferManager::DTypeMetadataKind::SIZE);
1482 int64_t items_count,
1483 int64_t max_nof_values,
1491 FlatBufferManager::DTypeMetadataKind::SIZE_DICTID);
1498 FlatBufferManager::DTypeMetadataKind::SIZE);
1508 auto status = m.
getItem(n, result->length, result->pointer, result->is_null);
1509 if (status == FlatBufferManager::Status::IndexError) {
1512 result->pointer = NULL;
1513 result->is_null =
true;
1517 CHECK_EQ(status, FlatBufferManager::Status::Success);
void initializeVarlenArray(int64_t items_count, int64_t max_nof_values, int64_t dtype_size, DTypeMetadataKind dtype_metadata_kind)
HOST DEVICE SQLTypes get_subtype() const
void set_compression(EncodingType c)
static constexpr int32_t kMaxRepresentableNumericPrecision
HOST DEVICE int get_size() const
HOST DEVICE void operator=(const SQLTypeInfo &rhs)
shared::StringDictKey dict_key_
int8_t * append_datum(int8_t *buf, const Datum &d, const SQLTypeInfo &ti)
std::string DatumToString(Datum d, const SQLTypeInfo &ti)
bool is_varlen_array() const
static constexpr int32_t kMaxNumericPrecision
bool is_text_encoding_dict_array() const
DEVICE constexpr bool is_cuda_compiler()
std::vector< std::string > * stringsPtr
bool is_timestamp() const
std::vector< ArrayDatum > * arraysPtr
bool is_column_list_array() const
bool is_time_or_date() const
SQLTypeInfo get_nullable_logical_type_info(const SQLTypeInfo &type_info)
HOST DEVICE bool operator==(const SQLTypeInfo &rhs) const
std::ostream & operator<<(std::ostream &os, const SessionInfo &session_info)
HOST DEVICE int get_scale() const
#define NULL_ARRAY_SMALLINT
std::string get_compression_name() const
static int64_t get_VarlenArray_flatbuffer_size(int64_t items_count, int64_t max_nof_values, int64_t dtype_size, DTypeMetadataKind dtype_metadata_kind)
HOST DEVICE void set_subtype(SQLTypes st)
Definitions for core Datum union type.
SQLTypeInfo(SQLTypes t, int d, int s)
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
#define NULL_ARRAY_TINYINT
HOST DEVICE bool is_null_fixlen_array(const int8_t *val, int array_size) const
HOST DEVICE SQLTypes get_type() const
HostArrayDatum(size_t const l, int8_t *p, bool const n, CUSTOM_DELETER custom_deleter)
bool has_render_group() const
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
void set_input_srid(int d)
std::string to_string() const
int get_physical_cols() const
bool is_fixlen_array() const
HOST DEVICE Status getItem(int64_t index, int64_t &size, int8_t *&dest, bool &is_null)
bool is_castable(const SQLTypeInfo &new_type_info) const
std::shared_ptr< int8_t > ManagedPtr
HOST DEVICE bool operator!=(const SQLTypeInfo &rhs) const
int get_logical_size() const
bool DatumEqual(const Datum a, const Datum b, const SQLTypeInfo &ti)
static std::string type_name[kSQLTYPE_LAST]
bool is_subtype_dict_encoded_string() const
int64_t extract_int_type_from_datum(const Datum datum, const SQLTypeInfo &ti)
bool is_column_array() const
#define NULL_ARRAY_COMPRESSED_32
bool has_same_itemtype(const SQLTypeInfo &other) const
bool is_text_encoding_dict() const
HostArrayDatum(size_t const l, int8_t *p, CUSTOM_DELETER custom_deleter)
bool is_timeinterval() const
bool is_numeric_scalar_auto_castable(const SQLTypeInfo &new_type_info) const
returns true if the sql_type can be cast to the type specified by new_type_info with no loss of preci...
int is_logical_geo_type() const
bool is_dict_intersection() const
bool is_dict_encoded_type() const
Datum StringToDatum(const std::string_view s, SQLTypeInfo &ti)
SQLTypeInfo(SQLTypes t, int d, int s, bool n)
std::string toString(const ExecutorDeviceType &device_type)
std::string toString() const
HostArrayDatum(size_t const l, int8_t *p, bool const n)
void operator()(int8_t *p)
SQLTypeInfo(SQLTypes t, int d, int s, bool n, EncodingType c, int p, SQLTypes st)
bool IsNullDatum(const Datum datum, const SQLTypeInfo &ti)
std::string get_buffer_name() const
SQLTypeInfo(SQLTypes t, bool n, EncodingType c)
SQLTypeInfo get_array_type() const
Datum NullDatum(const SQLTypeInfo &ti)
int get_precision() const
void set_output_srid(int s)
SQLTypes decimal_to_int_type(const SQLTypeInfo &ti)
DEVICE DeviceArrayDatum()
HOST DEVICE bool is_null(const Datum &d) const
auto generate_column_type(const SQLTypeInfo &elem_ti)
void set_comp_param(int p)
HOST DEVICE int get_storage_size() const
static std::string comp_name[kENCODING_LAST]
void initializeVarlenArray(FlatBufferManager &m, int64_t items_count, int64_t max_nof_values, const SQLTypeInfo &ti)
HOST DEVICE EncodingType get_compression() const
bool is_date_in_days() const
int get_array_context_logical_size() const
int64_t convert_decimal_value_to_scale(const int64_t decimal_value, const SQLTypeInfo &type_info, const SQLTypeInfo &new_type_info)
auto generate_column_list_type(const SQLTypeInfo &elem_ti)
void set_dimension(int d)
void setStringDictKey(const shared::StringDictKey &dict_key)
SQLTypes get_int_type_by_size(size_t const nbytes)
bool is_none_encoded_string() const
HOST DEVICE int get_dimension() const
std::string get_type_name() const
int32_t get_numeric_scalar_scale() const
returns integer between 1 and 8 indicating what is roughly equivalent to the logical byte size of a s...
HOST DEVICE int get_comp_param() const
HOST DEVICE int get_input_srid() const
void set_dict_intersection()
#define NULL_ARRAY_DOUBLE
bool is_column_list() const
bool g_enable_watchdog false
int64_t getVarlenArrayBufferSize(int64_t items_count, int64_t max_nof_values, const SQLTypeInfo &ti)
bool is_encoded_timestamp() const
bool is_high_precision_timestamp() const
double extract_fp_type_from_datum(const Datum datum, const SQLTypeInfo &ti)
void setDTypeMetadataDictKey(int32_t db_id, int32_t dict_id)
HostArrayDatum(size_t const l, ManagedPtr p, bool const n)
#define NULL_ARRAY_BIGINT
bool is_dict_encoded_string() const
bool is_varlen_indeed() const
SQLTypeInfo(SQLTypes t, EncodingType c, int p, SQLTypes st)
SQLTypeInfo(SQLTypes t, bool n)
HOST DEVICE bool get_notnull() const
bool is_string_array() const
SQLTypeInfo get_elem_type() const
int get_physical_coord_cols() const
void operator()(int8_t *)
#define TRANSIENT_DICT(ID)
void set_precision(int d)
SQLTypeInfo get_nullable_type_info(const SQLTypeInfo &type_info)
HOST DEVICE bool is_null_point_coord_array(const int8_t *val, int array_size) const
HOST DEVICE int get_output_srid() const
DEVICE void VarlenArray_get_nth(int8_t *buf, int n, ArrayDatum *result, bool *is_end)
constexpr auto is_datetime(SQLTypes type)
const shared::StringDictKey & getStringDictKey() const
HOST DEVICE bool is_null(const int8_t *val) const
SQLTypes string_dict_to_int_type(const SQLTypeInfo &ti)
HOST DEVICE void set_type(SQLTypes t)