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)
486 std::string srid_string =
"";
504 return elem_ti.get_type_name() + ps +
"[" + num_elems +
"]";
511 return "COLUMN<" + elem_ti.get_type_name() + ps +
">" + num_elems;
518 return "COLUMN_LIST<" + elem_ti.get_type_name() + ps +
">" + num_elems;
529 std::ostringstream oss;
532 <<
", null=" << (
get_notnull() ?
"not nullable" :
"nullable")
546 return "TextEncodingNone";
559 return (... || (types ==
type));
696 return sizeof(int32_t);
764 const auto& new_type = new_type_info.
get_type();
774 if (new_type_info.
is_fp()) {
783 if (!new_type_info.
is_fp()) {
806 return new_type ==
kDATE;
808 return new_type ==
kTIME;
932 if (
type ==
kARRAY && val && array_size > 0 && array_size ==
size) {
937 elem_ti.set_subtype(
kNULLT);
938 auto elem_size = elem_ti.get_storage_size();
964 int array_size)
const {
966 array_size ==
size) {
967 if (array_size == 2 *
sizeof(
double)) {
970 if (array_size == 2 *
sizeof(int32_t)) {
1230 switch (sql_value_type) {
1289 return sizeof(int8_t);
1291 return sizeof(int8_t);
1295 return sizeof(int16_t);
1309 return sizeof(int32_t);
1326 return sizeof(int64_t);
1340 return sizeof(float);
1354 return sizeof(double);
1372 return sizeof(int64_t);
1402 return sizeof(int32_t);
1429 #include <string_view>
1443 #ifdef HAVE_TOSTRING
1450 #include "../QueryEngine/DateAdd.h"
1451 #include "../QueryEngine/DateTruncate.h"
1452 #include "../QueryEngine/ExtractFromTime.h"
1465 #if !(defined(__CUDACC__) || defined(NO_BOOST))
1466 UNREACHABLE() <<
"Invalid number of bytes=" << nbytes;
1478 auto type_info_copy = type_info;
1480 type_info_copy.setStorageSize();
1481 return type_info_copy;
1487 return nullable_type_info;
1633 auto new_elem_ti = elem_ti;
1643 switch (elem_type) {
1674 if (c ==
kENCODING_NONE && p == 0 && (d == 9 || d == 6 || d == 0)) {
1693 ti.set_dimension(d);
1703 if (type_info.get_subtype() !=
kNULLT) {
1708 type_info.set_subtype(
kNULLT);
1722 if (m.isNestedArray()) {
1724 status = m.getItem(n, item);
1725 if (status == FlatBufferManager::Status::Success) {
1726 result->length = item.
nof_values * m.getValueSize();
1727 result->pointer = item.
values;
1728 result->is_null = item.
is_null;
1732 result->pointer = NULL;
1733 result->is_null =
true;
1737 CHECK_EQ(status, FlatBufferManager::Status::ItemUnspecifiedError);
1742 auto status = m.getItemOld(n, result->length, result->pointer, result->is_null);
1743 if (status == FlatBufferManager::Status::IndexError) {
1746 result->pointer = NULL;
1747 result->is_null =
true;
1751 CHECK_EQ(status, FlatBufferManager::Status::Success);
1765 CHECK(m.isNestedArray());
1768 status = m.getItem(n, item);
1769 if (status == FlatBufferManager::Status::Success) {
1770 result->
length = item.nof_values * m.getValueSize();
1771 result->
pointer = item.values;
1772 result->
is_null = item.is_null;
1784 CHECK_EQ(status, FlatBufferManager::Status::IndexError);
1790 const int64_t max_nof_values,
1793 int64_t& max_nof_sizes) {
1803 max_nof_sizes = items_count + 2 * max_nof_values / 3;
1806 max_nof_sizes = items_count + max_nof_values / 3;
1812 max_nof_sizes = items_count + max_nof_values / 3;
1817 max_nof_sizes = items_count + 2 * max_nof_values / 3;
1821 max_nof_sizes = items_count + max_nof_values;
1827 max_nof_sizes = items_count + max_nof_values / 3;
1842 int64_t max_nof_values,
1854 int64_t max_nof_sizes = 0;
1889 double geodouble[2];
1994 int64_t items_count,
1995 int64_t max_nof_values,
2006 int64_t max_nof_sizes = 0;
2010 int8_t* null_value_ptr = &null_value.
i8;
2019 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)
#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)
std::string toString(const Executor::ExtModuleKinds &kind)
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 is_variable_size() 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)