25 #if !(defined(__CUDACC__) || defined(NO_BOOST))
33 #include "../Logger/Logger.h"
34 #include "../QueryEngine/Utils/FlatBuffer.h"
45 #include <type_traits>
50 namespace sql_constants {
59 std::numeric_limits<int64_t>::digits10;
101 #if !(defined(__CUDACC__) || defined(NO_BOOST))
138 return "DAY TIME INTERVAL";
140 return "YEAR MONTH INTERVAL";
148 return "MULTILINESTRING";
152 return "MULTIPOLYGON";
160 return "UNEVALUATED ANY";
168 return "COLUMN_LIST";
181 #endif // #if !(defined(__CUDACC__) || defined(NO_BOOST))
201 template <
typename CUSTOM_DELETER,
202 typename = std::enable_if_t<
203 std::is_void<std::result_of_t<CUSTOM_DELETER(int8_t*)> >::value> >
207 template <
typename CUSTOM_DELETER,
208 typename = std::enable_if_t<
209 std::is_void<std::result_of_t<CUSTOM_DELETER(int8_t*)> >::value> >
210 HostArrayDatum(
size_t const l, int8_t* p,
bool const n, CUSTOM_DELETER custom_deleter)
229 std::conditional_t<is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum>;
254 #if !(defined(__CUDACC__) || defined(NO_BOOST))
280 os <<
"DATE_IN_DAYS";
297 std::ostringstream ss;
302 #endif // #if !(defined(__CUDACC__) || defined(NO_BOOST))
304 #define IS_INTEGER(T) \
305 (((T) == kINT) || ((T) == kSMALLINT) || ((T) == kBIGINT) || ((T) == kTINYINT))
306 #define IS_NUMBER(T) \
307 (((T) == kINT) || ((T) == kSMALLINT) || ((T) == kDOUBLE) || ((T) == kFLOAT) || \
308 ((T) == kBIGINT) || ((T) == kNUMERIC) || ((T) == kDECIMAL) || ((T) == kTINYINT))
309 #define IS_STRING(T) (((T) == kTEXT) || ((T) == kVARCHAR) || ((T) == kCHAR))
311 (((T) == kPOINT) || ((T) == kLINESTRING) || ((T) == kMULTILINESTRING) || \
312 ((T) == kMULTIPOINT) || ((T) == kPOLYGON) || ((T) == kMULTIPOLYGON))
313 #define IS_INTERVAL(T) ((T) == kINTERVAL_DAY_TIME || (T) == kINTERVAL_YEAR_MONTH)
314 #define IS_DECIMAL(T) ((T) == kNUMERIC || (T) == kDECIMAL)
315 #define IS_GEO_POLY(T) (((T) == kPOLYGON) || ((T) == kMULTIPOLYGON))
316 #define IS_GEO_LINE(T) (((T) == kLINESTRING) || ((T) == kMULTILINESTRING))
317 #define IS_GEO_MULTI(T) \
318 (((T) == kMULTIPOLYGON) || ((T) == kMULTILINESTRING) || ((T) == kMULTIPOINT))
322 #define TRANSIENT_DICT(ID) (-(ID))
323 #define REGULAR_DICT(TRANSIENTID) (-(TRANSIENTID))
407 ? ~(~size_t(0) << 15)
484 std::string srid_string =
"";
502 return elem_ti.get_type_name() + ps +
"[" + num_elems +
"]";
509 return "COLUMN<" + elem_ti.get_type_name() + ps +
">" + num_elems;
516 return "COLUMN_LIST<" + elem_ti.get_type_name() + ps +
">" + num_elems;
527 std::ostringstream oss;
530 <<
", null=" << (
get_notnull() ?
"not nullable" :
"nullable")
544 return "TextEncodingNone";
557 return (... || (types ==
type));
694 return sizeof(int32_t);
762 const auto& new_type = new_type_info.
get_type();
772 if (new_type_info.
is_fp()) {
781 if (!new_type_info.
is_fp()) {
804 return new_type ==
kDATE;
806 return new_type ==
kTIME;
930 if (
type ==
kARRAY && val && array_size > 0 && array_size ==
size) {
935 elem_ti.set_subtype(
kNULLT);
936 auto elem_size = elem_ti.get_storage_size();
962 int array_size)
const {
964 array_size ==
size) {
965 if (array_size == 2 *
sizeof(
double)) {
968 if (array_size == 2 *
sizeof(int32_t)) {
1228 switch (sql_value_type) {
1287 return sizeof(int8_t);
1289 return sizeof(int8_t);
1293 return sizeof(int16_t);
1307 return sizeof(int32_t);
1324 return sizeof(int64_t);
1338 return sizeof(float);
1352 return sizeof(double);
1370 return sizeof(int64_t);
1400 return sizeof(int32_t);
1427 #include <string_view>
1441 #ifdef HAVE_TOSTRING
1448 #include "../QueryEngine/DateAdd.h"
1449 #include "../QueryEngine/DateTruncate.h"
1450 #include "../QueryEngine/ExtractFromTime.h"
1463 #if !(defined(__CUDACC__) || defined(NO_BOOST))
1464 UNREACHABLE() <<
"Invalid number of bytes=" << nbytes;
1476 auto type_info_copy = type_info;
1478 type_info_copy.setStorageSize();
1479 return type_info_copy;
1485 return nullable_type_info;
1631 auto new_elem_ti = elem_ti;
1641 switch (elem_type) {
1672 if (c ==
kENCODING_NONE && p == 0 && (d == 9 || d == 6 || d == 0)) {
1691 ti.set_dimension(d);
1701 if (type_info.get_subtype() !=
kNULLT) {
1706 type_info.set_subtype(
kNULLT);
1720 if (m.isNestedArray()) {
1722 status = m.getItem(n, item);
1723 if (status == FlatBufferManager::Status::Success) {
1724 result->length = item.
nof_values * m.getValueSize();
1725 result->pointer = item.
values;
1726 result->is_null = item.
is_null;
1730 result->pointer = NULL;
1731 result->is_null =
true;
1735 CHECK_EQ(status, FlatBufferManager::Status::ItemUnspecifiedError);
1740 auto status = m.getItemOld(n, result->length, result->pointer, result->is_null);
1741 if (status == FlatBufferManager::Status::IndexError) {
1744 result->pointer = NULL;
1745 result->is_null =
true;
1749 CHECK_EQ(status, FlatBufferManager::Status::Success);
1763 CHECK(m.isNestedArray());
1766 status = m.getItem(n, item);
1767 if (status == FlatBufferManager::Status::Success) {
1768 result->
length = item.nof_values * m.getValueSize();
1769 result->
pointer = item.values;
1770 result->
is_null = item.is_null;
1782 CHECK_EQ(status, FlatBufferManager::Status::IndexError);
1788 const int64_t max_nof_values,
1791 int64_t& max_nof_sizes) {
1801 max_nof_sizes = items_count + 2 * max_nof_values / 3;
1804 max_nof_sizes = items_count + max_nof_values / 3;
1810 max_nof_sizes = items_count + max_nof_values / 3;
1815 max_nof_sizes = items_count + 2 * max_nof_values / 3;
1819 max_nof_sizes = items_count + max_nof_values;
1825 max_nof_sizes = items_count + max_nof_values / 3;
1840 int64_t max_nof_values,
1852 int64_t max_nof_sizes = 0;
1887 double geodouble[2];
1992 int64_t items_count,
1993 int64_t max_nof_values,
2004 int64_t max_nof_sizes = 0;
2008 int8_t* null_value_ptr = &null_value.
i8;
2017 reinterpret_cast<const int8_t*
>(&ti_lite),
bool geo_promoted_type_match(const SQLTypes a, const SQLTypes b)
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
const shared::StringDictKey & getStringDictKeySkipCompParamCheck() 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
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)
void initializeFlatBuffer(FlatBufferManager &m, int64_t items_count, int64_t max_nof_values, const SQLTypeInfo &ti)
std::string toString(const QueryDescriptionType &type)
#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
void setStringDictKeySkipCompParamCheck(const shared::StringDictKey &dict_key)
HostArrayDatum(size_t const l, int8_t *p, bool const n, CUSTOM_DELETER custom_deleter)
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
void initialize(FlatBufferFormat format_id, const int8_t *format_metadata_ptr)
void set_input_srid(int d)
std::string to_string() const
int get_physical_cols() const
bool is_fixlen_array() const
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)
FlatBufferManager::ValueType toValueType() const
bool is_timeinterval() const
bool supportsFlatBuffer() 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...
int64_t getFlatBufferSize(int64_t items_count, int64_t max_nof_values, const SQLTypeInfo &ti)
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)
bool usesFlatBuffer() const
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)
static int64_t compute_flatbuffer_size(FlatBufferFormat format_id, const int8_t *format_metadata_ptr)
SQLTypeInfoLite toLite() const
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]
HOST DEVICE EncodingType get_compression() const
void setUsesFlatBuffer(bool uses_flatbuffer=true)
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
static int64_t computeBufferSizeNestedArray(int64_t ndims, int64_t total_items_count, int64_t total_sizes_count, int64_t total_values_count, ValueType value_type, size_t user_data_size)
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...
Status initializeNestedArray(int64_t ndims, int64_t total_items_count, int64_t total_sizes_count, int64_t total_values_count, ValueType value_type, const int8_t *null_value_ptr, const int8_t *user_data_ptr, size_t user_data_size)
void getFlatBufferNDimsAndSizes(const int64_t items_count, const int64_t max_nof_values, const SQLTypeInfo &ti, size_t &ndims, int64_t &max_nof_sizes)
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
bool is_encoded_timestamp() const
bool is_high_precision_timestamp() const
double extract_fp_type_from_datum(const Datum datum, const SQLTypeInfo &ti)
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
#define NULL_ARRAY_BOOLEAN
SQLTypeInfo(SQLTypes t, EncodingType c, int p, SQLTypes st)
SQLTypeInfo(SQLTypes t, bool n)
HOST DEVICE bool get_notnull() const
HOST DEVICE size_t get_max_strlen() const
bool is_text_encoding_none() 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)