Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
Value Class Reference

#include <duckdb.hpp>

Collaboration diagram for Value:

Classes

union  Val
 The value of the object, if it is of a constant size Type. More...

Public Member Functions

DUCKDB_API Value (LogicalType type=LogicalType::SQLNULL)
 Create an empty NULL value of the specified type.
DUCKDB_API Value (int32_t val)
 Create an INTEGER value.
DUCKDB_API Value (bool val)
 Create a BOOLEAN value.
DUCKDB_API Value (int64_t val)
 Create a BIGINT value.
DUCKDB_API Value (float val)
 Create a FLOAT value.
DUCKDB_API Value (double val)
 Create a DOUBLE value.
DUCKDB_API Value (const char *val)
 Create a VARCHAR value.
DUCKDB_API Value (std::nullptr_t val)
 Create a NULL value.
DUCKDB_API Value (string_t val)
 Create a VARCHAR value.
DUCKDB_API Value (string val)
 Create a VARCHAR value.
DUCKDB_API Value (String val)
 Create a VARCHAR value.
DUCKDB_API Value (const Value &other)
 Copy constructor.
DUCKDB_API Value (Value &&other) noexcept
 Move constructor.
DUCKDB_API ~Value ()
 Destructor.
DUCKDB_API Value & operator= (const Value &other)
DUCKDB_API Value & operator= (Value &&other) noexcept
LogicalType & GetTypeMutable ()
const LogicalType & type () const
bool IsNull () const
template<class T>
T GetValue () const
template<>
bool GetValue () const
template<>
int8_t GetValue () const
template<>
int16_t GetValue () const
template<>
int32_t GetValue () const
template<>
int64_t GetValue () const
template<>
hugeint_t GetValue () const
template<>
uint8_t GetValue () const
template<>
uint16_t GetValue () const
template<>
uint32_t GetValue () const
template<>
uint64_t GetValue () const
template<>
uhugeint_t GetValue () const
template<>
string GetValue () const
template<>
float GetValue () const
template<>
double GetValue () const
template<>
date_t GetValue () const
template<>
dtime_t GetValue () const
template<>
dtime_ns_t GetValue () const
template<>
timestamp_t GetValue () const
template<>
timestamp_sec_t GetValue () const
template<>
timestamp_ms_t GetValue () const
template<>
timestamp_ns_t GetValue () const
template<>
timestamp_tz_t GetValue () const
template<>
dtime_tz_t GetValue () const
template<>
DUCKDB_API interval_t GetValue () const
template<>
DUCKDB_API Value GetValue () const
template<>
DUCKDB_API bool GetValue () const
template<>
DUCKDB_API int8_t GetValue () const
template<>
DUCKDB_API int16_t GetValue () const
template<>
DUCKDB_API int32_t GetValue () const
template<>
DUCKDB_API int64_t GetValue () const
template<>
DUCKDB_API uint8_t GetValue () const
template<>
DUCKDB_API uint16_t GetValue () const
template<>
DUCKDB_API uint32_t GetValue () const
template<>
DUCKDB_API uint64_t GetValue () const
template<>
DUCKDB_API hugeint_t GetValue () const
template<>
DUCKDB_API uhugeint_t GetValue () const
template<>
DUCKDB_API string GetValue () const
template<>
DUCKDB_API float GetValue () const
template<>
DUCKDB_API double GetValue () const
template<>
DUCKDB_API date_t GetValue () const
template<>
DUCKDB_API dtime_t GetValue () const
template<>
DUCKDB_API dtime_ns_t GetValue () const
template<>
DUCKDB_API dtime_tz_t GetValue () const
template<>
DUCKDB_API timestamp_t GetValue () const
template<>
DUCKDB_API timestamp_sec_t GetValue () const
template<>
DUCKDB_API timestamp_ms_t GetValue () const
template<>
DUCKDB_API timestamp_ns_t GetValue () const
template<>
DUCKDB_API timestamp_tz_t GetValue () const
template<>
DUCKDB_API interval_t GetValue () const
template<>
DUCKDB_API Value GetValue () const
template<>
Value CreateValue (bool value)
template<>
Value CreateValue (int8_t value)
template<>
Value CreateValue (int16_t value)
template<>
Value CreateValue (int32_t value)
template<>
Value CreateValue (int64_t value)
template<>
Value CreateValue (uint8_t value)
template<>
Value CreateValue (uint16_t value)
template<>
Value CreateValue (uint32_t value)
template<>
Value CreateValue (uint64_t value)
template<>
Value CreateValue (hugeint_t value)
template<>
Value CreateValue (uhugeint_t value)
template<>
Value CreateValue (date_t value)
template<>
Value CreateValue (dtime_t value)
template<>
Value CreateValue (dtime_ns_t value)
template<>
Value CreateValue (dtime_tz_t value)
template<>
Value CreateValue (timestamp_t value)
template<>
Value CreateValue (timestamp_sec_t value)
template<>
Value CreateValue (timestamp_ms_t value)
template<>
Value CreateValue (timestamp_ns_t value)
template<>
Value CreateValue (timestamp_tz_t value)
template<>
Value CreateValue (const char *value)
template<>
Value CreateValue (string value)
template<>
Value CreateValue (string_t value)
template<>
Value CreateValue (float value)
template<>
Value CreateValue (double value)
template<>
Value CreateValue (interval_t value)
template<>
Value CreateValue (Value value)
template<>
Value DUCKDB_API CreateValue (bool value)
template<>
Value DUCKDB_API CreateValue (uint8_t value)
template<>
Value DUCKDB_API CreateValue (uint16_t value)
template<>
Value DUCKDB_API CreateValue (uint32_t value)
template<>
Value DUCKDB_API CreateValue (uint64_t value)
template<>
Value DUCKDB_API CreateValue (int8_t value)
template<>
Value DUCKDB_API CreateValue (int16_t value)
template<>
Value DUCKDB_API CreateValue (int32_t value)
template<>
Value DUCKDB_API CreateValue (int64_t value)
template<>
Value DUCKDB_API CreateValue (hugeint_t value)
template<>
Value DUCKDB_API CreateValue (uhugeint_t value)
template<>
Value DUCKDB_API CreateValue (date_t value)
template<>
Value DUCKDB_API CreateValue (dtime_t value)
template<>
Value DUCKDB_API CreateValue (dtime_ns_t value)
template<>
Value DUCKDB_API CreateValue (dtime_tz_t value)
template<>
Value DUCKDB_API CreateValue (timestamp_t value)
template<>
Value DUCKDB_API CreateValue (timestamp_sec_t value)
template<>
Value DUCKDB_API CreateValue (timestamp_ms_t value)
template<>
Value DUCKDB_API CreateValue (timestamp_ns_t value)
template<>
Value DUCKDB_API CreateValue (timestamp_tz_t value)
template<>
Value DUCKDB_API CreateValue (const char *value)
template<>
Value DUCKDB_API CreateValue (string value)
template<>
Value DUCKDB_API CreateValue (string_t value)
template<>
Value DUCKDB_API CreateValue (float value)
template<>
Value DUCKDB_API CreateValue (double value)
template<>
Value DUCKDB_API CreateValue (interval_t value)
template<>
Value DUCKDB_API CreateValue (Value value)
template<class T>
T GetValueUnsafe () const
template<>
DUCKDB_API bool GetValueUnsafe () const
template<>
int8_t GetValueUnsafe () const
template<>
int16_t GetValueUnsafe () const
template<>
int32_t GetValueUnsafe () const
template<>
int64_t GetValueUnsafe () const
template<>
hugeint_t GetValueUnsafe () const
template<>
uint8_t GetValueUnsafe () const
template<>
uint16_t GetValueUnsafe () const
template<>
uint32_t GetValueUnsafe () const
template<>
uint64_t GetValueUnsafe () const
template<>
uhugeint_t GetValueUnsafe () const
template<>
string GetValueUnsafe () const
template<>
DUCKDB_API string_t GetValueUnsafe () const
template<>
DUCKDB_API bignum_t GetValueUnsafe () const
template<>
float GetValueUnsafe () const
template<>
double GetValueUnsafe () const
template<>
date_t GetValueUnsafe () const
template<>
dtime_t GetValueUnsafe () const
template<>
dtime_ns_t GetValueUnsafe () const
template<>
dtime_tz_t GetValueUnsafe () const
template<>
timestamp_t GetValueUnsafe () const
template<>
timestamp_sec_t GetValueUnsafe () const
template<>
timestamp_ms_t GetValueUnsafe () const
template<>
timestamp_ns_t GetValueUnsafe () const
template<>
timestamp_tz_t GetValueUnsafe () const
template<>
interval_t GetValueUnsafe () const
template<>
DUCKDB_API bool GetValueUnsafe () const
template<>
DUCKDB_API int8_t GetValueUnsafe () const
template<>
DUCKDB_API int16_t GetValueUnsafe () const
template<>
DUCKDB_API int32_t GetValueUnsafe () const
template<>
DUCKDB_API int64_t GetValueUnsafe () const
template<>
DUCKDB_API hugeint_t GetValueUnsafe () const
template<>
DUCKDB_API uhugeint_t GetValueUnsafe () const
template<>
DUCKDB_API uint8_t GetValueUnsafe () const
template<>
DUCKDB_API uint16_t GetValueUnsafe () const
template<>
DUCKDB_API uint32_t GetValueUnsafe () const
template<>
DUCKDB_API uint64_t GetValueUnsafe () const
template<>
DUCKDB_API string GetValueUnsafe () const
template<>
DUCKDB_API string_t GetValueUnsafe () const
template<>
DUCKDB_API float GetValueUnsafe () const
template<>
DUCKDB_API double GetValueUnsafe () const
template<>
DUCKDB_API date_t GetValueUnsafe () const
template<>
DUCKDB_API dtime_t GetValueUnsafe () const
template<>
DUCKDB_API dtime_ns_t GetValueUnsafe () const
template<>
DUCKDB_API dtime_tz_t GetValueUnsafe () const
template<>
DUCKDB_API timestamp_t GetValueUnsafe () const
template<>
DUCKDB_API timestamp_sec_t GetValueUnsafe () const
template<>
DUCKDB_API timestamp_ms_t GetValueUnsafe () const
template<>
DUCKDB_API timestamp_ns_t GetValueUnsafe () const
template<>
DUCKDB_API timestamp_tz_t GetValueUnsafe () const
template<>
DUCKDB_API interval_t GetValueUnsafe () const
Value Copy () const
 Return a copy of this value.
DUCKDB_API hash_t Hash () const
 Hashes the Value.
DUCKDB_API string ToString () const
 Convert this value to a string.
DUCKDB_API string ToSQLString () const
 Convert this value to a SQL-parseable string.
DUCKDB_API uintptr_t GetPointer () const
DUCKDB_API Value CastAs (CastFunctionSet &set, GetCastFunctionInput &get_input, const LogicalType &target_type, bool strict=false) const
 Cast this value to another type, throws exception if its not possible.
DUCKDB_API Value CastAs (ClientContext &context, const LogicalType &target_type, bool strict=false) const
DUCKDB_API Value DefaultCastAs (const LogicalType &target_type, bool strict=false) const
DUCKDB_API bool TryCastAs (CastFunctionSet &set, GetCastFunctionInput &get_input, const LogicalType &target_type, Value &new_value, string *error_message, bool strict=false) const
 Tries to cast this value to another type, and stores the result in "new_value".
DUCKDB_API bool TryCastAs (ClientContext &context, const LogicalType &target_type, Value &new_value, string *error_message, bool strict=false) const
DUCKDB_API bool TryCastAs (CastFunctionSet &set, GetCastFunctionInput &get_input, const LogicalType &target_type, bool strict=false)
 Tries to cast this value to another type, and stores the result in THIS value again.
DUCKDB_API bool TryCastAs (ClientContext &context, const LogicalType &target_type, bool strict=false)
DUCKDB_API bool DefaultTryCastAs (const LogicalType &target_type, Value &new_value, string *error_message, bool strict=false) const
DUCKDB_API bool DefaultTryCastAs (const LogicalType &target_type, bool strict=false)
DUCKDB_API void Reinterpret (LogicalType new_type)
DUCKDB_API void Serialize (Serializer &serializer) const
 Serializes a Value to a stand-alone binary blob.
DUCKDB_API bool operator== (const Value &rhs) const
DUCKDB_API bool operator== (const int64_t &rhs) const
DUCKDB_API bool operator!= (const Value &rhs) const
DUCKDB_API bool operator!= (const int64_t &rhs) const
DUCKDB_API bool operator< (const Value &rhs) const
DUCKDB_API bool operator< (const int64_t &rhs) const
DUCKDB_API bool operator> (const Value &rhs) const
DUCKDB_API bool operator> (const int64_t &rhs) const
DUCKDB_API bool operator<= (const Value &rhs) const
DUCKDB_API bool operator<= (const int64_t &rhs) const
DUCKDB_API bool operator>= (const Value &rhs) const
DUCKDB_API bool operator>= (const int64_t &rhs) const
template<>
bool IsNan (float input)
template<>
bool IsNan (double input)
template<>
DUCKDB_API bool IsNan (float input)
template<>
DUCKDB_API bool IsNan (double input)
template<>
bool IsFinite (float input)
template<>
bool IsFinite (double input)
template<>
bool IsFinite (date_t input)
template<>
bool IsFinite (timestamp_t input)
template<>
bool IsFinite (timestamp_sec_t input)
template<>
bool IsFinite (timestamp_ms_t input)
template<>
bool IsFinite (timestamp_ns_t input)
template<>
bool IsFinite (timestamp_tz_t input)
template<>
DUCKDB_API bool IsFinite (float input)
template<>
DUCKDB_API bool IsFinite (double input)
template<>
DUCKDB_API bool IsFinite (date_t input)
template<>
DUCKDB_API bool IsFinite (timestamp_t input)
template<>
DUCKDB_API bool IsFinite (timestamp_sec_t input)
template<>
DUCKDB_API bool IsFinite (timestamp_ms_t input)
template<>
DUCKDB_API bool IsFinite (timestamp_ns_t input)
template<>
DUCKDB_API bool IsFinite (timestamp_tz_t input)
DUCKDB_API void Print () const

Static Public Member Functions

static DUCKDB_API Value MinimumValue (const LogicalType &type)
 Create the lowest possible value of a given type (numeric only).
static DUCKDB_API Value MaximumValue (const LogicalType &type)
 Create the highest possible value of a given type (numeric only).
static DUCKDB_API Value NegativeInfinity (const LogicalType &type)
 Create the negative infinite value of a given type (numeric only).
static DUCKDB_API Value Infinity (const LogicalType &type)
 Create the positive infinite value of a given type (numeric only).
static DUCKDB_API Value Numeric (const LogicalType &type, int64_t value)
 Create a Numeric value of the specified type with the specified value.
static DUCKDB_API Value Numeric (const LogicalType &type, hugeint_t value)
static DUCKDB_API Value Numeric (const LogicalType &type, uhugeint_t value)
static DUCKDB_API Value BOOLEAN (bool value)
 Create a boolean Value from a specified value.
static DUCKDB_API Value TINYINT (int8_t value)
 Create a tinyint Value from a specified value.
static DUCKDB_API Value SMALLINT (int16_t value)
 Create a smallint Value from a specified value.
static DUCKDB_API Value INTEGER (int32_t value)
 Create an integer Value from a specified value.
static DUCKDB_API Value BIGINT (int64_t value)
 Create a bigint Value from a specified value.
static DUCKDB_API Value UTINYINT (uint8_t value)
 Create an unsigned tinyint Value from a specified value.
static DUCKDB_API Value USMALLINT (uint16_t value)
 Create an unsigned smallint Value from a specified value.
static DUCKDB_API Value UINTEGER (uint32_t value)
 Create an unsigned integer Value from a specified value.
static DUCKDB_API Value UBIGINT (uint64_t value)
 Create an unsigned bigint Value from a specified value.
static DUCKDB_API Value HUGEINT (hugeint_t value)
 Create a hugeint Value from a specified value.
static DUCKDB_API Value UHUGEINT (uhugeint_t value)
 Create a uhugeint Value from a specified value.
static DUCKDB_API Value UUID (const string &value)
 Create a uuid Value from a specified value.
static DUCKDB_API Value UUID (hugeint_t value)
 Create a uuid Value from a specified value.
static DUCKDB_API Value HASH (hash_t value)
 Create a hash Value from a specified value.
static DUCKDB_API Value POINTER (uintptr_t value)
 Create a pointer Value from a specified value.
static DUCKDB_API Value DATE (date_t date)
 Create a date Value from a specified date.
static DUCKDB_API Value DATE (int32_t year, int32_t month, int32_t day)
 Create a date Value from a specified date.
static DUCKDB_API Value TIME (dtime_t time)
 Create a time Value from a specified time.
static DUCKDB_API Value TIME (int32_t hour, int32_t min, int32_t sec, int32_t micros)
 Create a time Value from a specified time.
static DUCKDB_API Value TIME_NS (dtime_ns_t time)
static DUCKDB_API Value TIMETZ (dtime_tz_t time)
static DUCKDB_API Value TIMESTAMP (date_t date, dtime_t time)
 Create a timestamp Value from a specified date/time combination.
static DUCKDB_API Value TIMESTAMP (timestamp_t timestamp)
 Create a timestamp Value from a specified value.
static DUCKDB_API Value TIMESTAMP (int32_t year, int32_t month, int32_t day, int32_t hour, int32_t min, int32_t sec, int32_t micros)
 Create a timestamp Value from a specified timestamp in separate values.
static DUCKDB_API Value TIMESTAMPSEC (timestamp_sec_t timestamp)
 Create a timestamp_s Value from a specified value.
static DUCKDB_API Value TIMESTAMPMS (timestamp_ms_t timestamp)
 Create a timestamp_ms Value from a specified value.
static DUCKDB_API Value TIMESTAMPNS (timestamp_ns_t timestamp)
 Create a timestamp_ns Value from a specified value.
static DUCKDB_API Value TIMESTAMPTZ (timestamp_tz_t timestamp)
 Create a timestamp_tz Value from a specified value.
static DUCKDB_API Value INTERVAL (int32_t months, int32_t days, int64_t micros)
static DUCKDB_API Value INTERVAL (interval_t interval)
static DUCKDB_API Value ENUM (uint64_t value, const LogicalType &original_type)
static DUCKDB_API Value DECIMAL (int16_t value, uint8_t width, uint8_t scale)
static DUCKDB_API Value DECIMAL (int32_t value, uint8_t width, uint8_t scale)
static DUCKDB_API Value DECIMAL (int64_t value, uint8_t width, uint8_t scale)
static DUCKDB_API Value DECIMAL (hugeint_t value, uint8_t width, uint8_t scale)
static DUCKDB_API Value FLOAT (float value)
 Create a float Value from a specified value.
static DUCKDB_API Value DOUBLE (double value)
 Create a double Value from a specified value.
static DUCKDB_API Value STRUCT (child_list_t< Value > values)
 Create a struct value with given list of entries.
static DUCKDB_API Value STRUCT (const LogicalType &type, vector< Value > struct_values)
static DUCKDB_API Value VARIANT (vector< Value > children)
 Create a variant value with given list of internal variant data (keys/children/values/data).
static DUCKDB_API Value LIST (const LogicalType &child_type, vector< Value > values)
 Create a list value with the given entries.
static DUCKDB_API Value LIST (vector< Value > values)
static DUCKDB_API Value ARRAY (const LogicalType &type, vector< Value > values)
static DUCKDB_API Value MAP (const LogicalType &child_type, vector< Value > values)
 Create a map value with the given entries.
static DUCKDB_API Value MAP (const LogicalType &key_type, const LogicalType &value_type, vector< Value > keys, vector< Value > values)
 Create a map value with the given entries.
static DUCKDB_API Value MAP (const InsertionOrderPreservingMap< string > &kv_pairs)
 Create a map value from a set of key-value pairs.
static DUCKDB_API Value UNION (child_list_t< LogicalType > members, uint8_t tag, Value value)
 Create a union value from a selected value and a tag from a set of alternatives.
static DUCKDB_API Value BLOB (const_data_ptr_t data, idx_t len)
 Create a blob Value from a data pointer and a length: no bytes are interpreted.
static DUCKDB_API Value BLOB (const string &data)
 Creates a blob by casting a specified string to a blob (i.e. interpreting \x characters).
static Value BLOB_RAW (const string &data)
static DUCKDB_API Value BIT (const_data_ptr_t data, idx_t len)
 Creates a bitstring by casting a specified string to a bitstring.
static DUCKDB_API Value BIT (const string &data)
static DUCKDB_API Value BIGNUM (const_data_ptr_t data, idx_t len)
static DUCKDB_API Value BIGNUM (const string &data)
static DUCKDB_API Value GEOMETRY (const_data_ptr_t data, idx_t len)
static DUCKDB_API Value GEOMETRY (const_data_ptr_t data, idx_t len, const CoordinateReferenceSystem &crs)
static DUCKDB_API Value TYPE (const LogicalType &type)
static DUCKDB_API Value TYPE (const string_t &serialized_type)
static DUCKDB_API Value AGGREGATE_STATE (const LogicalType &type, const_data_ptr_t data, idx_t len)
 Creates an aggregate state.
template<class T>
static Value CreateValue (T value)
static DUCKDB_API Value Deserialize (Deserializer &deserializer)
 Deserializes a Value from a blob.
static DUCKDB_API bool FloatIsFinite (float value)
static DUCKDB_API bool DoubleIsFinite (double value)
template<class T>
static bool IsNan (T value)
template<class T>
static bool IsFinite (T value)
static DUCKDB_API bool StringIsValid (const char *str, idx_t length)
static bool StringIsValid (const string &str)
static DUCKDB_API bool ValuesAreEqual (CastFunctionSet &set, GetCastFunctionInput &get_input, const Value &result_value, const Value &value)
static DUCKDB_API bool ValuesAreEqual (ClientContext &context, const Value &result_value, const Value &value)
static DUCKDB_API bool DefaultValuesAreEqual (const Value &result_value, const Value &value)
static DUCKDB_API bool NotDistinctFrom (const Value &lvalue, const Value &rvalue)
 Returns true if the values are not distinct from each other, following SQL semantics for NOT DISTINCT FROM.

Private Member Functions

void SerializeInternal (Serializer &serializer, bool serialize_type) const
template<class T>
T GetValueInternal () const

Static Private Member Functions

static void SerializeChildren (Serializer &serializer, const vector< Value > &children, const LogicalType &parent_type)

Private Attributes

LogicalType type_
 The logical of the value.
bool is_null
 Whether or not the value is NULL.
union duckdb::Value::Val value_
shared_ptr< ExtraValueInfo > value_info_

Friends

struct StringValue
struct StructValue
struct ListValue
struct UnionValue
struct ArrayValue
struct MapValue
struct TypeValue
std::ostream & operator<< (std::ostream &out, const Value &val)

Detailed Description

The Value object holds a single arbitrary value of any type that can be stored in the database.

Constructor & Destructor Documentation

◆ Value() [1/13]

duckdb::Value::Value ( LogicalType type = LogicalType::SQLNULL)
explicit

Create an empty NULL value of the specified type.

131807 : type_(std::move(type)), is_null(true) {
131808}
LogicalType type_
The logical of the value.
Definition duckdb.hpp:5934
bool is_null
Whether or not the value is NULL.
Definition duckdb.hpp:5937

◆ Value() [2/13]

Create an INTEGER value.

131810 : type_(LogicalType::INTEGER), is_null(false) {
131811 value_.integer = val;
131812}

◆ Value() [3/13]

duckdb::Value::Value ( bool val)
explicit

Create a BOOLEAN value.

131814 : type_(LogicalType::BOOLEAN), is_null(false) {
131815 value_.boolean = val;
131816}

◆ Value() [4/13]

Create a BIGINT value.

131818 : type_(LogicalType::BIGINT), is_null(false) {
131819 value_.bigint = val;
131820}

◆ Value() [5/13]

duckdb::Value::Value ( float val)

Create a FLOAT value.

131822 : type_(LogicalType::FLOAT), is_null(false) {
131823 value_.float_ = val;
131824}

◆ Value() [6/13]

duckdb::Value::Value ( double val)

Create a DOUBLE value.

131826 : type_(LogicalType::DOUBLE), is_null(false) {
131827 value_.double_ = val;
131828}

◆ Value() [7/13]

duckdb::Value::Value ( const char * val)

Create a VARCHAR value.

131830 : Value(val ? string(val) : string()) {
131831}
DUCKDB_API Value(LogicalType type=LogicalType::SQLNULL)
Create an empty NULL value of the specified type.
Definition duckdb.cpp:131807

◆ Value() [8/13]

duckdb::Value::Value ( std::nullptr_t val)

Create a NULL value.

131833 : Value(LogicalType::VARCHAR) {
131834}

◆ Value() [9/13]

Create a VARCHAR value.

131836 : Value(val.GetString()) {
131837}

◆ Value() [10/13]

duckdb::Value::Value ( string val)

Create a VARCHAR value.

131839 : type_(LogicalType::VARCHAR), is_null(false) {
131840 if (!Value::StringIsValid(val.c_str(), val.size())) {
131841 throw ErrorManager::InvalidUnicodeError(val, "value construction");
131842 }
131843 value_info_ = make_shared_ptr<StringValueInfo>(std::move(val));
131844}

◆ Value() [11/13]

Create a VARCHAR value.

131846 : type_(LogicalType::VARCHAR), is_null(false) {
131847 if (!Value::StringIsValid(val.c_str(), val.size())) {
131848 throw ErrorManager::InvalidUnicodeError(val, "value construction");
131849 }
131850 value_info_ = make_shared_ptr<StringValueInfo>(val.ToStdString());
131851}

◆ Value() [12/13]

duckdb::Value::Value ( const Value & other)

Copy constructor.

131857 : type_(other.type_), is_null(other.is_null), value_(other.value_), value_info_(other.value_info_) {
131858}

◆ Value() [13/13]

duckdb::Value::Value ( Value && other)
noexcept

Move constructor.

131861 : type_(std::move(other.type_)), is_null(other.is_null), value_(other.value_),
131862 value_info_(std::move(other.value_info_)) {
131863}

◆ ~Value()

Destructor.

131853 {
131854}

Member Function Documentation

◆ operator=() [1/2]

Value & duckdb::Value::operator= ( const Value & other)
131865 {
131866 if (this == &other) {
131867 return *this;
131868 }
131869 type_ = other.type_;
131870 is_null = other.is_null;
131871 value_ = other.value_;
131872 value_info_ = other.value_info_;
131873 return *this;
131874}
LogicalType type_
The logical of the value.
Definition duckdb.hpp:5934
bool is_null
Whether or not the value is NULL.
Definition duckdb.hpp:5937

◆ operator=() [2/2]

Value & duckdb::Value::operator= ( Value && other)
noexcept
131876 {
131877 type_ = std::move(other.type_);
131878 is_null = other.is_null;
131879 value_ = other.value_;
131880 value_info_ = std::move(other.value_info_);
131881 return *this;
131882}

◆ GetTypeMutable()

LogicalType & duckdb::Value::GetTypeMutable ( )
inline
5691 {
5692 return type_;
5693 }

◆ type()

const LogicalType & duckdb::Value::type ( ) const
inline
5694 { // NOLINT
5695 return type_;
5696 }

◆ IsNull()

bool duckdb::Value::IsNull ( ) const
inline
5697 {
5698 return is_null;
5699 }

◆ MinimumValue()

Create the lowest possible value of a given type (numeric only).

131884 {
131885 switch (type.id()) {
131886 case LogicalTypeId::BOOLEAN:
131887 return Value::BOOLEAN(false);
131888 case LogicalTypeId::TINYINT:
131889 return Value::TINYINT(NumericLimits<int8_t>::Minimum());
131890 case LogicalTypeId::SMALLINT:
131891 return Value::SMALLINT(NumericLimits<int16_t>::Minimum());
131892 case LogicalTypeId::INTEGER:
131893 case LogicalTypeId::SQLNULL:
131894 return Value::INTEGER(NumericLimits<int32_t>::Minimum());
131895 case LogicalTypeId::BIGINT:
131896 return Value::BIGINT(NumericLimits<int64_t>::Minimum());
131897 case LogicalTypeId::HUGEINT:
131898 return Value::HUGEINT(NumericLimits<hugeint_t>::Minimum());
131899 case LogicalTypeId::UHUGEINT:
131900 return Value::UHUGEINT(NumericLimits<uhugeint_t>::Minimum());
131901 case LogicalTypeId::UUID:
131902 return Value::UUID(NumericLimits<hugeint_t>::Minimum());
131903 case LogicalTypeId::UTINYINT:
131904 return Value::UTINYINT(NumericLimits<uint8_t>::Minimum());
131905 case LogicalTypeId::USMALLINT:
131906 return Value::USMALLINT(NumericLimits<uint16_t>::Minimum());
131907 case LogicalTypeId::UINTEGER:
131908 return Value::UINTEGER(NumericLimits<uint32_t>::Minimum());
131909 case LogicalTypeId::UBIGINT:
131910 return Value::UBIGINT(NumericLimits<uint64_t>::Minimum());
131911 case LogicalTypeId::DATE:
131912 return Value::DATE(Date::FromDate(Date::DATE_MIN_YEAR, Date::DATE_MIN_MONTH, Date::DATE_MIN_DAY));
131913 case LogicalTypeId::TIME:
131914 return Value::TIME(dtime_t(0));
131915 case LogicalTypeId::TIME_NS:
131916 return Value::TIME_NS(dtime_ns_t(0));
131917 case LogicalTypeId::TIMESTAMP: {
131918 const auto date = Date::FromDate(Timestamp::MIN_YEAR, Timestamp::MIN_MONTH, Timestamp::MIN_DAY);
131919 return Value::TIMESTAMP(date, dtime_t(0));
131920 }
131921 case LogicalTypeId::TIMESTAMP_SEC: {
131922 // Get the minimum timestamp and cast it to timestamp_sec_t.
131923 const auto min_ts = MinimumValue(LogicalType::TIMESTAMP).GetValue<timestamp_t>();
131924 const auto ts = Cast::Operation<timestamp_t, timestamp_sec_t>(min_ts);
131925 return Value::TIMESTAMPSEC(ts);
131926 }
131927 case LogicalTypeId::TIMESTAMP_MS: {
131928 // Get the minimum timestamp and cast it to timestamp_ms_t.
131929 const auto min_ts = MinimumValue(LogicalType::TIMESTAMP).GetValue<timestamp_t>();
131930 const auto ts = Cast::Operation<timestamp_t, timestamp_ms_t>(min_ts);
131931 return Value::TIMESTAMPMS(ts);
131932 }
131934 // Clear the fractional day.
131935 auto min_ns = NumericLimits<int64_t>::Minimum();
131936 min_ns /= Interval::NANOS_PER_DAY;
131937 min_ns *= Interval::NANOS_PER_DAY;
131938 return Value::TIMESTAMPNS(timestamp_ns_t(min_ns));
131939 }
131940 case LogicalTypeId::TIME_TZ:
131941 // "00:00:00+1559" from the PG docs, but actually 00:00:00+15:59:59
131942 return Value::TIMETZ(dtime_tz_t(dtime_t(0), dtime_tz_t::MAX_OFFSET));
131943 case LogicalTypeId::TIMESTAMP_TZ: {
131944 const auto date = Date::FromDate(Timestamp::MIN_YEAR, Timestamp::MIN_MONTH, Timestamp::MIN_DAY);
131945 const auto ts = Timestamp::FromDatetime(date, dtime_t(0));
131946 return Value::TIMESTAMPTZ(timestamp_tz_t(ts));
131947 }
131948 case LogicalTypeId::FLOAT:
131949 return Value::FLOAT(NumericLimits<float>::Minimum());
131950 case LogicalTypeId::DOUBLE:
131951 return Value::DOUBLE(NumericLimits<double>::Minimum());
131952 case LogicalTypeId::DECIMAL: {
131953 auto width = DecimalType::GetWidth(type);
131954 auto scale = DecimalType::GetScale(type);
131955 switch (type.InternalType()) {
131956 case PhysicalType::INT16:
131957 return Value::DECIMAL(int16_t(-NumericHelper::POWERS_OF_TEN[width] + 1), width, scale);
131958 case PhysicalType::INT32:
131959 return Value::DECIMAL(int32_t(-NumericHelper::POWERS_OF_TEN[width] + 1), width, scale);
131960 case PhysicalType::INT64:
131961 return Value::DECIMAL(int64_t(-NumericHelper::POWERS_OF_TEN[width] + 1), width, scale);
131962 case PhysicalType::INT128:
131963 return Value::DECIMAL(-Hugeint::POWERS_OF_TEN[width] + 1, width, scale);
131964 default:
131965 throw InternalException("Unknown decimal type");
131966 }
131967 }
131968 case LogicalTypeId::ENUM:
131969 return Value::ENUM(0, type);
131970 case LogicalTypeId::BIGNUM:
131971 return Value::BIGNUM(Bignum::VarcharToBignum(
131972 "-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540"
131973 "4589535143824642343213268894641827684675467035375169860499105765512820762454900903893289440758685084551339"
131974 "42304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368"));
131975 default:
131976 throw InvalidTypeException(type, "MinimumValue requires numeric type");
131977 }
131978}
static DUCKDB_API string VarcharToBignum(const string_t &value)
Function to convert Varchar to BIGNUM blob.
Definition duckdb.cpp:112580
static DUCKDB_API date_t FromDate(int32_t year, int32_t month, int32_t day)
Create a Date object from a specified (year, month, day) combination.
Definition duckdb.cpp:117328
static DUCKDB_API timestamp_t FromDatetime(date_t date, dtime_t time)
Create a Timestamp object from a specified (date, time) combination.
Definition duckdb.cpp:129804
static DUCKDB_API Value INTEGER(int32_t value)
Create an integer Value from a specified value.
Definition duckdb.cpp:132139
static DUCKDB_API Value HUGEINT(hugeint_t value)
Create a hugeint Value from a specified value.
Definition duckdb.cpp:132153
static DUCKDB_API Value MinimumValue(const LogicalType &type)
Create the lowest possible value of a given type (numeric only).
Definition duckdb.cpp:131884
static DUCKDB_API Value SMALLINT(int16_t value)
Create a smallint Value from a specified value.
Definition duckdb.cpp:132132
static DUCKDB_API Value BOOLEAN(bool value)
Create a boolean Value from a specified value.
Definition duckdb.cpp:132118
static DUCKDB_API Value TIME(dtime_t time)
Create a time Value from a specified time.
Definition duckdb.cpp:132349
static DUCKDB_API Value TIMESTAMPNS(timestamp_ns_t timestamp)
Create a timestamp_ns Value from a specified value.
Definition duckdb.cpp:132395
static DUCKDB_API Value TIMESTAMP(date_t date, dtime_t time)
Create a timestamp Value from a specified date/time combination.
Definition duckdb.cpp:132409
static DUCKDB_API Value BIGINT(int64_t value)
Create a bigint Value from a specified value.
Definition duckdb.cpp:132146
static DUCKDB_API Value DOUBLE(double value)
Create a double Value from a specified value.
Definition duckdb.cpp:132317
static DUCKDB_API Value UHUGEINT(uhugeint_t value)
Create a uhugeint Value from a specified value.
Definition duckdb.cpp:132160
static DUCKDB_API Value USMALLINT(uint16_t value)
Create an unsigned smallint Value from a specified value.
Definition duckdb.cpp:132188
static DUCKDB_API Value UINTEGER(uint32_t value)
Create an unsigned integer Value from a specified value.
Definition duckdb.cpp:132195
static DUCKDB_API Value TIMESTAMPTZ(timestamp_tz_t timestamp)
Create a timestamp_tz Value from a specified value.
Definition duckdb.cpp:132402
static DUCKDB_API Value TIMESTAMPMS(timestamp_ms_t timestamp)
Create a timestamp_ms Value from a specified value.
Definition duckdb.cpp:132388
static DUCKDB_API Value UTINYINT(uint8_t value)
Create an unsigned tinyint Value from a specified value.
Definition duckdb.cpp:132181
static DUCKDB_API Value FLOAT(float value)
Create a float Value from a specified value.
Definition duckdb.cpp:132310
static DUCKDB_API Value TIMESTAMPSEC(timestamp_sec_t timestamp)
Create a timestamp_s Value from a specified value.
Definition duckdb.cpp:132381
static DUCKDB_API Value UUID(const string &value)
Create a uuid Value from a specified value.
Definition duckdb.cpp:132174
static DUCKDB_API Value DATE(date_t date)
Create a date Value from a specified date.
Definition duckdb.cpp:132338
static DUCKDB_API Value TINYINT(int8_t value)
Create a tinyint Value from a specified value.
Definition duckdb.cpp:132125
static DUCKDB_API Value UBIGINT(uint64_t value)
Create an unsigned bigint Value from a specified value.
Definition duckdb.cpp:132202
void scale(cv::Mat &mat, const cv::Mat &range, const T min, const T max)
::int64_t int64_t
::int32_t int32_t
::int16_t int16_t
@ TIMESTAMP_NS
us
Definition duckdb.hpp:2886
@ INT64
Signed 64-bit little-endian integer.
Definition duckdb.hpp:2767
@ INT16
Signed 16-bit little-endian integer.
Definition duckdb.hpp:2755
@ INT32
Signed 32-bit little-endian integer.
Definition duckdb.hpp:2761

◆ MaximumValue()

Create the highest possible value of a given type (numeric only).

131980 {
131981 switch (type.id()) {
131982 case LogicalTypeId::BOOLEAN:
131983 return Value::BOOLEAN(true);
131984 case LogicalTypeId::TINYINT:
131985 return Value::TINYINT(NumericLimits<int8_t>::Maximum());
131986 case LogicalTypeId::SMALLINT:
131987 return Value::SMALLINT(NumericLimits<int16_t>::Maximum());
131988 case LogicalTypeId::INTEGER:
131989 case LogicalTypeId::SQLNULL:
131990 return Value::INTEGER(NumericLimits<int32_t>::Maximum());
131991 case LogicalTypeId::BIGINT:
131992 return Value::BIGINT(NumericLimits<int64_t>::Maximum());
131993 case LogicalTypeId::HUGEINT:
131994 return Value::HUGEINT(NumericLimits<hugeint_t>::Maximum());
131995 case LogicalTypeId::UHUGEINT:
131996 return Value::UHUGEINT(NumericLimits<uhugeint_t>::Maximum());
131997 case LogicalTypeId::UUID:
131998 return Value::UUID(NumericLimits<hugeint_t>::Maximum());
131999 case LogicalTypeId::UTINYINT:
132000 return Value::UTINYINT(NumericLimits<uint8_t>::Maximum());
132001 case LogicalTypeId::USMALLINT:
132002 return Value::USMALLINT(NumericLimits<uint16_t>::Maximum());
132003 case LogicalTypeId::UINTEGER:
132004 return Value::UINTEGER(NumericLimits<uint32_t>::Maximum());
132005 case LogicalTypeId::UBIGINT:
132006 return Value::UBIGINT(NumericLimits<uint64_t>::Maximum());
132007 case LogicalTypeId::DATE:
132008 return Value::DATE(Date::FromDate(Date::DATE_MAX_YEAR, Date::DATE_MAX_MONTH, Date::DATE_MAX_DAY));
132009 case LogicalTypeId::TIME:
132010 // 24:00:00 according to PG
132011 return Value::TIME(dtime_t(Interval::MICROS_PER_DAY));
132012 case LogicalTypeId::TIME_NS:
132013 // 24:00:00 according to PG
132014 return Value::TIME_NS(dtime_ns_t(Interval::NANOS_PER_DAY));
132015 case LogicalTypeId::TIMESTAMP:
132016 return Value::TIMESTAMP(timestamp_t(NumericLimits<int64_t>::Maximum() - 1));
132017 case LogicalTypeId::TIMESTAMP_SEC: {
132018 // Get the maximum timestamp and cast it to timestamp_s_t.
132019 const auto max_ts = MaximumValue(LogicalType::TIMESTAMP).GetValue<timestamp_t>();
132020 const auto ts = Cast::Operation<timestamp_t, timestamp_sec_t>(max_ts);
132021 return Value::TIMESTAMPSEC(ts);
132022 }
132023 case LogicalTypeId::TIMESTAMP_MS: {
132024 // Get the maximum timestamp and cast it to timestamp_ms_t.
132025 const auto max_ts = MaximumValue(LogicalType::TIMESTAMP).GetValue<timestamp_t>();
132026 const auto ts = Cast::Operation<timestamp_t, timestamp_ms_t>(max_ts);
132027 return Value::TIMESTAMPMS(ts);
132028 }
132030 const auto ts = timestamp_ns_t(NumericLimits<int64_t>::Maximum() - 1);
132031 return Value::TIMESTAMPNS(ts);
132032 }
132033 case LogicalTypeId::TIMESTAMP_TZ:
132034 return Value::TIMESTAMPTZ(timestamp_tz_t(NumericLimits<int64_t>::Maximum() - 1));
132035 case LogicalTypeId::TIME_TZ:
132036 // "24:00:00-1559" from the PG docs but actually "24:00:00-15:59:59".
132037 return Value::TIMETZ(dtime_tz_t(dtime_t(Interval::MICROS_PER_DAY), dtime_tz_t::MIN_OFFSET));
132038 case LogicalTypeId::FLOAT:
132039 return Value::FLOAT(NumericLimits<float>::Maximum());
132040 case LogicalTypeId::DOUBLE:
132041 return Value::DOUBLE(NumericLimits<double>::Maximum());
132042 case LogicalTypeId::DECIMAL: {
132043 auto width = DecimalType::GetWidth(type);
132044 auto scale = DecimalType::GetScale(type);
132045 switch (type.InternalType()) {
132046 case PhysicalType::INT16:
132047 return Value::DECIMAL(int16_t(NumericHelper::POWERS_OF_TEN[width] - 1), width, scale);
132048 case PhysicalType::INT32:
132049 return Value::DECIMAL(int32_t(NumericHelper::POWERS_OF_TEN[width] - 1), width, scale);
132050 case PhysicalType::INT64:
132051 return Value::DECIMAL(int64_t(NumericHelper::POWERS_OF_TEN[width] - 1), width, scale);
132052 case PhysicalType::INT128:
132053 return Value::DECIMAL(Hugeint::POWERS_OF_TEN[width] - 1, width, scale);
132054 default:
132055 throw InternalException("Unknown decimal type");
132056 }
132057 }
132058 case LogicalTypeId::ENUM: {
132059 auto enum_size = EnumType::GetSize(type);
132060 return Value::ENUM(enum_size - (enum_size ? 1 : 0), type);
132061 }
132062 case LogicalTypeId::BIGNUM:
132063 return Value::BIGNUM(Bignum::VarcharToBignum(
132064 "1797693134862315708145274237317043567980705675258449965989174768031572607800285387605895586327668781715404"
132065 "5895351438246423432132688946418276846754670353751698604991057655128207624549009038932894407586850845513394"
132066 "2304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368"));
132067 default:
132068 throw InvalidTypeException(type, "MaximumValue requires numeric type");
132069 }
132070}
static DUCKDB_API Value MaximumValue(const LogicalType &type)
Create the highest possible value of a given type (numeric only).
Definition duckdb.cpp:131980

◆ NegativeInfinity()

Create the negative infinite value of a given type (numeric only).

132095 {
132096 switch (type.id()) {
132097 case LogicalTypeId::DATE:
132098 return Value::DATE(date_t::ninfinity());
132099 case LogicalTypeId::TIMESTAMP:
132100 return Value::TIMESTAMP(timestamp_t::ninfinity());
132101 case LogicalTypeId::TIMESTAMP_SEC:
132102 return Value::TIMESTAMPSEC(timestamp_sec_t(timestamp_t::ninfinity().value));
132103 case LogicalTypeId::TIMESTAMP_MS:
132104 return Value::TIMESTAMPMS(timestamp_ms_t(timestamp_t::ninfinity().value));
132106 return Value::TIMESTAMPNS(timestamp_ns_t(timestamp_t::ninfinity().value));
132107 case LogicalTypeId::TIMESTAMP_TZ:
132108 return Value::TIMESTAMPTZ(timestamp_tz_t(timestamp_t::ninfinity()));
132109 case LogicalTypeId::FLOAT:
132110 return Value::FLOAT(-std::numeric_limits<float>::infinity());
132111 case LogicalTypeId::DOUBLE:
132112 return Value::DOUBLE(-std::numeric_limits<double>::infinity());
132113 default:
132114 throw InvalidTypeException(type, "NegativeInfinity requires numeric type");
132115 }
132116}

◆ Infinity()

Value duckdb::Value::Infinity ( const LogicalType & type)
static

Create the positive infinite value of a given type (numeric only).

132072 {
132073 switch (type.id()) {
132074 case LogicalTypeId::DATE:
132075 return Value::DATE(date_t::infinity());
132076 case LogicalTypeId::TIMESTAMP:
132077 return Value::TIMESTAMP(timestamp_t::infinity());
132078 case LogicalTypeId::TIMESTAMP_SEC:
132079 return Value::TIMESTAMPSEC(timestamp_sec_t(timestamp_t::infinity().value));
132080 case LogicalTypeId::TIMESTAMP_MS:
132081 return Value::TIMESTAMPMS(timestamp_ms_t(timestamp_t::infinity().value));
132083 return Value::TIMESTAMPNS(timestamp_ns_t(timestamp_t::infinity().value));
132084 case LogicalTypeId::TIMESTAMP_TZ:
132085 return Value::TIMESTAMPTZ(timestamp_tz_t(timestamp_t::infinity()));
132086 case LogicalTypeId::FLOAT:
132087 return Value::FLOAT(std::numeric_limits<float>::infinity());
132088 case LogicalTypeId::DOUBLE:
132089 return Value::DOUBLE(std::numeric_limits<double>::infinity());
132090 default:
132091 throw InvalidTypeException(type, "Infinity requires numeric type");
132092 }
132093}

◆ Numeric() [1/3]

Value duckdb::Value::Numeric ( const LogicalType & type,
int64_t value )
static

Create a Numeric value of the specified type with the specified value.

133053 {
133054 switch (type.id()) {
133055 case LogicalTypeId::BOOLEAN:
133056 D_ASSERT(value == 0 || value == 1);
133057 return Value::BOOLEAN(value ? true : false);
133058 case LogicalTypeId::TINYINT:
133059 D_ASSERT(value >= NumericLimits<int8_t>::Minimum() && value <= NumericLimits<int8_t>::Maximum());
133060 return Value::TINYINT((int8_t)value);
133061 case LogicalTypeId::SMALLINT:
133062 D_ASSERT(value >= NumericLimits<int16_t>::Minimum() && value <= NumericLimits<int16_t>::Maximum());
133063 return Value::SMALLINT((int16_t)value);
133064 case LogicalTypeId::INTEGER:
133065 D_ASSERT(value >= NumericLimits<int32_t>::Minimum() && value <= NumericLimits<int32_t>::Maximum());
133066 return Value::INTEGER((int32_t)value);
133067 case LogicalTypeId::BIGINT:
133068 return Value::BIGINT(value);
133069 case LogicalTypeId::UTINYINT:
133070 D_ASSERT(value >= NumericLimits<uint8_t>::Minimum() && value <= NumericLimits<uint8_t>::Maximum());
133071 return Value::UTINYINT((uint8_t)value);
133072 case LogicalTypeId::USMALLINT:
133073 D_ASSERT(value >= NumericLimits<uint16_t>::Minimum() && value <= NumericLimits<uint16_t>::Maximum());
133074 return Value::USMALLINT((uint16_t)value);
133075 case LogicalTypeId::UINTEGER:
133076 D_ASSERT(value >= NumericLimits<uint32_t>::Minimum() && value <= NumericLimits<uint32_t>::Maximum());
133077 return Value::UINTEGER((uint32_t)value);
133078 case LogicalTypeId::UBIGINT:
133079 D_ASSERT(value >= 0);
133080 return Value::UBIGINT(NumericCast<uint64_t>(value));
133081 case LogicalTypeId::HUGEINT:
133082 return Value::HUGEINT(value);
133083 case LogicalTypeId::UHUGEINT:
133084 return Value::UHUGEINT(NumericCast<uint64_t>(value));
133085 case LogicalTypeId::DECIMAL:
133086 return Value::DECIMAL(value, DecimalType::GetWidth(type), DecimalType::GetScale(type));
133087 case LogicalTypeId::FLOAT:
133088 return Value((float)value);
133089 case LogicalTypeId::DOUBLE:
133090 return Value((double)value);
133091 case LogicalTypeId::POINTER:
133092 return Value::POINTER(NumericCast<uintptr_t>(value));
133093 case LogicalTypeId::DATE:
133094 D_ASSERT(value >= NumericLimits<int32_t>::Minimum() && value <= NumericLimits<int32_t>::Maximum());
133095 return Value::DATE(date_t(NumericCast<int32_t>(value)));
133096 case LogicalTypeId::TIME:
133097 return Value::TIME(dtime_t(value));
133098 case LogicalTypeId::TIME_NS:
133099 return Value::TIME_NS(dtime_ns_t(value));
133100 case LogicalTypeId::TIMESTAMP:
133101 return Value::TIMESTAMP(timestamp_t(value));
133102 case LogicalTypeId::TIMESTAMP_SEC:
133103 return Value::TIMESTAMPSEC(timestamp_sec_t(value));
133104 case LogicalTypeId::TIMESTAMP_MS:
133105 return Value::TIMESTAMPMS(timestamp_ms_t(value));
133107 return Value::TIMESTAMPNS(timestamp_ns_t(value));
133108 case LogicalTypeId::TIMESTAMP_TZ:
133109 return Value::TIMESTAMPTZ(timestamp_tz_t(value));
133110 case LogicalTypeId::ENUM:
133111 return Value::ENUM(NumericCast<uint64_t>(value), type);
133112 default:
133113 throw InvalidTypeException(type, "Numeric requires numeric type");
133114 }
133115}
static DUCKDB_API Value POINTER(uintptr_t value)
Create a pointer Value from a specified value.
Definition duckdb.cpp:132331

◆ Numeric() [2/3]

Value duckdb::Value::Numeric ( const LogicalType & type,
hugeint_t value )
static
133117 {
133118#ifdef DEBUG
133119 // perform a throwing cast to verify that the type fits
133120 Value::HUGEINT(value).DefaultCastAs(type);
133121#endif
133122 switch (type.id()) {
133123 case LogicalTypeId::HUGEINT:
133124 return Value::HUGEINT(value);
133125 case LogicalTypeId::UBIGINT:
133126 return Value::UBIGINT(Hugeint::Cast<uint64_t>(value));
133127 default:
133128 return Value::Numeric(type, Hugeint::Cast<int64_t>(value));
133129 }
133130}
static DUCKDB_API Value Numeric(const LogicalType &type, int64_t value)
Create a Numeric value of the specified type with the specified value.
Definition duckdb.cpp:133053

◆ Numeric() [3/3]

Value duckdb::Value::Numeric ( const LogicalType & type,
uhugeint_t value )
static
133132 {
133133#ifdef DEBUG
133134 // perform a throwing cast to verify that the type fits
133135 Value::UHUGEINT(value).DefaultCastAs(type);
133136#endif
133137 switch (type.id()) {
133138 case LogicalTypeId::UHUGEINT:
133139 return Value::UHUGEINT(value);
133140 case LogicalTypeId::UBIGINT:
133141 return Value::UBIGINT(Uhugeint::Cast<uint64_t>(value));
133142 default:
133143 return Value::Numeric(type, Uhugeint::Cast<int64_t>(value));
133144 }
133145}

◆ BOOLEAN()

Value duckdb::Value::BOOLEAN ( bool value)
static

Create a boolean Value from a specified value.

132118 {
132119 Value result(LogicalType::BOOLEAN);
132120 result.value_.boolean = value;
132121 result.is_null = false;
132122 return result;
132123}
DUCKDB_API Value(LogicalType type=LogicalType::SQLNULL)
Create an empty NULL value of the specified type.
Definition duckdb.cpp:131807
Here is the caller graph for this function:

◆ TINYINT()

Create a tinyint Value from a specified value.

132125 {
132126 Value result(LogicalType::TINYINT);
132127 result.value_.tinyint = value;
132128 result.is_null = false;
132129 return result;
132130}
Here is the caller graph for this function:

◆ SMALLINT()

Create a smallint Value from a specified value.

132132 {
132133 Value result(LogicalType::SMALLINT);
132134 result.value_.smallint = value;
132135 result.is_null = false;
132136 return result;
132137}
Here is the caller graph for this function:

◆ INTEGER()

Create an integer Value from a specified value.

132139 {
132140 Value result(LogicalType::INTEGER);
132141 result.value_.integer = value;
132142 result.is_null = false;
132143 return result;
132144}
Here is the caller graph for this function:

◆ BIGINT()

Create a bigint Value from a specified value.

132146 {
132147 Value result(LogicalType::BIGINT);
132148 result.value_.bigint = value;
132149 result.is_null = false;
132150 return result;
132151}
Here is the caller graph for this function:

◆ UTINYINT()

Create an unsigned tinyint Value from a specified value.

132181 {
132182 Value result(LogicalType::UTINYINT);
132183 result.value_.utinyint = value;
132184 result.is_null = false;
132185 return result;
132186}
Here is the caller graph for this function:

◆ USMALLINT()

Create an unsigned smallint Value from a specified value.

132188 {
132189 Value result(LogicalType::USMALLINT);
132190 result.value_.usmallint = value;
132191 result.is_null = false;
132192 return result;
132193}
Here is the caller graph for this function:

◆ UINTEGER()

Create an unsigned integer Value from a specified value.

132195 {
132196 Value result(LogicalType::UINTEGER);
132197 result.value_.uinteger = value;
132198 result.is_null = false;
132199 return result;
132200}
Here is the caller graph for this function:

◆ UBIGINT()

Create an unsigned bigint Value from a specified value.

132202 {
132203 Value result(LogicalType::UBIGINT);
132204 result.value_.ubigint = value;
132205 result.is_null = false;
132206 return result;
132207}
Here is the caller graph for this function:

◆ HUGEINT()

Create a hugeint Value from a specified value.

132153 {
132154 Value result(LogicalType::HUGEINT);
132155 result.value_.hugeint = value;
132156 result.is_null = false;
132157 return result;
132158}
Here is the caller graph for this function:

◆ UHUGEINT()

Create a uhugeint Value from a specified value.

132160 {
132161 Value result(LogicalType::UHUGEINT);
132162 result.value_.uhugeint = value;
132163 result.is_null = false;
132164 return result;
132165}
Here is the caller graph for this function:

◆ UUID() [1/2]

Value duckdb::Value::UUID ( const string & value)
static

Create a uuid Value from a specified value.

132174 {
132175 Value result(LogicalType::UUID);
132176 result.value_.hugeint = UUID::FromString(value);
132177 result.is_null = false;
132178 return result;
132179}
static bool FromString(const string &str, hugeint_t &result, bool strict=false)
Convert a uuid string to a hugeint object.
Definition duckdb.cpp:130879

◆ UUID() [2/2]

Create a uuid Value from a specified value.

132167 {
132168 Value result(LogicalType::UUID);
132169 result.value_.hugeint = value;
132170 result.is_null = false;
132171 return result;
132172}

◆ HASH()

Value duckdb::Value::HASH ( hash_t value)
static

Create a hash Value from a specified value.

132324 {
132325 Value result(LogicalType::HASH);
132326 result.value_.hash = value;
132327 result.is_null = false;
132328 return result;
132329}

◆ POINTER()

Value duckdb::Value::POINTER ( uintptr_t value)
static

Create a pointer Value from a specified value.

132331 {
132332 Value result(LogicalType::POINTER);
132333 result.value_.pointer = value;
132334 result.is_null = false;
132335 return result;
132336}

◆ DATE() [1/2]

Create a date Value from a specified date.

132338 {
132339 Value result(LogicalType::DATE);
132340 result.value_.date = value;
132341 result.is_null = false;
132342 return result;
132343}
Here is the caller graph for this function:

◆ DATE() [2/2]

Value duckdb::Value::DATE ( int32_t year,
int32_t month,
int32_t day )
static

Create a date Value from a specified date.

132345 {
132346 return Value::DATE(Date::FromDate(year, month, day));
132347}

◆ TIME() [1/2]

Create a time Value from a specified time.

132349 {
132350 Value result(LogicalType::TIME);
132351 result.value_.time = value;
132352 result.is_null = false;
132353 return result;
132354}
Here is the caller graph for this function:

◆ TIME() [2/2]

Value duckdb::Value::TIME ( int32_t hour,
int32_t min,
int32_t sec,
int32_t micros )
static

Create a time Value from a specified time.

132370 {
132371 return Value::TIME(Time::FromTime(hour, min, sec, micros));
132372}
static softfloat min()

◆ TIME_NS()

Value duckdb::Value::TIME_NS ( dtime_ns_t time)
static
132356 {
132357 Value result(LogicalType::TIME_NS);
132358 result.value_.time_ns = value;
132359 result.is_null = false;
132360 return result;
132361}

◆ TIMETZ()

Value duckdb::Value::TIMETZ ( dtime_tz_t time)
static
132363 {
132364 Value result(LogicalType::TIME_TZ);
132365 result.value_.timetz = value;
132366 result.is_null = false;
132367 return result;
132368}

◆ TIMESTAMP() [1/3]

Value duckdb::Value::TIMESTAMP ( date_t date,
dtime_t time )
static

Create a timestamp Value from a specified date/time combination.

132409 {
132410 return Value::TIMESTAMP(Timestamp::FromDatetime(date, time));
132411}
Here is the caller graph for this function:

◆ TIMESTAMP() [2/3]

Create a timestamp Value from a specified value.

132374 {
132375 Value result(LogicalType::TIMESTAMP);
132376 result.value_.timestamp = value;
132377 result.is_null = false;
132378 return result;
132379}

◆ TIMESTAMP() [3/3]

Value duckdb::Value::TIMESTAMP ( int32_t year,
int32_t month,
int32_t day,
int32_t hour,
int32_t min,
int32_t sec,
int32_t micros )
static

Create a timestamp Value from a specified timestamp in separate values.

132414 {
132415 auto date = Date::FromDate(year, month, day);
132416 auto time = Time::FromTime(hour, min, sec, micros);
132417 auto val = Value::TIMESTAMP(date, time);
132418 val.type_ = LogicalType::TIMESTAMP;
132419 return val;
132420}

◆ TIMESTAMPSEC()

Create a timestamp_s Value from a specified value.

132381 {
132382 Value result(LogicalType::TIMESTAMP_S);
132383 result.value_.timestamp_s = timestamp;
132384 result.is_null = false;
132385 return result;
132386}
cv::GOpaque< int64_t > timestamp(G g)

◆ TIMESTAMPMS()

Create a timestamp_ms Value from a specified value.

132388 {
132389 Value result(LogicalType::TIMESTAMP_MS);
132390 result.value_.timestamp_ms = timestamp;
132391 result.is_null = false;
132392 return result;
132393}

◆ TIMESTAMPNS()

Create a timestamp_ns Value from a specified value.

132395 {
132396 Value result(LogicalType::TIMESTAMP_NS);
132397 result.value_.timestamp_ns = timestamp;
132398 result.is_null = false;
132399 return result;
132400}

◆ TIMESTAMPTZ()

Value duckdb::Value::TIMESTAMPTZ ( timestamp_tz_t timestamp)
static

Create a timestamp_tz Value from a specified value.

132402 {
132403 Value result(LogicalType::TIMESTAMP_TZ);
132404 result.value_.timestamp_tz = value;
132405 result.is_null = false;
132406 return result;
132407}
Here is the caller graph for this function:

◆ INTERVAL() [1/2]

Value duckdb::Value::INTERVAL ( int32_t months,
int32_t days,
int64_t micros )
static
132689 {
132690 Value result(LogicalType::INTERVAL);
132691 result.is_null = false;
132692 result.value_.interval.months = months;
132693 result.value_.interval.days = days;
132694 result.value_.interval.micros = micros;
132695 return result;
132696}

◆ INTERVAL() [2/2]

Value duckdb::Value::INTERVAL ( interval_t interval)
static
132698 {
132699 return Value::INTERVAL(interval.months, interval.days, interval.micros);
132700}

◆ ENUM()

Value duckdb::Value::ENUM ( uint64_t value,
const LogicalType & original_type )
static
132669 {
132670 D_ASSERT(original_type.id() == LogicalTypeId::ENUM);
132671 Value result(original_type);
132672 switch (original_type.InternalType()) {
132673 case PhysicalType::UINT8:
132674 result.value_.utinyint = NumericCast<uint8_t>(value);
132675 break;
132677 result.value_.usmallint = NumericCast<uint16_t>(value);
132678 break;
132680 result.value_.uinteger = NumericCast<uint32_t>(value);
132681 break;
132682 default:
132683 throw InternalException("Incorrect Physical Type for ENUM");
132684 }
132685 result.is_null = false;
132686 return result;
132687}
@ UINT32
Unsigned 32-bit little-endian integer.
Definition duckdb.hpp:2758
@ UINT16
Unsigned 16-bit little-endian integer.
Definition duckdb.hpp:2752
@ UINT8
Unsigned 8-bit little-endian integer.
Definition duckdb.hpp:2746

◆ DECIMAL() [1/4]

Value duckdb::Value::DECIMAL ( int16_t value,
uint8_t width,
uint8_t scale )
static
132272 {
132273 return Value::DECIMAL(int64_t(value), width, scale);
132274}

◆ DECIMAL() [2/4]

Value duckdb::Value::DECIMAL ( int32_t value,
uint8_t width,
uint8_t scale )
static
132276 {
132277 return Value::DECIMAL(int64_t(value), width, scale);
132278}

◆ DECIMAL() [3/4]

Value duckdb::Value::DECIMAL ( int64_t value,
uint8_t width,
uint8_t scale )
static
132280 {
132281 auto decimal_type = LogicalType::DECIMAL(width, scale);
132282 Value result(decimal_type);
132283 switch (decimal_type.InternalType()) {
132284 case PhysicalType::INT16:
132285 result.value_.smallint = NumericCast<int16_t>(value);
132286 break;
132287 case PhysicalType::INT32:
132288 result.value_.integer = NumericCast<int32_t>(value);
132289 break;
132290 case PhysicalType::INT64:
132291 result.value_.bigint = value;
132292 break;
132293 default:
132294 result.value_.hugeint = value;
132295 break;
132296 }
132297 result.type_.Verify();
132298 result.is_null = false;
132299 return result;
132300}

◆ DECIMAL() [4/4]

Value duckdb::Value::DECIMAL ( hugeint_t value,
uint8_t width,
uint8_t scale )
static
132302 {
132303 D_ASSERT(width >= Decimal::MAX_WIDTH_INT64 && width <= Decimal::MAX_WIDTH_INT128);
132304 Value result(LogicalType::DECIMAL(width, scale));
132305 result.value_.hugeint = value;
132306 result.is_null = false;
132307 return result;
132308}

◆ FLOAT()

Value duckdb::Value::FLOAT ( float value)
static

Create a float Value from a specified value.

132310 {
132311 Value result(LogicalType::FLOAT);
132312 result.value_.float_ = value;
132313 result.is_null = false;
132314 return result;
132315}
Here is the caller graph for this function:

◆ DOUBLE()

Value duckdb::Value::DOUBLE ( double value)
static

Create a double Value from a specified value.

132317 {
132318 Value result(LogicalType::DOUBLE);
132319 result.value_.double_ = value;
132320 result.is_null = false;
132321 return result;
132322}
Here is the caller graph for this function:

◆ STRUCT() [1/2]

Value duckdb::Value::STRUCT ( child_list_t< Value > values)
static

Create a struct value with given list of entries.

132434 {
132435 child_list_t<LogicalType> child_types;
132436 vector<Value> struct_values;
132437 for (auto &child : values) {
132438 child_types.push_back(make_pair(std::move(child.first), child.second.type()));
132439 struct_values.push_back(std::move(child.second));
132440 }
132441 return Value::STRUCT(LogicalType::STRUCT(child_types), std::move(struct_values));
132442}
static DUCKDB_API Value STRUCT(child_list_t< Value > values)
Create a struct value with given list of entries.
Definition duckdb.cpp:132434

◆ STRUCT() [2/2]

Value duckdb::Value::STRUCT ( const LogicalType & type,
vector< Value > struct_values )
static
132422 {
132423 Value result;
132424 auto child_types = StructType::GetChildTypes(type);
132425 for (size_t i = 0; i < struct_values.size(); i++) {
132426 struct_values[i] = struct_values[i].DefaultCastAs(child_types[i].second);
132427 }
132428 result.value_info_ = make_shared_ptr<NestedValueInfo>(std::move(struct_values));
132429 result.type_ = type;
132430 result.is_null = false;
132431 return result;
132432}

◆ VARIANT()

Value duckdb::Value::VARIANT ( vector< Value > children)
static

Create a variant value with given list of internal variant data (keys/children/values/data).

132444 {
132445 D_ASSERT(val.size() == 4);
132446 D_ASSERT(val[0].type().id() == LogicalTypeId::LIST);
132447 D_ASSERT(val[1].type().id() == LogicalTypeId::LIST);
132448 D_ASSERT(val[2].type().id() == LogicalTypeId::LIST);
132449 D_ASSERT(val[3].type().id() == LogicalTypeId::BLOB);
132450 return Value::STRUCT(LogicalType::VARIANT(), std::move(val));
132451}
static DUCKDB_API LogicalType VARIANT()
Definition duckdb.cpp:140950

◆ LIST() [1/2]

Value duckdb::Value::LIST ( const LogicalType & child_type,
vector< Value > values )
static

Create a list value with the given entries.

132555 {
132556 Value result;
132557 result.type_ = LogicalType::LIST(child_type);
132558 result.is_null = false;
132559 for (auto &val : values) {
132560 val = val.DefaultCastAs(child_type);
132561 }
132562 result.value_info_ = make_shared_ptr<NestedValueInfo>(std::move(values));
132563 return result;
132564}

◆ LIST() [2/2]

Value duckdb::Value::LIST ( vector< Value > values)
static

Create a list value with the given entries The type of the first value determines the list type. The list cannot be empty.

132566 {
132567 if (values.empty()) {
132568 throw InternalException(
132569 "Value::LIST(values) cannot be used to make an empty list - use Value::LIST(type, values) instead");
132570 }
132571 auto &type = values[0].type();
132572 return Value::LIST(type, std::move(values));
132573}
static DUCKDB_API Value LIST(const LogicalType &child_type, vector< Value > values)
Create a list value with the given entries.
Definition duckdb.cpp:132555

◆ ARRAY()

Value duckdb::Value::ARRAY ( const LogicalType & type,
vector< Value > values )
static
132575 {
132576 Value result;
132577 result.type_ = LogicalType::ARRAY(child_type, values.size());
132578 for (auto &val : values) {
132579 val = val.DefaultCastAs(child_type);
132580 }
132581 result.value_info_ = make_shared_ptr<NestedValueInfo>(std::move(values));
132582 result.is_null = false;
132583 return result;
132584}

◆ MAP() [1/3]

Value duckdb::Value::MAP ( const LogicalType & child_type,
vector< Value > values )
static

Create a map value with the given entries.

132466 { // NOLINT
132467 vector<Value> map_keys;
132468 vector<Value> map_values;
132469 value_set_t unique_keys;
132470
132471 for (auto &val : values) {
132472 D_ASSERT(val.type().InternalType() == PhysicalType::STRUCT);
132473 auto &children = StructValue::GetChildren(val);
132474 D_ASSERT(children.size() == 2);
132475
132476 auto &key = children[0];
132477 MapKeyCheck(unique_keys, key);
132478
132479 map_keys.push_back(key);
132480 map_values.push_back(children[1]);
132481 }
132482
132483 auto &key_type = StructType::GetChildType(child_type, 0);
132484 auto &value_type = StructType::GetChildType(child_type, 1);
132485 return Value::MAP(key_type, value_type, std::move(map_keys), std::move(map_values));
132486}
static DUCKDB_API Value MAP(const LogicalType &child_type, vector< Value > values)
Create a map value with the given entries.
Definition duckdb.cpp:132466
R value_type
@ STRUCT
Struct of logical types.
Definition duckdb.hpp:2816

◆ MAP() [2/3]

Value duckdb::Value::MAP ( const LogicalType & key_type,
const LogicalType & value_type,
vector< Value > keys,
vector< Value > values )
static

Create a map value with the given entries.

132488 {
132489 D_ASSERT(keys.size() == values.size());
132490 Value result;
132491
132492 result.type_ = LogicalType::MAP(key_type, value_type);
132493 result.is_null = false;
132494 value_set_t unique_keys;
132495
132496 for (idx_t i = 0; i < keys.size(); i++) {
132497 child_list_t<LogicalType> struct_types;
132498 vector<Value> new_children;
132499 struct_types.reserve(2);
132500 new_children.reserve(2);
132501
132502 struct_types.push_back(make_pair("key", key_type));
132503 struct_types.push_back(make_pair("value", value_type));
132504
132505 auto key = keys[i].DefaultCastAs(key_type);
132506 MapKeyCheck(unique_keys, key);
132507
132508 new_children.push_back(key);
132509 new_children.push_back(values[i]);
132510 auto struct_type = LogicalType::STRUCT(std::move(struct_types));
132511 values[i] = Value::STRUCT(struct_type, std::move(new_children));
132512 }
132513
132514 result.value_info_ = make_shared_ptr<NestedValueInfo>(std::move(values));
132515 return result;
132516}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ MAP() [3/3]

Value duckdb::Value::MAP ( const InsertionOrderPreservingMap< string > & kv_pairs)
static

Create a map value from a set of key-value pairs.

132518 {
132519 Value result;
132520 result.type_ = LogicalType::MAP(LogicalType::VARCHAR, LogicalType::VARCHAR);
132521 result.is_null = false;
132522 vector<Value> pairs;
132523 for (auto &kv : kv_pairs) {
132524 pairs.push_back(Value::STRUCT({{"key", Value(kv.first)}, {"value", Value(kv.second)}}));
132525 }
132526 result.value_info_ = make_shared_ptr<NestedValueInfo>(std::move(pairs));
132527 return result;
132528}

◆ UNION()

Value duckdb::Value::UNION ( child_list_t< LogicalType > members,
uint8_t tag,
Value value )
static

Create a union value from a selected value and a tag from a set of alternatives.

132530 {
132531 D_ASSERT(!members.empty());
132532 D_ASSERT(members.size() <= UnionType::MAX_UNION_MEMBERS);
132533 D_ASSERT(members.size() > tag);
132534
132535 D_ASSERT(value.type() == members[tag].second);
132536
132537 Value result;
132538 result.is_null = false;
132539 // add the tag to the front of the struct
132540 vector<Value> union_values;
132541 union_values.emplace_back(Value::UTINYINT(tag));
132542 for (idx_t i = 0; i < members.size(); i++) {
132543 if (i != tag) {
132544 union_values.emplace_back(members[i].second);
132545 } else {
132546 union_values.emplace_back(nullptr);
132547 }
132548 }
132549 union_values[tag + 1] = std::move(value);
132550 result.value_info_ = make_shared_ptr<NestedValueInfo>(std::move(union_values));
132551 result.type_ = LogicalType::UNION(std::move(members));
132552 return result;
132553}

◆ BLOB() [1/2]

Value duckdb::Value::BLOB ( const_data_ptr_t data,
idx_t len )
static

Create a blob Value from a data pointer and a length: no bytes are interpreted.

132586 {
132587 Value result(LogicalType::BLOB);
132588 result.is_null = false;
132589 result.value_info_ = make_shared_ptr<StringValueInfo>(string(const_char_ptr_cast(data), len));
132590 return result;
132591}
Here is the caller graph for this function:

◆ BLOB() [2/2]

Value duckdb::Value::BLOB ( const string & data)
static

Creates a blob by casting a specified string to a blob (i.e. interpreting \x characters).

132641 {
132642 Value result(LogicalType::BLOB);
132643 result.is_null = false;
132644 result.value_info_ = make_shared_ptr<StringValueInfo>(Blob::ToBlob(string_t(data)));
132645 return result;
132646}
static DUCKDB_API void ToBlob(string_t str, data_ptr_t output)
Convert a string to a blob. This function should ONLY be called after calling GetBlobSize,...
Definition duckdb.cpp:113232

◆ BLOB_RAW()

Value duckdb::Value::BLOB_RAW ( const string & data)
inlinestatic
5809 { // NOLINT
5810 return Value::BLOB(const_data_ptr_cast(data.c_str()), data.size());
5811 }
static DUCKDB_API Value BLOB(const_data_ptr_t data, idx_t len)
Create a blob Value from a data pointer and a length: no bytes are interpreted.
Definition duckdb.cpp:132586

◆ BIT() [1/2]

Value duckdb::Value::BIT ( const_data_ptr_t data,
idx_t len )
static

Creates a bitstring by casting a specified string to a bitstring.

132655 {
132656 Value result(LogicalType::BIT);
132657 result.is_null = false;
132658 result.value_info_ = make_shared_ptr<StringValueInfo>(string(const_char_ptr_cast(data), len));
132659 return result;
132660}

◆ BIT() [2/2]

Value duckdb::Value::BIT ( const string & data)
static
132662 {
132663 Value result(LogicalType::BIT);
132664 result.is_null = false;
132665 result.value_info_ = make_shared_ptr<StringValueInfo>(Bit::ToBit(string_t(data)));
132666 return result;
132667}
static DUCKDB_API void ToBit(string_t str, bitstring_t &output)
Definition duckdb.cpp:112794

◆ BIGNUM() [1/2]

Value duckdb::Value::BIGNUM ( const_data_ptr_t data,
idx_t len )
static
132593 {
132594 return BIGNUM(string(const_char_ptr_cast(data), len));
132595}

◆ BIGNUM() [2/2]

Value duckdb::Value::BIGNUM ( const string & data)
static
132597 {
132598 Value result(LogicalType::BIGNUM);
132599 result.is_null = false;
132600 result.value_info_ = make_shared_ptr<StringValueInfo>(data);
132601 return result;
132602}

◆ GEOMETRY() [1/2]

Value duckdb::Value::GEOMETRY ( const_data_ptr_t data,
idx_t len )
static
132612 {
132613 Value result;
132614 result.type_ = LogicalType::GEOMETRY(); // construct type explicitly so that we get the ExtraTypeInfo
132615 result.is_null = false;
132616 result.value_info_ = make_shared_ptr<StringValueInfo>(string(const_char_ptr_cast(data), len));
132617 return result;
132618}

◆ GEOMETRY() [2/2]

Value duckdb::Value::GEOMETRY ( const_data_ptr_t data,
idx_t len,
const CoordinateReferenceSystem & crs )
static
132604 {
132605 Value result;
132606 result.type_ = LogicalType::GEOMETRY(crs); // construct type explicitly so that we get the ExtraTypeInfo
132607 result.is_null = false;
132608 result.value_info_ = make_shared_ptr<StringValueInfo>(string(const_char_ptr_cast(data), len));
132609 return result;
132610}

◆ TYPE() [1/2]

Value duckdb::Value::TYPE ( const LogicalType & type)
static
132620 {
132621 MemoryStream stream;
132622 SerializationOptions options;
132623 options.serialization_compatibility = SerializationCompatibility::Latest();
132624 BinarySerializer::Serialize(type, stream, options);
132625 auto data_ptr = const_char_ptr_cast(stream.GetData());
132626 auto data_len = stream.GetPosition();
132627
132628 Value result(LogicalType::TYPE());
132629 result.is_null = false;
132630 result.value_info_ = make_shared_ptr<StringValueInfo>(string(data_ptr, data_len));
132631 return result;
132632}

◆ TYPE() [2/2]

Value duckdb::Value::TYPE ( const string_t & serialized_type)
static
132634 {
132635 Value result(LogicalType::TYPE());
132636 result.is_null = false;
132637 result.value_info_ = make_shared_ptr<StringValueInfo>(serialized_type.GetString());
132638 return result;
132639}

◆ AGGREGATE_STATE()

Value duckdb::Value::AGGREGATE_STATE ( const LogicalType & type,
const_data_ptr_t data,
idx_t len )
static

Creates an aggregate state.

132648 { // NOLINT
132649 Value result(type);
132650 result.is_null = false;
132651 result.value_info_ = make_shared_ptr<StringValueInfo>(string(const_char_ptr_cast(data), len));
132652 return result;
132653}

◆ GetValue() [1/25]

template<>
bool duckdb::Value::GetValue ( ) const
132918 {
132919 return GetValueInternal<int8_t>();
132920}

◆ GetValue() [2/25]

template<>
int8_t duckdb::Value::GetValue ( ) const
132922 {
132923 return GetValueInternal<int8_t>();
132924}

◆ GetValue() [3/25]

template<>
int16_t duckdb::Value::GetValue ( ) const
132926 {
132927 return GetValueInternal<int16_t>();
132928}

◆ GetValue() [4/25]

template<>
int32_t duckdb::Value::GetValue ( ) const
132930 {
132931 if (type_.id() == LogicalTypeId::DATE) {
132932 return value_.integer;
132933 }
132934 return GetValueInternal<int32_t>();
132935}

◆ GetValue() [5/25]

template<>
int64_t duckdb::Value::GetValue ( ) const
132937 {
132938 if (IsNull()) {
132939 throw InternalException("Calling GetValue on a value that is NULL");
132940 }
132941 switch (type_.id()) {
132942 case LogicalTypeId::TIMESTAMP:
132943 return value_.timestamp.value;
132944 case LogicalTypeId::TIMESTAMP_SEC:
132945 return value_.timestamp_s.value;
132946 case LogicalTypeId::TIMESTAMP_MS:
132947 return value_.timestamp_ms.value;
132949 return value_.timestamp_ns.value;
132950 case LogicalTypeId::TIMESTAMP_TZ:
132951 return value_.timestamp_tz.value;
132952 case LogicalTypeId::TIME:
132953 return value_.bigint;
132954 default:
132955 return GetValueInternal<int64_t>();
132956 }
132957}

◆ GetValue() [6/25]

template<>
hugeint_t duckdb::Value::GetValue ( ) const
132959 {
132960 return GetValueInternal<hugeint_t>();
132961}

◆ GetValue() [7/25]

template<>
uint8_t duckdb::Value::GetValue ( ) const
132963 {
132964 return GetValueInternal<uint8_t>();
132965}

◆ GetValue() [8/25]

template<>
uint16_t duckdb::Value::GetValue ( ) const
132967 {
132968 return GetValueInternal<uint16_t>();
132969}

◆ GetValue() [9/25]

template<>
uint32_t duckdb::Value::GetValue ( ) const
132971 {
132972 return GetValueInternal<uint32_t>();
132973}

◆ GetValue() [10/25]

template<>
uint64_t duckdb::Value::GetValue ( ) const
132975 {
132976 return GetValueInternal<uint64_t>();
132977}

◆ GetValue() [11/25]

template<>
uhugeint_t duckdb::Value::GetValue ( ) const
132979 {
132980 return GetValueInternal<uhugeint_t>();
132981}

◆ GetValue() [12/25]

template<>
string duckdb::Value::GetValue ( ) const
132983 {
132984 return ToString();
132985}
DUCKDB_API string ToString() const
Convert this value to a string.
Definition duckdb.cpp:133318

◆ GetValue() [13/25]

template<>
float duckdb::Value::GetValue ( ) const
132987 {
132988 return GetValueInternal<float>();
132989}

◆ GetValue() [14/25]

template<>
double duckdb::Value::GetValue ( ) const
132991 {
132992 return GetValueInternal<double>();
132993}

◆ GetValue() [15/25]

template<>
date_t duckdb::Value::GetValue ( ) const
132995 {
132996 return GetValueInternal<date_t>();
132997}

◆ GetValue() [16/25]

template<>
dtime_t duckdb::Value::GetValue ( ) const
132999 {
133000 return GetValueInternal<dtime_t>();
133001}

◆ GetValue() [17/25]

template<>
dtime_ns_t duckdb::Value::GetValue ( ) const
133004 {
133005 return GetValueInternal<dtime_ns_t>();
133006}

◆ GetValue() [18/25]

template<>
timestamp_t duckdb::Value::GetValue ( ) const
133009 {
133010 return GetValueInternal<timestamp_t>();
133011}

◆ GetValue() [19/25]

template<>
timestamp_sec_t duckdb::Value::GetValue ( ) const
133014 {
133015 return GetValueInternal<timestamp_sec_t>();
133016}

◆ GetValue() [20/25]

template<>
timestamp_ms_t duckdb::Value::GetValue ( ) const
133019 {
133020 return GetValueInternal<timestamp_ms_t>();
133021}

◆ GetValue() [21/25]

template<>
timestamp_ns_t duckdb::Value::GetValue ( ) const
133024 {
133025 return GetValueInternal<timestamp_ns_t>();
133026}

◆ GetValue() [22/25]

template<>
timestamp_tz_t duckdb::Value::GetValue ( ) const
133029 {
133030 return GetValueInternal<timestamp_tz_t>();
133031}

◆ GetValue() [23/25]

template<>
dtime_tz_t duckdb::Value::GetValue ( ) const
133034 {
133035 return GetValueInternal<dtime_tz_t>();
133036}

◆ GetValue() [24/25]

template<>
DUCKDB_API interval_t duckdb::Value::GetValue ( ) const
133039 {
133040 return GetValueInternal<interval_t>();
133041}

◆ GetValue() [25/25]

template<>
DUCKDB_API Value duckdb::Value::GetValue ( ) const
133044 {
133045 return Value(*this);
133046}

◆ CreateValue() [1/28]

template<class T>
Value duckdb::Value::CreateValue ( T value)
inlinestatic
5832 {
5833 static_assert(AlwaysFalse<T>::VALUE, "No specialization exists for this type");
5834 return Value(nullptr);
5835 }

◆ CreateValue() [2/28]

template<>
Value duckdb::Value::CreateValue ( bool value)
132706 {
132707 return Value::BOOLEAN(value);
132708}

◆ CreateValue() [3/28]

template<>
Value duckdb::Value::CreateValue ( int8_t value)
132711 {
132712 return Value::TINYINT(value);
132713}

◆ CreateValue() [4/28]

template<>
Value duckdb::Value::CreateValue ( int16_t value)
132716 {
132717 return Value::SMALLINT(value);
132718}

◆ CreateValue() [5/28]

template<>
Value duckdb::Value::CreateValue ( int32_t value)
132721 {
132722 return Value::INTEGER(value);
132723}

◆ CreateValue() [6/28]

template<>
Value duckdb::Value::CreateValue ( int64_t value)
132726 {
132727 return Value::BIGINT(value);
132728}

◆ CreateValue() [7/28]

template<>
Value duckdb::Value::CreateValue ( uint8_t value)
132731 {
132732 return Value::UTINYINT(value);
132733}

◆ CreateValue() [8/28]

template<>
Value duckdb::Value::CreateValue ( uint16_t value)
132736 {
132737 return Value::USMALLINT(value);
132738}

◆ CreateValue() [9/28]

template<>
Value duckdb::Value::CreateValue ( uint32_t value)
132741 {
132742 return Value::UINTEGER(value);
132743}

◆ CreateValue() [10/28]

template<>
Value duckdb::Value::CreateValue ( uint64_t value)
132746 {
132747 return Value::UBIGINT(value);
132748}

◆ CreateValue() [11/28]

template<>
Value duckdb::Value::CreateValue ( hugeint_t value)
132751 {
132752 return Value::HUGEINT(value);
132753}

◆ CreateValue() [12/28]

template<>
Value duckdb::Value::CreateValue ( uhugeint_t value)
132756 {
132757 return Value::UHUGEINT(value);
132758}

◆ CreateValue() [13/28]

template<>
Value duckdb::Value::CreateValue ( date_t value)
132761 {
132762 return Value::DATE(value);
132763}

◆ CreateValue() [14/28]

template<>
Value duckdb::Value::CreateValue ( dtime_t value)
132766 {
132767 return Value::TIME(value);
132768}

◆ CreateValue() [15/28]

template<>
Value duckdb::Value::CreateValue ( dtime_ns_t value)
132771 {
132772 return Value::TIME_NS(value);
132773}

◆ CreateValue() [16/28]

template<>
Value duckdb::Value::CreateValue ( dtime_tz_t value)
132776 {
132777 return Value::TIMETZ(value);
132778}

◆ CreateValue() [17/28]

template<>
Value duckdb::Value::CreateValue ( timestamp_t value)
132781 {
132782 return Value::TIMESTAMP(value);
132783}

◆ CreateValue() [18/28]

template<>
Value duckdb::Value::CreateValue ( timestamp_sec_t value)
132786 {
132787 return Value::TIMESTAMPSEC(value);
132788}

◆ CreateValue() [19/28]

template<>
Value duckdb::Value::CreateValue ( timestamp_ms_t value)
132791 {
132792 return Value::TIMESTAMPMS(value);
132793}

◆ CreateValue() [20/28]

template<>
Value duckdb::Value::CreateValue ( timestamp_ns_t value)
132796 {
132797 return Value::TIMESTAMPNS(value);
132798}

◆ CreateValue() [21/28]

template<>
Value duckdb::Value::CreateValue ( timestamp_tz_t value)
132801 {
132802 return Value::TIMESTAMPTZ(value);
132803}

◆ CreateValue() [22/28]

template<>
Value duckdb::Value::CreateValue ( const char * value)
132806 {
132807 return Value(string(value));
132808}

◆ CreateValue() [23/28]

template<>
Value duckdb::Value::CreateValue ( string value)
132811 { // NOLINT: required for templating
132812 return Value::BLOB(value);
132813}
static DUCKDB_API Value BLOB(const_data_ptr_t data, idx_t len)
Create a blob Value from a data pointer and a length: no bytes are interpreted.
Definition duckdb.cpp:132586

◆ CreateValue() [24/28]

template<>
Value duckdb::Value::CreateValue ( string_t value)
132816 {
132817 return Value(value);
132818}

◆ CreateValue() [25/28]

template<>
Value duckdb::Value::CreateValue ( float value)
132821 {
132822 return Value::FLOAT(value);
132823}

◆ CreateValue() [26/28]

template<>
Value duckdb::Value::CreateValue ( double value)
132826 {
132827 return Value::DOUBLE(value);
132828}

◆ CreateValue() [27/28]

template<>
Value duckdb::Value::CreateValue ( interval_t value)
132831 {
132832 return Value::INTERVAL(value);
132833}

◆ CreateValue() [28/28]

template<>
Value duckdb::Value::CreateValue ( Value value)
132836 {
132837 return value;
132838}

◆ GetValueUnsafe() [1/26]

template<>
DUCKDB_API bool duckdb::Value::GetValueUnsafe ( ) const
133151 {
133152 D_ASSERT(type_.InternalType() == PhysicalType::BOOL);
133153 return value_.boolean;
133154}
@ BOOL
Boolean as 8 bit "bool" value.
Definition duckdb.hpp:2743

◆ GetValueUnsafe() [2/26]

template<>
int8_t duckdb::Value::GetValueUnsafe ( ) const
133157 {
133158 D_ASSERT(type_.InternalType() == PhysicalType::INT8 || type_.InternalType() == PhysicalType::BOOL);
133159 return value_.tinyint;
133160}
@ INT8
Signed 8-bit little-endian integer.
Definition duckdb.hpp:2749

◆ GetValueUnsafe() [3/26]

template<>
int16_t duckdb::Value::GetValueUnsafe ( ) const
133163 {
133164 D_ASSERT(type_.InternalType() == PhysicalType::INT16);
133165 return value_.smallint;
133166}

◆ GetValueUnsafe() [4/26]

template<>
int32_t duckdb::Value::GetValueUnsafe ( ) const
133169 {
133170 D_ASSERT(type_.InternalType() == PhysicalType::INT32);
133171 return value_.integer;
133172}

◆ GetValueUnsafe() [5/26]

template<>
int64_t duckdb::Value::GetValueUnsafe ( ) const
133175 {
133176 D_ASSERT(type_.InternalType() == PhysicalType::INT64);
133177 return value_.bigint;
133178}

◆ GetValueUnsafe() [6/26]

template<>
hugeint_t duckdb::Value::GetValueUnsafe ( ) const
133181 {
133182 D_ASSERT(type_.InternalType() == PhysicalType::INT128);
133183 return value_.hugeint;
133184}

◆ GetValueUnsafe() [7/26]

template<>
uint8_t duckdb::Value::GetValueUnsafe ( ) const
133187 {
133188 D_ASSERT(type_.InternalType() == PhysicalType::UINT8);
133189 return value_.utinyint;
133190}

◆ GetValueUnsafe() [8/26]

template<>
uint16_t duckdb::Value::GetValueUnsafe ( ) const
133193 {
133194 D_ASSERT(type_.InternalType() == PhysicalType::UINT16);
133195 return value_.usmallint;
133196}

◆ GetValueUnsafe() [9/26]

template<>
uint32_t duckdb::Value::GetValueUnsafe ( ) const
133199 {
133200 D_ASSERT(type_.InternalType() == PhysicalType::UINT32);
133201 return value_.uinteger;
133202}

◆ GetValueUnsafe() [10/26]

template<>
uint64_t duckdb::Value::GetValueUnsafe ( ) const
133205 {
133206 D_ASSERT(type_.InternalType() == PhysicalType::UINT64);
133207 return value_.ubigint;
133208}
@ UINT64
Unsigned 64-bit little-endian integer.
Definition duckdb.hpp:2764

◆ GetValueUnsafe() [11/26]

template<>
uhugeint_t duckdb::Value::GetValueUnsafe ( ) const
133211 {
133212 D_ASSERT(type_.InternalType() == PhysicalType::UINT128);
133213 return value_.uhugeint;
133214}

◆ GetValueUnsafe() [12/26]

template<>
string duckdb::Value::GetValueUnsafe ( ) const
133217 {
133218 return StringValue::Get(*this);
133219}

◆ GetValueUnsafe() [13/26]

template<>
DUCKDB_API string_t duckdb::Value::GetValueUnsafe ( ) const
133222 {
133223 return string_t(StringValue::Get(*this));
133224}

◆ GetValueUnsafe() [14/26]

template<>
DUCKDB_API bignum_t duckdb::Value::GetValueUnsafe ( ) const
133227 {
133228 return bignum_t(StringValue::Get(*this));
133229}

◆ GetValueUnsafe() [15/26]

template<>
float duckdb::Value::GetValueUnsafe ( ) const
133232 {
133233 D_ASSERT(type_.InternalType() == PhysicalType::FLOAT);
133234 return value_.float_;
133235}
@ FLOAT
4-byte floating point value
Definition duckdb.hpp:2773

◆ GetValueUnsafe() [16/26]

template<>
double duckdb::Value::GetValueUnsafe ( ) const
133238 {
133239 D_ASSERT(type_.InternalType() == PhysicalType::DOUBLE);
133240 return value_.double_;
133241}
@ DOUBLE
8-byte floating point value
Definition duckdb.hpp:2776

◆ GetValueUnsafe() [17/26]

template<>
date_t duckdb::Value::GetValueUnsafe ( ) const
133244 {
133245 D_ASSERT(type_.InternalType() == PhysicalType::INT32);
133246 return value_.date;
133247}

◆ GetValueUnsafe() [18/26]

template<>
dtime_t duckdb::Value::GetValueUnsafe ( ) const
133250 {
133251 D_ASSERT(type_.InternalType() == PhysicalType::INT64);
133252 return value_.time;
133253}

◆ GetValueUnsafe() [19/26]

template<>
dtime_ns_t duckdb::Value::GetValueUnsafe ( ) const
133256 {
133257 D_ASSERT(type_.InternalType() == PhysicalType::INT64);
133258 return value_.time_ns;
133259}

◆ GetValueUnsafe() [20/26]

template<>
dtime_tz_t duckdb::Value::GetValueUnsafe ( ) const
133262 {
133263 D_ASSERT(type_.InternalType() == PhysicalType::INT64);
133264 return value_.timetz;
133265}

◆ GetValueUnsafe() [21/26]

template<>
timestamp_t duckdb::Value::GetValueUnsafe ( ) const
133268 {
133269 D_ASSERT(type_.InternalType() == PhysicalType::INT64);
133270 return value_.timestamp;
133271}

◆ GetValueUnsafe() [22/26]

template<>
timestamp_sec_t duckdb::Value::GetValueUnsafe ( ) const
133274 {
133275 D_ASSERT(type_.InternalType() == PhysicalType::INT64);
133276 return value_.timestamp_s;
133277}

◆ GetValueUnsafe() [23/26]

template<>
timestamp_ms_t duckdb::Value::GetValueUnsafe ( ) const
133280 {
133281 D_ASSERT(type_.InternalType() == PhysicalType::INT64);
133282 return value_.timestamp_ms;
133283}

◆ GetValueUnsafe() [24/26]

template<>
timestamp_ns_t duckdb::Value::GetValueUnsafe ( ) const
133286 {
133287 D_ASSERT(type_.InternalType() == PhysicalType::INT64);
133288 return value_.timestamp_ns;
133289}

◆ GetValueUnsafe() [25/26]

template<>
timestamp_tz_t duckdb::Value::GetValueUnsafe ( ) const
133292 {
133293 D_ASSERT(type_.InternalType() == PhysicalType::INT64);
133294 return value_.timestamp_tz;
133295}

◆ GetValueUnsafe() [26/26]

template<>
interval_t duckdb::Value::GetValueUnsafe ( ) const
133298 {
133299 D_ASSERT(type_.InternalType() == PhysicalType::INTERVAL);
133300 return value_.interval;
133301}
@ INTERVAL
YEAR_MONTH or DAY_TIME interval in SQL style.
Definition duckdb.hpp:2806

◆ Copy()

Value duckdb::Value::Copy ( ) const
inline

Return a copy of this value.

5842 {
5843 return Value(*this);
5844 }

◆ Hash()

hash_t duckdb::Value::Hash ( ) const

Hashes the Value.

133306 {
133307 if (IsNull()) {
133308 return 0;
133309 }
133310 Vector input(*this);
133311 Vector result(LogicalType::HASH, 1);
133312 VectorOperations::Hash(input, result, 1);
133313
133314 auto data = FlatVector::GetData<hash_t>(result);
133315 return data[0];
133316}

◆ ToString()

string duckdb::Value::ToString ( ) const

Convert this value to a string.

133318 {
133319 if (IsNull()) {
133320 return "NULL";
133321 }
133322 return StringValue::Get(DefaultCastAs(LogicalType::VARCHAR));
133323}

◆ ToSQLString()

string duckdb::Value::ToSQLString ( ) const

Convert this value to a SQL-parseable string.

133325 {
133326 if (IsNull()) {
133327 return ToString();
133328 }
133329 switch (type_.id()) {
133330 case LogicalTypeId::UUID:
133331 case LogicalTypeId::DATE:
133332 case LogicalTypeId::TIME:
133333 case LogicalTypeId::TIME_NS:
133334 case LogicalTypeId::TIMESTAMP:
133335 case LogicalTypeId::TIME_TZ:
133336 case LogicalTypeId::TIMESTAMP_TZ:
133337 case LogicalTypeId::TIMESTAMP_SEC:
133338 case LogicalTypeId::TIMESTAMP_MS:
133340 case LogicalTypeId::INTERVAL:
133341 case LogicalTypeId::BLOB:
133342 return "'" + ToString() + "'::" + type_.ToString();
133343 case LogicalTypeId::VARCHAR:
133344 case LogicalTypeId::ENUM: {
133345 auto str_val = ToString();
133346 if (str_val.size() == 1 && str_val[0] == '\0') {
133347 return "chr(0)";
133348 }
133349 return "'" + StringUtil::Replace(ToString(), "'", "''") + "'";
133350 }
133351 case LogicalTypeId::VARIANT: {
133352 string ret = "VARIANT(";
133353 Vector tmp(*this);
133354 RecursiveUnifiedVectorFormat format;
133356 UnifiedVariantVectorData vector_data(format);
133357 auto val = VariantUtils::ConvertVariantToValue(vector_data, 0, 0);
133358 ret += val.ToString();
133359 ret += ")";
133360 return ret;
133361 }
133362 case LogicalTypeId::STRUCT: {
133363 bool is_unnamed = StructType::IsUnnamed(type_);
133364 string ret = is_unnamed ? "(" : "{";
133365 auto &child_types = StructType::GetChildTypes(type_);
133366 auto &struct_values = StructValue::GetChildren(*this);
133367 for (idx_t i = 0; i < struct_values.size(); i++) {
133368 auto &name = child_types[i].first;
133369 auto &child = struct_values[i];
133370 if (is_unnamed) {
133371 ret += child.ToSQLString();
133372 } else {
133373 ret += "'" + name + "': " + child.ToSQLString();
133374 }
133375 if (i < struct_values.size() - 1) {
133376 ret += ", ";
133377 }
133378 }
133379 ret += is_unnamed ? ")" : "}";
133380 return ret;
133381 }
133382 case LogicalTypeId::FLOAT:
133383 if (!FloatIsFinite(FloatValue::Get(*this))) {
133384 return "'" + ToString() + "'::" + type_.ToString();
133385 }
133386 return ToString();
133387 case LogicalTypeId::DOUBLE: {
133388 double val = DoubleValue::Get(*this);
133389 if (!DoubleIsFinite(val)) {
133390 if (!Value::IsNan(val)) {
133391 // to infinity and beyond
133392 return val < 0 ? "-1e1000" : "1e1000";
133393 }
133394 return "'" + ToString() + "'::" + type_.ToString();
133395 }
133396 return ToString();
133397 }
133398 case LogicalTypeId::LIST: {
133399 string ret = "[";
133400 auto &list_values = ListValue::GetChildren(*this);
133401 for (idx_t i = 0; i < list_values.size(); i++) {
133402 auto &child = list_values[i];
133403 ret += child.ToSQLString();
133404 if (i < list_values.size() - 1) {
133405 ret += ", ";
133406 }
133407 }
133408 ret += "]";
133409 return ret;
133410 }
133411 case LogicalTypeId::ARRAY: {
133412 string ret = "[";
133413 auto &array_values = ArrayValue::GetChildren(*this);
133414 for (idx_t i = 0; i < array_values.size(); i++) {
133415 auto &child = array_values[i];
133416 ret += child.ToSQLString();
133417 if (i < array_values.size() - 1) {
133418 ret += ", ";
133419 }
133420 }
133421 ret += "]";
133422 return ret;
133423 }
133424 case LogicalTypeId::UNION: {
133425 string ret = "union_value(";
133426 auto union_tag = UnionValue::GetTag(*this);
133427 auto &tag_name = UnionType::GetMemberName(type(), union_tag);
133428 ret += tag_name + " := ";
133429 ret += UnionValue::GetValue(*this).ToSQLString();
133430 ret += ")";
133431 return ret;
133432 }
133433 default:
133434 return ToString();
133435 }
133436}
static void RecursiveToUnifiedFormat(Vector &input, idx_t count, RecursiveUnifiedVectorFormat &data)
Recursively calls UnifiedVectorFormat on a vector and its child vectors (for nested types).
Definition duckdb.cpp:136924
std::basic_string< Char > format(const S &format_str, Args &&... args)
Definition duckdb.cpp:16295

◆ GetPointer()

uintptr_t duckdb::Value::GetPointer ( ) const
133048 {
133049 D_ASSERT(type() == LogicalType::POINTER);
133050 return value_.pointer;
133051}

◆ CastAs() [1/2]

Value duckdb::Value::CastAs ( CastFunctionSet & set,
GetCastFunctionInput & get_input,
const LogicalType & target_type,
bool strict = false ) const

Cast this value to another type, throws exception if its not possible.

133711 {
133712 if (target_type.id() == LogicalTypeId::ANY) {
133713 return *this;
133714 }
133715 Value new_value;
133716 string error_message;
133717 if (!TryCastAs(set, get_input, target_type, new_value, &error_message, strict)) {
133718 throw InvalidInputException("Failed to cast value: %s", error_message);
133719 }
133720 return new_value;
133721}
DUCKDB_API bool TryCastAs(CastFunctionSet &set, GetCastFunctionInput &get_input, const LogicalType &target_type, Value &new_value, string *error_message, bool strict=false) const
Tries to cast this value to another type, and stores the result in "new_value".
Definition duckdb.cpp:133682

◆ CastAs() [2/2]

Value duckdb::Value::CastAs ( ClientContext & context,
const LogicalType & target_type,
bool strict = false ) const
133723 {
133724 GetCastFunctionInput get_input(context);
133725 return CastAs(CastFunctionSet::Get(context), get_input, target_type, strict);
133726}
DUCKDB_API Value CastAs(CastFunctionSet &set, GetCastFunctionInput &get_input, const LogicalType &target_type, bool strict=false) const
Cast this value to another type, throws exception if its not possible.
Definition duckdb.cpp:133710

◆ DefaultCastAs()

Value duckdb::Value::DefaultCastAs ( const LogicalType & target_type,
bool strict = false ) const
133728 {
133729 CastFunctionSet set;
133730 GetCastFunctionInput get_input;
133731 return CastAs(set, get_input, target_type, strict);
133732}

◆ TryCastAs() [1/4]

bool duckdb::Value::TryCastAs ( CastFunctionSet & set,
GetCastFunctionInput & get_input,
const LogicalType & target_type,
Value & new_value,
string * error_message,
bool strict = false ) const

Tries to cast this value to another type, and stores the result in "new_value".

133683 {
133684 if (type_ == target_type) {
133685 new_value = Copy();
133686 return true;
133687 }
133688 Vector input(*this);
133689 Vector result(target_type);
133690 if (!VectorOperations::TryCast(set, get_input, input, result, 1, error_message, strict)) {
133691 return false;
133692 }
133693 new_value = result.GetValue(0);
133694 return true;
133695}
Value Copy() const
Return a copy of this value.
Definition duckdb.hpp:5842
static DUCKDB_API bool TryCast(CastFunctionSet &set, GetCastFunctionInput &input, Vector &source, Vector &result, idx_t count, string *error_message, bool strict=false, const bool nullify_parent=false)
Definition duckdb.cpp:143445

◆ TryCastAs() [2/4]

bool duckdb::Value::TryCastAs ( ClientContext & context,
const LogicalType & target_type,
Value & new_value,
string * error_message,
bool strict = false ) const
133698 {
133699 GetCastFunctionInput get_input(context);
133700 return TryCastAs(CastFunctionSet::Get(context), get_input, target_type, new_value, error_message, strict);
133701}

◆ TryCastAs() [3/4]

bool duckdb::Value::TryCastAs ( CastFunctionSet & set,
GetCastFunctionInput & get_input,
const LogicalType & target_type,
bool strict = false )

Tries to cast this value to another type, and stores the result in THIS value again.

133735 {
133736 Value new_value;
133737 string error_message;
133738 if (!TryCastAs(set, get_input, target_type, new_value, &error_message, strict)) {
133739 return false;
133740 }
133741 type_ = target_type;
133742 is_null = new_value.is_null;
133743 value_ = new_value.value_;
133744 value_info_ = std::move(new_value.value_info_);
133745 return true;
133746}

◆ TryCastAs() [4/4]

bool duckdb::Value::TryCastAs ( ClientContext & context,
const LogicalType & target_type,
bool strict = false )
133748 {
133749 GetCastFunctionInput get_input(context);
133750 return TryCastAs(CastFunctionSet::Get(context), get_input, target_type, strict);
133751}

◆ DefaultTryCastAs() [1/2]

bool duckdb::Value::DefaultTryCastAs ( const LogicalType & target_type,
Value & new_value,
string * error_message,
bool strict = false ) const
133704 {
133705 CastFunctionSet set;
133706 GetCastFunctionInput get_input;
133707 return TryCastAs(set, get_input, target_type, new_value, error_message, strict);
133708}

◆ DefaultTryCastAs() [2/2]

bool duckdb::Value::DefaultTryCastAs ( const LogicalType & target_type,
bool strict = false )
133753 {
133754 CastFunctionSet set;
133755 GetCastFunctionInput get_input;
133756 return TryCastAs(set, get_input, target_type, strict);
133757}

◆ Reinterpret()

void duckdb::Value::Reinterpret ( LogicalType new_type)
133759 {
133760 this->type_ = std::move(new_type);
133761}

◆ Serialize()

void duckdb::Value::Serialize ( Serializer & serializer) const

Serializes a Value to a stand-alone binary blob.

133904 {
133905 // serialize the value - the top-level value always needs to serialize its type
133906 SerializeInternal(serializer, true);
133907}

◆ Deserialize()

Value duckdb::Value::Deserialize ( Deserializer & deserializer)
static

Deserializes a Value from a blob.

133909 {
133910 auto type = deserializer.ReadPropertyWithExplicitDefault<LogicalType>(100, "type", LogicalTypeId::INVALID);
133911 if (type.InternalType() == PhysicalType::INVALID) {
133912 type = deserializer.Get<const LogicalType &>();
133913 }
133914 auto is_null = deserializer.ReadProperty<bool>(101, "is_null");
133915 Value new_value = Value(type);
133916 if (is_null) {
133917 return new_value;
133918 }
133919 new_value.is_null = false;
133920
133921 if (type.id() == LogicalTypeId::TYPE) {
133922 // special case for TYPE values: deserialize the type as a nested object
133923 auto type_value = deserializer.ReadProperty<LogicalType>(102, "value");
133924 return Value::TYPE(type_value);
133925 }
133926
133927 switch (type.InternalType()) {
133928 case PhysicalType::BIT:
133929 throw InternalException("BIT type should not be deserialized");
133930 case PhysicalType::BOOL:
133931 new_value.value_.boolean = deserializer.ReadProperty<bool>(102, "value");
133932 break;
133933 case PhysicalType::UINT8:
133934 new_value.value_.utinyint = deserializer.ReadProperty<uint8_t>(102, "value");
133935 break;
133936 case PhysicalType::INT8:
133937 new_value.value_.tinyint = deserializer.ReadProperty<int8_t>(102, "value");
133938 break;
133940 new_value.value_.usmallint = deserializer.ReadProperty<uint16_t>(102, "value");
133941 break;
133942 case PhysicalType::INT16:
133943 new_value.value_.smallint = deserializer.ReadProperty<int16_t>(102, "value");
133944 break;
133946 new_value.value_.uinteger = deserializer.ReadProperty<uint32_t>(102, "value");
133947 break;
133948 case PhysicalType::INT32:
133949 new_value.value_.integer = deserializer.ReadProperty<int32_t>(102, "value");
133950 break;
133952 new_value.value_.ubigint = deserializer.ReadProperty<uint64_t>(102, "value");
133953 break;
133954 case PhysicalType::INT64:
133955 new_value.value_.bigint = deserializer.ReadProperty<int64_t>(102, "value");
133956 break;
133957 case PhysicalType::UINT128:
133958 new_value.value_.uhugeint = deserializer.ReadProperty<uhugeint_t>(102, "value");
133959 break;
133960 case PhysicalType::INT128:
133961 new_value.value_.hugeint = deserializer.ReadProperty<hugeint_t>(102, "value");
133962 break;
133963 case PhysicalType::FLOAT:
133964 new_value.value_.float_ = deserializer.ReadProperty<float>(102, "value");
133965 break;
133967 new_value.value_.double_ = deserializer.ReadProperty<double>(102, "value");
133968 break;
133970 new_value.value_.interval = deserializer.ReadProperty<interval_t>(102, "value");
133971 break;
133972 case PhysicalType::VARCHAR: {
133973 if (type.id() == LogicalTypeId::BLOB) {
133974 auto str = deserializer.ReadProperty<string>(102, "value");
133975 new_value.value_info_ = make_shared_ptr<StringValueInfo>(Blob::ToBlob(str));
133976 } else if (type.id() == LogicalTypeId::GEOMETRY) {
133977 auto text = deserializer.ReadProperty<string>(102, "value");
133978 auto type = deserializer.ReadPropertyWithExplicitDefault<GeometryStorageType>(103, "geometry_format",
133979 GeometryStorageType::SPATIAL);
133980
133981 auto blob = Blob::ToBlob(text);
133982 if (type == GeometryStorageType::WKB) {
133983 new_value.value_info_ = make_shared_ptr<StringValueInfo>(std::move(blob));
133984 } else if (type == GeometryStorageType::SPATIAL) {
133985 string geom;
133986 Geometry::FromSpatialGeometry(blob, geom);
133987 new_value.value_info_ = make_shared_ptr<StringValueInfo>(std::move(geom));
133988 } else {
133989 throw InternalException("Unknown geometry format in value deserialization");
133990 }
133991 } else {
133992 auto str = deserializer.ReadProperty<string>(102, "value");
133993 new_value.value_info_ = make_shared_ptr<StringValueInfo>(std::move(str));
133994 }
133995 } break;
133996 case PhysicalType::LIST: {
133997 deserializer.Set<const LogicalType &>(ListType::GetChildType(type));
133998 deserializer.ReadObject(102, "value", [&](Deserializer &obj) {
133999 auto children = obj.ReadProperty<vector<Value>>(100, "children");
134000 new_value.value_info_ = make_shared_ptr<NestedValueInfo>(children);
134001 });
134002 deserializer.Unset<LogicalType>();
134003 } break;
134004 case PhysicalType::STRUCT: {
134005 deserializer.ReadObject(102, "value", [&](Deserializer &obj) {
134006 vector<Value> children;
134007 obj.ReadList(100, "children", [&](Deserializer::List &list, idx_t i) {
134008 deserializer.Set<const LogicalType &>(StructType::GetChildType(type, i));
134009 auto child = list.ReadElement<Value>();
134010 deserializer.Unset<LogicalType>();
134011 children.push_back(std::move(child));
134012 });
134013 new_value.value_info_ = make_shared_ptr<NestedValueInfo>(children);
134014 });
134015 } break;
134016 case PhysicalType::ARRAY: {
134017 deserializer.Set<const LogicalType &>(ArrayType::GetChildType(type));
134018 deserializer.ReadObject(102, "value", [&](Deserializer &obj) {
134019 auto children = obj.ReadProperty<vector<Value>>(100, "children");
134020 new_value.value_info_ = make_shared_ptr<NestedValueInfo>(children);
134021 });
134022 deserializer.Unset<LogicalType>();
134023 } break;
134024 default:
134025 throw NotImplementedException("Unimplemented type for Deserialize");
134026 }
134027 return new_value;
134028}
::int8_t int8_t
::uint32_t uint32_t
::uint8_t uint8_t
::uint64_t uint64_t
::uint16_t uint16_t
@ LIST
A list of some logical data type.
Definition duckdb.hpp:2813
@ BIT
Boolean as 1 bit, LSB bit-packed ordering.
Definition duckdb.hpp:2852
@ VARCHAR
DuckDB Extensions.
Definition duckdb.hpp:2847

◆ operator==() [1/2]

bool duckdb::Value::operator== ( const Value & rhs) const
133634 {
133635 return ValueOperations::Equals(*this, rhs);
133636}

◆ operator==() [2/2]

bool duckdb::Value::operator== ( const int64_t & rhs) const
133658 {
133659 return *this == Value::Numeric(type_, rhs);
133660}

◆ operator!=() [1/2]

bool duckdb::Value::operator!= ( const Value & rhs) const
133638 {
133639 return ValueOperations::NotEquals(*this, rhs);
133640}

◆ operator!=() [2/2]

bool duckdb::Value::operator!= ( const int64_t & rhs) const
133662 {
133663 return *this != Value::Numeric(type_, rhs);
133664}

◆ operator<() [1/2]

bool duckdb::Value::operator< ( const Value & rhs) const
133642 {
133643 return ValueOperations::LessThan(*this, rhs);
133644}

◆ operator<() [2/2]

bool duckdb::Value::operator< ( const int64_t & rhs) const
133666 {
133667 return *this < Value::Numeric(type_, rhs);
133668}

◆ operator>() [1/2]

bool duckdb::Value::operator> ( const Value & rhs) const
133646 {
133647 return ValueOperations::GreaterThan(*this, rhs);
133648}

◆ operator>() [2/2]

bool duckdb::Value::operator> ( const int64_t & rhs) const
133670 {
133671 return *this > Value::Numeric(type_, rhs);
133672}

◆ operator<=() [1/2]

bool duckdb::Value::operator<= ( const Value & rhs) const
133650 {
133651 return ValueOperations::LessThanEquals(*this, rhs);
133652}

◆ operator<=() [2/2]

bool duckdb::Value::operator<= ( const int64_t & rhs) const
133674 {
133675 return *this <= Value::Numeric(type_, rhs);
133676}

◆ operator>=() [1/2]

bool duckdb::Value::operator>= ( const Value & rhs) const
133654 {
133655 return ValueOperations::GreaterThanEquals(*this, rhs);
133656}

◆ operator>=() [2/2]

bool duckdb::Value::operator>= ( const int64_t & rhs) const
133678 {
133679 return *this >= Value::Numeric(type_, rhs);
133680}

◆ FloatIsFinite()

bool duckdb::Value::FloatIsFinite ( float value)
static
132209 {
132210 return !(std::isnan(value) || std::isinf(value));
132211}

◆ DoubleIsFinite()

bool duckdb::Value::DoubleIsFinite ( double value)
static
132213 {
132214 return !(std::isnan(value) || std::isinf(value));
132215}

◆ IsNan() [1/3]

template<class T>
bool duckdb::Value::IsNan ( T value)
inlinestatic
5900 {
5901 throw InternalException("Unimplemented template type for Value::IsNan");
5902 }

◆ IsNan() [2/3]

template<>
bool duckdb::Value::IsNan ( float input)
132218 {
132219 return std::isnan(input);
132220}

◆ IsNan() [3/3]

template<>
bool duckdb::Value::IsNan ( double input)
132223 {
132224 return std::isnan(input);
132225}

◆ IsFinite() [1/9]

template<class T>
bool duckdb::Value::IsFinite ( T value)
inlinestatic
5904 {
5905 return true;
5906 }

◆ IsFinite() [2/9]

template<>
bool duckdb::Value::IsFinite ( float input)
132228 {
132229 return Value::FloatIsFinite(input);
132230}

◆ IsFinite() [3/9]

template<>
bool duckdb::Value::IsFinite ( double input)
132233 {
132234 return Value::DoubleIsFinite(input);
132235}

◆ IsFinite() [4/9]

template<>
bool duckdb::Value::IsFinite ( date_t input)
132238 {
132239 return Date::IsFinite(input);
132240}
static bool IsFinite(date_t date)
Returns true if the specified date is finite.
Definition duckdb.hpp:5078

◆ IsFinite() [5/9]

template<>
bool duckdb::Value::IsFinite ( timestamp_t input)
132243 {
132244 return Timestamp::IsFinite(input);
132245}
static bool IsFinite(timestamp_t timestamp)
True, if the timestamp is finite, else false.
Definition duckdb.hpp:4287

◆ IsFinite() [6/9]

template<>
bool duckdb::Value::IsFinite ( timestamp_sec_t input)
132248 {
132249 return Timestamp::IsFinite(input);
132250}

◆ IsFinite() [7/9]

template<>
bool duckdb::Value::IsFinite ( timestamp_ms_t input)
132253 {
132254 return Timestamp::IsFinite(input);
132255}

◆ IsFinite() [8/9]

template<>
bool duckdb::Value::IsFinite ( timestamp_ns_t input)
132258 {
132259 return Timestamp::IsFinite(input);
132260}

◆ IsFinite() [9/9]

template<>
bool duckdb::Value::IsFinite ( timestamp_tz_t input)
132263 {
132264 return Timestamp::IsFinite(input);
132265}

◆ StringIsValid() [1/2]

bool duckdb::Value::StringIsValid ( const char * str,
idx_t length )
static
132267 {
132268 auto utf_type = Utf8Proc::Analyze(str, length);
132269 return utf_type != UnicodeType::INVALID;
132270}
static UnicodeType Analyze(const char *s, size_t len, UnicodeInvalidReason *invalid_reason=nullptr, size_t *invalid_pos=nullptr)
Distinguishes ASCII, Valid UTF8 and Invalid UTF8 strings.
Definition duckdb.cpp:507297

◆ StringIsValid() [2/2]

bool duckdb::Value::StringIsValid ( const string & str)
inlinestatic
5908 {
5909 return StringIsValid(str.c_str(), str.size());
5910 }

◆ ValuesAreEqual() [1/2]

bool duckdb::Value::ValuesAreEqual ( CastFunctionSet & set,
GetCastFunctionInput & get_input,
const Value & result_value,
const Value & value )
static

Returns true if the values are (approximately) equivalent. Note this is NOT the SQL equivalence. For this function, NULL values are equivalent and floating point values that are close are equivalent.

134050 {
134051 if (result_value.IsNull() != value.IsNull()) {
134052 return false;
134053 }
134054 if (result_value.IsNull() && value.IsNull()) {
134055 // NULL = NULL in checking code
134056 return true;
134057 }
134058 switch (value.type_.id()) {
134059 case LogicalTypeId::FLOAT: {
134060 auto other = result_value.CastAs(set, get_input, LogicalType::FLOAT);
134061 float ldecimal = value.value_.float_;
134062 float rdecimal = other.value_.float_;
134063 return ApproxEqual(ldecimal, rdecimal);
134064 }
134065 case LogicalTypeId::DOUBLE: {
134066 auto other = result_value.CastAs(set, get_input, LogicalType::DOUBLE);
134067 double ldecimal = value.value_.double_;
134068 double rdecimal = other.value_.double_;
134069 return ApproxEqual(ldecimal, rdecimal);
134070 }
134071 case LogicalTypeId::VARCHAR: {
134072 auto other = result_value.CastAs(set, get_input, LogicalType::VARCHAR);
134073 string left = SanitizeValue(StringValue::Get(other));
134074 string right = SanitizeValue(StringValue::Get(value));
134075 return left == right;
134076 }
134077 default:
134078 if (result_value.type_.id() == LogicalTypeId::FLOAT || result_value.type_.id() == LogicalTypeId::DOUBLE) {
134079 return Value::ValuesAreEqual(set, get_input, value, result_value);
134080 }
134081 return value == result_value;
134082 }
134083}
static DUCKDB_API bool ValuesAreEqual(CastFunctionSet &set, GetCastFunctionInput &get_input, const Value &result_value, const Value &value)
Definition duckdb.cpp:134049

◆ ValuesAreEqual() [2/2]

bool duckdb::Value::ValuesAreEqual ( ClientContext & context,
const Value & result_value,
const Value & value )
static
134085 {
134086 GetCastFunctionInput get_input(context);
134087 return Value::ValuesAreEqual(CastFunctionSet::Get(context), get_input, result_value, value);
134088}

◆ DefaultValuesAreEqual()

bool duckdb::Value::DefaultValuesAreEqual ( const Value & result_value,
const Value & value )
static
134089 {
134090 CastFunctionSet set;
134091 GetCastFunctionInput get_input;
134092 return Value::ValuesAreEqual(set, get_input, result_value, value);
134093}

◆ NotDistinctFrom()

bool duckdb::Value::NotDistinctFrom ( const Value & lvalue,
const Value & rvalue )
static

Returns true if the values are not distinct from each other, following SQL semantics for NOT DISTINCT FROM.

134034 {
134035 return ValueOperations::NotDistinctFrom(lvalue, rvalue);
134036}

◆ Print()

void duckdb::Value::Print ( ) const
134030 {
134032}
static DUCKDB_API void Print(OutputStream stream, const string &str)
Print the object to the stream.
Definition duckdb.cpp:92556

◆ SerializeInternal()

void duckdb::Value::SerializeInternal ( Serializer & serializer,
bool serialize_type ) const
private
133806 {
133807 if (serialize_type || !serializer.ShouldSerialize(4)) {
133808 // only the root value needs to serialize its type
133809 // for forwards compatibility reasons, we also serialize the type always when targeting versions < v1.2.0
133810 serializer.WriteProperty(100, "type", type_);
133811 }
133812 serializer.WriteProperty(101, "is_null", is_null);
133813 if (IsNull()) {
133814 return;
133815 }
133816
133817 if (type_.id() == LogicalTypeId::TYPE) {
133818 // special case for TYPE values: serialize the type as a nested object
133819 auto type_value = TypeValue::GetType(*this);
133820 serializer.WriteProperty(102, "value", type_value);
133821 return;
133822 }
133823
133824 switch (type_.InternalType()) {
133825 case PhysicalType::BIT:
133826 throw InternalException("BIT type should not be serialized");
133827 case PhysicalType::BOOL:
133828 serializer.WriteProperty(102, "value", value_.boolean);
133829 break;
133830 case PhysicalType::INT8:
133831 serializer.WriteProperty(102, "value", value_.tinyint);
133832 break;
133833 case PhysicalType::INT16:
133834 serializer.WriteProperty(102, "value", value_.smallint);
133835 break;
133836 case PhysicalType::INT32:
133837 serializer.WriteProperty(102, "value", value_.integer);
133838 break;
133839 case PhysicalType::INT64:
133840 serializer.WriteProperty(102, "value", value_.bigint);
133841 break;
133842 case PhysicalType::UINT8:
133843 serializer.WriteProperty(102, "value", value_.utinyint);
133844 break;
133846 serializer.WriteProperty(102, "value", value_.usmallint);
133847 break;
133849 serializer.WriteProperty(102, "value", value_.uinteger);
133850 break;
133852 serializer.WriteProperty(102, "value", value_.ubigint);
133853 break;
133854 case PhysicalType::INT128:
133855 serializer.WriteProperty(102, "value", value_.hugeint);
133856 break;
133857 case PhysicalType::UINT128:
133858 serializer.WriteProperty(102, "value", value_.uhugeint);
133859 break;
133860 case PhysicalType::FLOAT:
133861 serializer.WriteProperty(102, "value", value_.float_);
133862 break;
133864 serializer.WriteProperty(102, "value", value_.double_);
133865 break;
133867 serializer.WriteProperty(102, "value", value_.interval);
133868 break;
133869 case PhysicalType::VARCHAR: {
133870 if (type_.id() == LogicalTypeId::BLOB) {
133871 auto blob_str = Blob::ToString(StringValue::Get(*this));
133872 serializer.WriteProperty(102, "value", blob_str);
133873 } else if (type_.id() == LogicalTypeId::GEOMETRY) {
133874 if (!serializer.ShouldSerialize(7)) {
133875 // Write as old-style SPATIAL format
133876 string blob;
133877 Geometry::ToSpatialGeometry(StringValue::Get(*this), blob);
133878 auto text = Blob::ToString(blob);
133879 serializer.WriteProperty(102, "value", text);
133880 } else {
133881 // Otherwise, write as WKB with an explicit format property so that we recognize during deserialization.
133882 auto text = Blob::ToString(StringValue::Get(*this));
133883 serializer.WriteProperty(102, "value", text);
133884 serializer.WriteProperty(103, "geometry_format", GeometryStorageType::WKB);
133885 }
133886 } else {
133887 serializer.WriteProperty(102, "value", StringValue::Get(*this));
133888 }
133889 } break;
133890 case PhysicalType::LIST:
133891 SerializeChildren(serializer, ListValue::GetChildren(*this), type_);
133892 break;
133894 SerializeChildren(serializer, StructValue::GetChildren(*this), type_);
133895 break;
133896 case PhysicalType::ARRAY:
133897 SerializeChildren(serializer, ArrayValue::GetChildren(*this), type_);
133898 break;
133899 default:
133900 throw NotImplementedException("Unimplemented type for Serialize");
133901 }
133902}
static DUCKDB_API void ToString(string_t blob, char *output)
Converts a blob to a string, writing the output to the designated output string. The string needs to ...
Definition duckdb.cpp:113152

◆ SerializeChildren()

void duckdb::Value::SerializeChildren ( Serializer & serializer,
const vector< Value > & children,
const LogicalType & parent_type )
staticprivate
133789 {
133790 serializer.WriteObject(102, "value", [&](Serializer &child_serializer) {
133791 child_serializer.WriteList(100, "children", children.size(), [&](Serializer::List &list, idx_t i) {
133792 auto &value_type = GetChildType(parent_type, i);
133793 bool serialize_type = value_type.InternalType() == PhysicalType::INVALID;
133794 if (!serialize_type && !SerializeTypeMatches(value_type, children[i].type())) {
133795 throw InternalException("Error when serializing type - serializing a child of a nested value with type "
133796 "%s, but expected type %s",
133797 children[i].type(), value_type);
133798 }
133799 list.WriteObject([&](Serializer &element_serializer) {
133800 children[i].SerializeInternal(element_serializer, serialize_type);
133801 });
133802 });
133803 });
133804}

◆ GetValueInternal()

template<class T>
T duckdb::Value::GetValueInternal ( ) const
private
132844 {
132845 if (IsNull()) {
132846 throw InternalException("Calling GetValueInternal on a value that is NULL");
132847 }
132848 switch (type_.id()) {
132849 case LogicalTypeId::BOOLEAN:
132850 return Cast::Operation<bool, T>(value_.boolean);
132851 case LogicalTypeId::TINYINT:
132852 return Cast::Operation<int8_t, T>(value_.tinyint);
132853 case LogicalTypeId::SMALLINT:
132854 return Cast::Operation<int16_t, T>(value_.smallint);
132855 case LogicalTypeId::INTEGER:
132856 return Cast::Operation<int32_t, T>(value_.integer);
132857 case LogicalTypeId::BIGINT:
132858 return Cast::Operation<int64_t, T>(value_.bigint);
132859 case LogicalTypeId::HUGEINT:
132860 case LogicalTypeId::UUID:
132861 return Cast::Operation<hugeint_t, T>(value_.hugeint);
132862 case LogicalTypeId::UHUGEINT:
132863 return Cast::Operation<uhugeint_t, T>(value_.uhugeint);
132864 case LogicalTypeId::DATE:
132865 return Cast::Operation<date_t, T>(value_.date);
132866 case LogicalTypeId::TIME:
132867 return Cast::Operation<dtime_t, T>(value_.time);
132868 case LogicalTypeId::TIME_NS:
132869 return Cast::Operation<dtime_ns_t, T>(value_.time_ns);
132870 case LogicalTypeId::TIME_TZ:
132871 return Cast::Operation<dtime_tz_t, T>(value_.timetz);
132872 case LogicalTypeId::TIMESTAMP:
132873 return Cast::Operation<timestamp_t, T>(value_.timestamp);
132874 case LogicalTypeId::TIMESTAMP_SEC:
132875 return Cast::Operation<timestamp_sec_t, T>(value_.timestamp_s);
132876 case LogicalTypeId::TIMESTAMP_MS:
132877 return Cast::Operation<timestamp_ms_t, T>(value_.timestamp_ms);
132879 return Cast::Operation<timestamp_ns_t, T>(value_.timestamp_ns);
132880 case LogicalTypeId::TIMESTAMP_TZ:
132881 return Cast::Operation<timestamp_tz_t, T>(value_.timestamp_tz);
132882 case LogicalTypeId::UTINYINT:
132883 return Cast::Operation<uint8_t, T>(value_.utinyint);
132884 case LogicalTypeId::USMALLINT:
132885 return Cast::Operation<uint16_t, T>(value_.usmallint);
132886 case LogicalTypeId::UINTEGER:
132887 return Cast::Operation<uint32_t, T>(value_.uinteger);
132888 case LogicalTypeId::UBIGINT:
132889 return Cast::Operation<uint64_t, T>(value_.ubigint);
132890 case LogicalTypeId::FLOAT:
132891 return Cast::Operation<float, T>(value_.float_);
132892 case LogicalTypeId::DOUBLE:
132893 return Cast::Operation<double, T>(value_.double_);
132894 case LogicalTypeId::VARCHAR:
132895 return Cast::Operation<string_t, T>(StringValue::Get(*this).c_str());
132896 case LogicalTypeId::INTERVAL:
132897 return Cast::Operation<interval_t, T>(value_.interval);
132898 case LogicalTypeId::DECIMAL:
132899 return DefaultCastAs(LogicalType::DOUBLE).GetValueInternal<T>();
132900 case LogicalTypeId::ENUM: {
132901 switch (type_.InternalType()) {
132902 case PhysicalType::UINT8:
132903 return Cast::Operation<uint8_t, T>(value_.utinyint);
132905 return Cast::Operation<uint16_t, T>(value_.usmallint);
132907 return Cast::Operation<uint32_t, T>(value_.uinteger);
132908 default:
132909 throw InternalException("Invalid Internal Type for ENUMs");
132910 }
132911 }
132912 default:
132913 throw NotImplementedException("Unimplemented type \"%s\" for GetValue()", type_.ToString());
132914 }
132915}

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const Value & val )
friend
5921 {
5922 out << val.ToString();
5923 return out;
5924 }
DUCKDB_API string ToString() const
Convert this value to a string.
Definition duckdb.cpp:133318

The documentation for this class was generated from the following files: