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
LogicalType Struct Reference
Collaboration diagram for LogicalType:

Public Member Functions

DUCKDB_API LogicalType (LogicalTypeId id)
DUCKDB_API LogicalType (LogicalTypeId id, shared_ptr< ExtraTypeInfo > type_info)
DUCKDB_API LogicalType (const LogicalType &other)
DUCKDB_API LogicalType (LogicalType &&other) noexcept
LogicalTypeId id () const
PhysicalType InternalType () const
const optional_ptr< ExtraTypeInfo > AuxInfo () const
bool IsNested () const
bool IsUnknown () const
bool IsUnbound () const
shared_ptr< ExtraTypeInfo > GetAuxInfoShrPtr () const
LogicalType Copy () const
 Copies the logical type, making a new ExtraTypeInfo.
LogicalType DeepCopy () const
 DeepCopy() will make a unique copy of any nested ExtraTypeInfo as well.
void CopyAuxInfo (const LogicalType &other)
bool EqualTypeInfo (const LogicalType &rhs) const
LogicalType & operator= (const LogicalType &other)
LogicalType & operator= (LogicalType &&other) noexcept
DUCKDB_API bool operator== (const LogicalType &rhs) const
bool operator!= (const LogicalType &rhs) const
DUCKDB_API void Serialize (Serializer &serializer) const
DUCKDB_API string ToString () const
DUCKDB_API bool IsIntegral () const
DUCKDB_API bool IsFloating () const
DUCKDB_API bool IsNumeric () const
DUCKDB_API bool IsTemporal () const
DUCKDB_API hash_t Hash () const
DUCKDB_API void SetAlias (string alias)
DUCKDB_API bool HasAlias () const
DUCKDB_API string GetAlias () const
DUCKDB_API bool HasExtensionInfo () const
DUCKDB_API optional_ptr< const ExtensionTypeInfo > GetExtensionInfo () const
DUCKDB_API optional_ptr< ExtensionTypeInfo > GetExtensionInfo ()
DUCKDB_API void SetExtensionInfo (unique_ptr< ExtensionTypeInfo > info)
DUCKDB_API bool GetDecimalProperties (uint8_t &width, uint8_t &scale) const
 Gets the decimal properties of a numeric type. Fails if the type is not numeric.
DUCKDB_API void Verify () const
DUCKDB_API bool IsSigned () const
DUCKDB_API bool IsUnsigned () const
DUCKDB_API bool IsValid () const
DUCKDB_API bool IsComplete () const
DUCKDB_API bool IsTemplated () const
bool SupportsRegularUpdate () const
 True, if this type supports in-place updates.
DUCKDB_API bool IsJSONType () const

Static Public Member Functions

static DUCKDB_API LogicalType Deserialize (Deserializer &deserializer)
static bool TypeIsTimestamp (LogicalTypeId id)
static bool TypeIsTimestamp (const LogicalType &type)
static DUCKDB_API bool IsNumeric (LogicalTypeId type)
static DUCKDB_API LogicalType MaxLogicalType (ClientContext &context, const LogicalType &left, const LogicalType &right)
 Returns the maximum logical type when combining the two types - or throws an exception if combining is not possible.
static DUCKDB_API bool TryGetMaxLogicalType (ClientContext &context, const LogicalType &left, const LogicalType &right, LogicalType &result)
static DUCKDB_API bool TryGetMaxLogicalTypeUnchecked (const LogicalType &left, const LogicalType &right, LogicalType &result)
static DUCKDB_API LogicalType ForceMaxLogicalType (const LogicalType &left, const LogicalType &right)
 Forcibly returns a maximum logical type - similar to MaxLogicalType but never throws. As a fallback either left or right are returned.
static DUCKDB_API LogicalType NormalizeType (const LogicalType &type)
 Normalize a type - removing literals.
static DUCKDB_API LogicalType DECIMAL (uint8_t width, uint8_t scale)
static DUCKDB_API LogicalType VARCHAR_COLLATION (string collation)
static DUCKDB_API LogicalType LIST (const LogicalType &child)
static DUCKDB_API LogicalType STRUCT (child_list_t< LogicalType > children)
static DUCKDB_API LogicalType AGGREGATE_STATE (aggregate_state_t state_type)
static DUCKDB_API LogicalType MAP (const LogicalType &child)
static DUCKDB_API LogicalType MAP (LogicalType key, LogicalType value)
static DUCKDB_API LogicalType UNION (child_list_t< LogicalType > members)
static DUCKDB_API LogicalType ARRAY (const LogicalType &child, optional_idx index)
static DUCKDB_API LogicalType ENUM (Vector &ordered_data, idx_t size)
static DUCKDB_API LogicalType ENUM (const string &enum_name, Vector &ordered_data, idx_t size)
static DUCKDB_API LogicalType GEOMETRY ()
static DUCKDB_API LogicalType GEOMETRY (const string &crs)
static DUCKDB_API LogicalType GEOMETRY (const CoordinateReferenceSystem &crs)
static DUCKDB_API LogicalType ANY_PARAMS (LogicalType target, idx_t cast_score=5)
static DUCKDB_API LogicalType TEMPLATE (const string &name)
static DUCKDB_API LogicalType VARIANT ()
static DUCKDB_API LogicalType INTEGER_LITERAL (const Value &constant)
 Integer literal of the specified value.
static DUCKDB_API LogicalType UNBOUND (unique_ptr< ParsedExpression > expr)
static DUCKDB_API LogicalType TYPE ()
static DUCKDB_API const vector< LogicalType > Numeric ()
 A list of all NUMERIC types (integral and floating point types).
static DUCKDB_API const vector< LogicalType > Integral ()
 A list of all INTEGRAL types.
static DUCKDB_API const vector< LogicalType > Real ()
 A list of all REAL types.
static DUCKDB_API const vector< LogicalType > AllTypes ()
 A list of ALL SQL types.
static DUCKDB_API LogicalType JSON ()

Static Public Attributes

static constexpr const LogicalTypeId SQLNULL = LogicalTypeId::SQLNULL
static constexpr const LogicalTypeId UNKNOWN = LogicalTypeId::UNKNOWN
static constexpr const LogicalTypeId BOOLEAN = LogicalTypeId::BOOLEAN
static constexpr const LogicalTypeId TINYINT = LogicalTypeId::TINYINT
static constexpr const LogicalTypeId UTINYINT = LogicalTypeId::UTINYINT
static constexpr const LogicalTypeId SMALLINT = LogicalTypeId::SMALLINT
static constexpr const LogicalTypeId USMALLINT = LogicalTypeId::USMALLINT
static constexpr const LogicalTypeId INTEGER = LogicalTypeId::INTEGER
static constexpr const LogicalTypeId UINTEGER = LogicalTypeId::UINTEGER
static constexpr const LogicalTypeId BIGINT = LogicalTypeId::BIGINT
static constexpr const LogicalTypeId UBIGINT = LogicalTypeId::UBIGINT
static constexpr const LogicalTypeId FLOAT = LogicalTypeId::FLOAT
static constexpr const LogicalTypeId DOUBLE = LogicalTypeId::DOUBLE
static constexpr const LogicalTypeId DATE = LogicalTypeId::DATE
static constexpr const LogicalTypeId TIMESTAMP = LogicalTypeId::TIMESTAMP
static constexpr const LogicalTypeId TIMESTAMP_S = LogicalTypeId::TIMESTAMP_SEC
static constexpr const LogicalTypeId TIMESTAMP_MS = LogicalTypeId::TIMESTAMP_MS
static constexpr const LogicalTypeId TIMESTAMP_NS = LogicalTypeId::TIMESTAMP_NS
static constexpr const LogicalTypeId TIME = LogicalTypeId::TIME
static constexpr const LogicalTypeId TIME_NS = LogicalTypeId::TIME_NS
static constexpr const LogicalTypeId TIMESTAMP_TZ = LogicalTypeId::TIMESTAMP_TZ
static constexpr const LogicalTypeId TIME_TZ = LogicalTypeId::TIME_TZ
static constexpr const LogicalTypeId VARCHAR = LogicalTypeId::VARCHAR
static constexpr const LogicalTypeId ANY = LogicalTypeId::ANY
static constexpr const LogicalTypeId BLOB = LogicalTypeId::BLOB
static constexpr const LogicalTypeId BIT = LogicalTypeId::BIT
static constexpr const LogicalTypeId BIGNUM = LogicalTypeId::BIGNUM
static constexpr const LogicalTypeId INTERVAL = LogicalTypeId::INTERVAL
static constexpr const LogicalTypeId HUGEINT = LogicalTypeId::HUGEINT
static constexpr const LogicalTypeId UHUGEINT = LogicalTypeId::UHUGEINT
static constexpr const LogicalTypeId UUID = LogicalTypeId::UUID
static constexpr const LogicalTypeId HASH = LogicalTypeId::UBIGINT
static constexpr const LogicalTypeId POINTER = LogicalTypeId::POINTER
static constexpr const LogicalTypeId TABLE = LogicalTypeId::TABLE
static constexpr const LogicalTypeId LAMBDA = LogicalTypeId::LAMBDA
static constexpr const LogicalTypeId INVALID = LogicalTypeId::INVALID
static constexpr const LogicalTypeId ROW_TYPE = LogicalTypeId::BIGINT
static constexpr auto JSON_TYPE_NAME = "JSON"
 The JSON type lives in the JSON extension, but we need to define this here for special handling.

Private Member Functions

PhysicalType GetInternalType ()

Private Attributes

LogicalTypeId id_
PhysicalType physical_type_
shared_ptr< ExtraTypeInfo > type_info_

Constructor & Destructor Documentation

◆ LogicalType() [1/5]

duckdb::LogicalType::LogicalType ( )
139074 : LogicalType(LogicalTypeId::INVALID) {
139075}

◆ LogicalType() [2/5]

duckdb::LogicalType::LogicalType ( LogicalTypeId id)
139077 : id_(id) {
139078 physical_type_ = GetInternalType();
139079}

◆ LogicalType() [3/5]

duckdb::LogicalType::LogicalType ( LogicalTypeId id,
shared_ptr< ExtraTypeInfo > type_info )
139081 : id_(id), type_info_(std::move(type_info_p)) {
139082 physical_type_ = GetInternalType();
139083}

◆ LogicalType() [4/5]

duckdb::LogicalType::LogicalType ( const LogicalType & other)
139086 : id_(other.id_), physical_type_(other.physical_type_), type_info_(other.type_info_) {
139087}

◆ LogicalType() [5/5]

duckdb::LogicalType::LogicalType ( LogicalType && other)
noexcept
139090 : id_(other.id_), physical_type_(other.physical_type_), type_info_(std::move(other.type_info_)) {
139091}

◆ ~LogicalType()

duckdb::LogicalType::~LogicalType ( )
141092 {
141093}

Member Function Documentation

◆ id()

LogicalTypeId duckdb::LogicalType::id ( ) const
inline
2939 { // NOLINT: mimic std casing
2940 return id_;
2941 }

◆ InternalType()

PhysicalType duckdb::LogicalType::InternalType ( ) const
inline
2942 {
2943 return physical_type_;
2944 }

◆ AuxInfo()

const optional_ptr< ExtraTypeInfo > duckdb::LogicalType::AuxInfo ( ) const
inline
2945 {
2946 return type_info_.get();
2947 }

◆ IsNested()

bool duckdb::LogicalType::IsNested ( ) const
inline
2948 {
2949 auto internal = InternalType();
2950 if (internal == PhysicalType::STRUCT) {
2951 return true;
2952 }
2953 if (internal == PhysicalType::LIST) {
2954 return true;
2955 }
2956 if (internal == PhysicalType::ARRAY) {
2957 return true;
2958 }
2959 return false;
2960 }

◆ IsUnknown()

bool duckdb::LogicalType::IsUnknown ( ) const
inline
2961 {
2962 return id_ == LogicalTypeId::UNKNOWN;
2963 }

◆ IsUnbound()

bool duckdb::LogicalType::IsUnbound ( ) const
inline
2964 {
2965 return id_ == LogicalTypeId::UNBOUND;
2966 }

◆ GetAuxInfoShrPtr()

shared_ptr< ExtraTypeInfo > duckdb::LogicalType::GetAuxInfoShrPtr ( ) const
inline
2968 {
2969 return type_info_;
2970 }

◆ Copy()

Copies the logical type, making a new ExtraTypeInfo.

140449 {
140450 LogicalType copy = *this;
140451 if (type_info_ && type_info_->type != ExtraTypeInfoType::ENUM_TYPE_INFO) {
140452 // We copy (i.e., create new) type info, unless the type is an ENUM, otherwise we have to copy the whole dict
140453 copy.type_info_ = type_info_->Copy();
140454 }
140455 return copy;
140456}

◆ DeepCopy()

DeepCopy() will make a unique copy of any nested ExtraTypeInfo as well.

140458 {
140459 LogicalType copy = *this;
140460 if (type_info_ && type_info_->type != ExtraTypeInfoType::ENUM_TYPE_INFO) {
140461 // We copy (i.e., create new) type info, unless the type is an ENUM, otherwise we have to copy the whole dict
140462 copy.type_info_ = type_info_->DeepCopy();
140463 }
140464 return copy;
140465}

◆ CopyAuxInfo()

void duckdb::LogicalType::CopyAuxInfo ( const LogicalType & other)
inline
2977 {
2978 type_info_ = other.type_info_;
2979 }

◆ EqualTypeInfo()

bool duckdb::LogicalType::EqualTypeInfo ( const LogicalType & rhs) const
141095 {
141096 if (type_info_.get() == rhs.type_info_.get()) {
141097 return true;
141098 }
141099 if (type_info_) {
141100 return type_info_->Equals(rhs.type_info_.get());
141101 } else {
141102 D_ASSERT(rhs.type_info_);
141103 return rhs.type_info_->Equals(type_info_.get());
141104 }
141105}

◆ operator=() [1/2]

LogicalType & duckdb::LogicalType::operator= ( const LogicalType & other)
inline
2983 {
2984 if (this == &other) {
2985 return *this;
2986 }
2987 id_ = other.id_;
2988 physical_type_ = other.physical_type_;
2989 type_info_ = other.type_info_;
2990 return *this;
2991 }

◆ operator=() [2/2]

LogicalType & duckdb::LogicalType::operator= ( LogicalType && other)
inlinenoexcept
2993 {
2994 id_ = other.id_;
2995 physical_type_ = other.physical_type_;
2996 std::swap(type_info_, other.type_info_);
2997 return *this;
2998 }

◆ operator==()

bool duckdb::LogicalType::operator== ( const LogicalType & rhs) const
141107 {
141108 if (id_ != rhs.id_) {
141109 return false;
141110 }
141111 return EqualTypeInfo(rhs);
141112}

◆ operator!=()

bool duckdb::LogicalType::operator!= ( const LogicalType & rhs) const
inline
3001 {
3002 return !(*this == rhs);
3003 }

◆ Serialize()

void duckdb::LogicalType::Serialize ( Serializer & serializer) const
140404 {
140405 // Serialize geometry as old extension geometry type if required
140406 if (id_ == LogicalTypeId::GEOMETRY && !serializer.ShouldSerialize(7)) {
140407 // This will drop the CRS information, but that's better than throwing an error.
140408 auto legacy_geom = Geometry::GetSpatialGeometryType();
140409 legacy_geom.Serialize(serializer);
140410 return;
140411 }
140412
140413 // This is a UNBOUND type and we are writing to older storage.
140414 // 1. try to default-bind into a concrete logical type, and serialize that
140415 // 2. if that fails, serialize normally, in which case the UNBOUND_TYPE_INFO will try to
140416 // write itself as an old-style USER type.
140417 if (id_ == LogicalTypeId::UNBOUND && !serializer.ShouldSerialize(7)) {
140418 try {
140419 auto bound_type = UnboundType::TryDefaultBind(*this);
140420 if (bound_type.id() != LogicalTypeId::INVALID && bound_type.id() != LogicalTypeId::UNBOUND) {
140421 bound_type.Serialize(serializer);
140422 return;
140423 }
140424 } catch (...) {
140425 // Ignore errors, just try to write as a USER type instead
140426 }
140427 }
140428 serializer.WriteProperty<LogicalTypeId>(100, "id", id_);
140429 serializer.WritePropertyWithDefault<shared_ptr<ExtraTypeInfo>>(101, "type_info", type_info_);
140430}
static LogicalType GetSpatialGeometryType()
Get legacy geometry type (pre v1.5).
Definition duckdb.cpp:120729
LogicalTypeId
Definition duckdb.hpp:2860

◆ Deserialize()

LogicalType duckdb::LogicalType::Deserialize ( Deserializer & deserializer)
static
140432 {
140433 auto id = deserializer.ReadProperty<LogicalTypeId>(100, "id");
140434 auto type_info = deserializer.ReadPropertyWithDefault<shared_ptr<ExtraTypeInfo>>(101, "type_info");
140435
140436 LogicalType result(id, std::move(type_info));
140437
140438 if (Geometry::IsSpatialGeometryType(result)) {
140439 // This is a legacy geometry type, deserialize as geometry
140440 return LogicalType::GEOMETRY();
140441 }
140442
140443 return result;
140444}
static bool IsSpatialGeometryType(const LogicalType &type)
Check for legayc geometry type (pre v1.5).
Definition duckdb.cpp:120735

◆ TypeIsTimestamp() [1/2]

bool duckdb::LogicalType::TypeIsTimestamp ( LogicalTypeId id)
inlinestatic
3008 {
3009 return (id == LogicalTypeId::TIMESTAMP || id == LogicalTypeId::TIMESTAMP_MS ||
3010 id == LogicalTypeId::TIMESTAMP_NS || id == LogicalTypeId::TIMESTAMP_SEC ||
3011 id == LogicalTypeId::TIMESTAMP_TZ);
3012 }

◆ TypeIsTimestamp() [2/2]

bool duckdb::LogicalType::TypeIsTimestamp ( const LogicalType & type)
inlinestatic
3013 {
3014 return TypeIsTimestamp(type.id());
3015 }

◆ ToString()

string duckdb::LogicalType::ToString ( ) const
139433 {
139434 if (id_ != LogicalTypeId::UNBOUND) {
139435 auto alias = GetAlias();
139436 if (!alias.empty()) {
139437 if (HasExtensionInfo()) {
139438 auto &ext_info = *GetExtensionInfo();
139439 alias += TypeModifierListToString(ext_info.modifiers);
139440 }
139441 return alias;
139442 }
139443 }
139444 switch (id_) {
139445 case LogicalTypeId::STRUCT: {
139446 if (!type_info_) {
139447 return "STRUCT";
139448 }
139449 auto is_unnamed = StructType::IsUnnamed(*this);
139450 auto &child_types = StructType::GetChildTypes(*this);
139451 string ret = "STRUCT(";
139452 for (size_t i = 0; i < child_types.size(); i++) {
139453 if (is_unnamed) {
139454 ret += child_types[i].second.ToString();
139455 } else {
139456 ret += StringUtil::Format("%s %s", SQLIdentifier(child_types[i].first), child_types[i].second);
139457 }
139458 if (i < child_types.size() - 1) {
139459 ret += ", ";
139460 }
139461 }
139462 ret += ")";
139463 return ret;
139464 }
139465 case LogicalTypeId::LIST: {
139466 if (!type_info_) {
139467 return "LIST";
139468 }
139469 return ListType::GetChildType(*this).ToString() + "[]";
139470 }
139471 case LogicalTypeId::MAP: {
139472 if (!type_info_) {
139473 return "MAP";
139474 }
139475 auto &key_type = MapType::KeyType(*this);
139476 auto &value_type = MapType::ValueType(*this);
139477 return "MAP(" + key_type.ToString() + ", " + value_type.ToString() + ")";
139478 }
139479 case LogicalTypeId::UNION: {
139480 if (!type_info_) {
139481 return "UNION";
139482 }
139483 string ret = "UNION(";
139484 size_t count = UnionType::GetMemberCount(*this);
139485 for (size_t i = 0; i < count; i++) {
139486 auto member_name = UnionType::GetMemberName(*this, i);
139487 auto member_type = UnionType::GetMemberType(*this, i).ToString();
139488 ret += StringUtil::Format("%s %s", SQLIdentifier(member_name), member_type);
139489 if (i < count - 1) {
139490 ret += ", ";
139491 }
139492 }
139493 ret += ")";
139494 return ret;
139495 }
139496 case LogicalTypeId::ARRAY: {
139497 if (!type_info_) {
139498 return "ARRAY";
139499 }
139500 auto size = ArrayType::GetSize(*this);
139501 if (size == 0) {
139502 return ArrayType::GetChildType(*this).ToString() + "[ANY]";
139503 } else {
139504 return ArrayType::GetChildType(*this).ToString() + "[" + to_string(size) + "]";
139505 }
139506 }
139507 case LogicalTypeId::DECIMAL: {
139508 if (!type_info_) {
139509 return "DECIMAL";
139510 }
139511 auto width = DecimalType::GetWidth(*this);
139512 auto scale = DecimalType::GetScale(*this);
139513 if (width == 0) {
139514 return "DECIMAL";
139515 }
139516 return StringUtil::Format("DECIMAL(%d,%d)", width, scale);
139517 }
139518 case LogicalTypeId::ENUM: {
139519 string ret = "ENUM(";
139520 for (idx_t i = 0; i < EnumType::GetSize(*this); i++) {
139521 if (i > 0) {
139522 ret += ", ";
139523 }
139524 ret += KeywordHelper::WriteQuoted(EnumType::GetString(*this, i).GetString(), '\'');
139525 }
139526 ret += ")";
139527 return ret;
139528 }
139529 case LogicalTypeId::UNBOUND: {
139530 if (!type_info_) {
139531 return "UNBOUND";
139532 }
139533
139534 auto &expr = UnboundType::GetTypeExpression(*this);
139535 if (expr->type != ExpressionType::TYPE) {
139536 return "(" + expr->ToString() + ")";
139537 } else {
139538 return expr->ToString();
139539 }
139540 }
139541 case LogicalTypeId::AGGREGATE_STATE: {
139542 return AggregateStateType::GetTypeName(*this);
139543 }
139544 case LogicalTypeId::SQLNULL: {
139545 return "\"NULL\"";
139546 }
139547 case LogicalTypeId::TEMPLATE: {
139548 if (!type_info_) {
139549 return "T";
139550 }
139551 return TemplateType::GetName(*this);
139552 }
139553 case LogicalTypeId::GEOMETRY: {
139554 if (!type_info_ || !GeoType::HasCRS(*this)) {
139555 return "GEOMETRY";
139556 }
139557 auto &crs = GeoType::GetCRS(*this);
139558 auto crs_text = KeywordHelper::WriteQuoted(crs.GetDefinition(), '\'');
139559 return StringUtil::Format("GEOMETRY(%s)", crs_text);
139560 }
139561 default:
139562 return EnumUtil::ToString(id_);
139563 }
139564}
static string WriteQuoted(const string &text, char quote='\'')
Writes a string that is quoted.
Definition duckdb.cpp:338028
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002
std::string to_string(const T &value)
Definition duckdb.cpp:19425
R value_type
GOpaque< Size > size(const GMat &src)
void scale(cv::Mat &mat, const cv::Mat &range, const T min, const T max)
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ IsIntegral()

bool duckdb::LogicalType::IsIntegral ( ) const
139581 {
139582 switch (id_) {
139583 case LogicalTypeId::TINYINT:
139584 case LogicalTypeId::SMALLINT:
139585 case LogicalTypeId::INTEGER:
139586 case LogicalTypeId::BIGINT:
139587 case LogicalTypeId::UTINYINT:
139588 case LogicalTypeId::USMALLINT:
139589 case LogicalTypeId::UINTEGER:
139590 case LogicalTypeId::UBIGINT:
139591 case LogicalTypeId::HUGEINT:
139592 case LogicalTypeId::UHUGEINT:
139593 return true;
139594 default:
139595 return false;
139596 }
139597}

◆ IsFloating()

bool duckdb::LogicalType::IsFloating ( ) const
139627 {
139628 switch (id_) {
139629 case LogicalTypeId::FLOAT:
139630 case LogicalTypeId::DOUBLE:
139631 return true;
139632 default:
139633 return false;
139634 }
139635}

◆ IsNumeric() [1/2]

bool duckdb::LogicalType::IsNumeric ( ) const
139637 {
139638 return IsNumeric(id_);
139639}

◆ IsNumeric() [2/2]

bool duckdb::LogicalType::IsNumeric ( LogicalTypeId type)
static
139641 {
139642 switch (type) {
139643 case LogicalTypeId::TINYINT:
139644 case LogicalTypeId::SMALLINT:
139645 case LogicalTypeId::INTEGER:
139646 case LogicalTypeId::BIGINT:
139647 case LogicalTypeId::HUGEINT:
139648 case LogicalTypeId::FLOAT:
139649 case LogicalTypeId::DOUBLE:
139650 case LogicalTypeId::DECIMAL:
139651 case LogicalTypeId::UTINYINT:
139652 case LogicalTypeId::USMALLINT:
139653 case LogicalTypeId::UINTEGER:
139654 case LogicalTypeId::UBIGINT:
139655 case LogicalTypeId::UHUGEINT:
139656 return true;
139657 default:
139658 return false;
139659 }
139660}

◆ IsTemporal()

bool duckdb::LogicalType::IsTemporal ( ) const
139662 {
139663 switch (id_) {
139664 case LogicalTypeId::DATE:
139665 case LogicalTypeId::TIME:
139666 case LogicalTypeId::TIME_NS:
139667 case LogicalTypeId::TIMESTAMP:
139668 case LogicalTypeId::TIME_TZ:
139669 case LogicalTypeId::TIMESTAMP_TZ:
139670 case LogicalTypeId::TIMESTAMP_SEC:
139671 case LogicalTypeId::TIMESTAMP_MS:
139673 return true;
139674 default:
139675 return false;
139676 }
139677}
@ TIMESTAMP_NS
us
Definition duckdb.hpp:2886

◆ Hash()

hash_t duckdb::LogicalType::Hash ( ) const
139093 {
139094 return duckdb::Hash<uint8_t>((uint8_t)id_);
139095}

◆ SetAlias()

void duckdb::LogicalType::SetAlias ( string alias)
140467 {
140468 if (!type_info_) {
140469 type_info_ = make_shared_ptr<ExtraTypeInfo>(ExtraTypeInfoType::GENERIC_TYPE_INFO, std::move(alias));
140470 } else {
140471 type_info_->alias = std::move(alias);
140472 }
140473}

◆ HasAlias()

bool duckdb::LogicalType::HasAlias ( ) const
140482 {
140483 if (type_info_ && !type_info_->alias.empty()) {
140484 return true;
140485 }
140486 return false;
140487}

◆ GetAlias()

string duckdb::LogicalType::GetAlias ( ) const
140475 {
140476 if (type_info_) {
140477 return type_info_->alias;
140478 }
140479 return string();
140480}

◆ HasExtensionInfo()

bool duckdb::LogicalType::HasExtensionInfo ( ) const
140489 {
140490 if (type_info_ && type_info_->extension_info) {
140491 return true;
140492 }
140493 return false;
140494}

◆ GetExtensionInfo() [1/2]

optional_ptr< const ExtensionTypeInfo > duckdb::LogicalType::GetExtensionInfo ( ) const
140496 {
140497 if (type_info_ && type_info_->extension_info) {
140498 return type_info_->extension_info.get();
140499 }
140500 return nullptr;
140501}

◆ GetExtensionInfo() [2/2]

optional_ptr< ExtensionTypeInfo > duckdb::LogicalType::GetExtensionInfo ( )
140503 {
140504 if (type_info_ && type_info_->extension_info) {
140505 return type_info_->extension_info.get();
140506 }
140507 return nullptr;
140508}

◆ SetExtensionInfo()

void duckdb::LogicalType::SetExtensionInfo ( unique_ptr< ExtensionTypeInfo > info)
140510 {
140511 if (!type_info_) {
140512 type_info_ = make_shared_ptr<ExtraTypeInfo>(ExtraTypeInfoType::GENERIC_TYPE_INFO);
140513 }
140514 type_info_->extension_info = std::move(info);
140515}

◆ MaxLogicalType()

LogicalType duckdb::LogicalType::MaxLogicalType ( ClientContext & context,
const LogicalType & left,
const LogicalType & right )
static

Returns the maximum logical type when combining the two types - or throws an exception if combining is not possible.

140334 {
140335 LogicalType result;
140336 if (!TryGetMaxLogicalType(context, left, right, result)) {
140337 throw NotImplementedException("Cannot combine types %s and %s - an explicit cast is required", left.ToString(),
140338 right.ToString());
140339 }
140340 return result;
140341}

◆ TryGetMaxLogicalType()

bool duckdb::LogicalType::TryGetMaxLogicalType ( ClientContext & context,
const LogicalType & left,
const LogicalType & right,
LogicalType & result )
static
140206 {
140207 if (Settings::Get<OldImplicitCastingSetting>(context)) {
140208 result = LogicalType::ForceMaxLogicalType(left, right);
140209 return true;
140210 }
140211 return TryGetMaxLogicalTypeUnchecked(left, right, result);
140212}
static DUCKDB_API LogicalType ForceMaxLogicalType(const LogicalType &left, const LogicalType &right)
Forcibly returns a maximum logical type - similar to MaxLogicalType but never throws....
Definition duckdb.cpp:140319

◆ TryGetMaxLogicalTypeUnchecked()

bool duckdb::LogicalType::TryGetMaxLogicalTypeUnchecked ( const LogicalType & left,
const LogicalType & right,
LogicalType & result )
static
140215 {
140216 return TryGetMaxLogicalTypeInternal<TryGetTypeOperation>(left, right, result);
140217}

◆ ForceMaxLogicalType()

Forcibly returns a maximum logical type - similar to MaxLogicalType but never throws. As a fallback either left or right are returned.

140319 {
140320 LogicalType result;
140321 if (TryGetMaxLogicalTypeInternal<ForceGetTypeOperation>(left, right, result)) {
140322 return result;
140323 }
140324 // we prefer the type with the highest score
140325 auto left_score = GetLogicalTypeScore(left);
140326 auto right_score = GetLogicalTypeScore(right);
140327 if (left_score < right_score) {
140328 return right;
140329 } else {
140330 return left;
140331 }
140332}

◆ NormalizeType()

Normalize a type - removing literals.

139907 {
139908 switch (type.id()) {
139909 case LogicalTypeId::STRING_LITERAL:
139910 return LogicalType::VARCHAR;
139911 case LogicalTypeId::INTEGER_LITERAL:
139912 return IntegerLiteral::GetType(type);
139913 case LogicalTypeId::UNKNOWN:
139914 throw ParameterNotResolvedException();
139915 default:
139916 return type;
139917 }
139918}
static DUCKDB_API LogicalType GetType(const LogicalType &type)
Returns the type that this integer literal "prefers".
Definition duckdb.cpp:140898

◆ GetDecimalProperties()

bool duckdb::LogicalType::GetDecimalProperties ( uint8_t & width,
uint8_t & scale ) const

Gets the decimal properties of a numeric type. Fails if the type is not numeric.

139765 {
139766 switch (id_) {
139767 case LogicalTypeId::SQLNULL:
139768 width = 0;
139769 scale = 0;
139770 break;
139771 case LogicalTypeId::BOOLEAN:
139772 width = 1;
139773 scale = 0;
139774 break;
139775 case LogicalTypeId::TINYINT:
139776 // tinyint: [-127, 127] = DECIMAL(3,0)
139777 width = 3;
139778 scale = 0;
139779 break;
139780 case LogicalTypeId::SMALLINT:
139781 // smallint: [-32767, 32767] = DECIMAL(5,0)
139782 width = 5;
139783 scale = 0;
139784 break;
139785 case LogicalTypeId::INTEGER:
139786 // integer: [-2147483647, 2147483647] = DECIMAL(10,0)
139787 width = 10;
139788 scale = 0;
139789 break;
139790 case LogicalTypeId::BIGINT:
139791 // bigint: [-9223372036854775807, 9223372036854775807] = DECIMAL(19,0)
139792 width = 19;
139793 scale = 0;
139794 break;
139795 case LogicalTypeId::UTINYINT:
139796 // UInt8 — [0 : 255]
139797 width = 3;
139798 scale = 0;
139799 break;
139800 case LogicalTypeId::USMALLINT:
139801 // UInt16 — [0 : 65535]
139802 width = 5;
139803 scale = 0;
139804 break;
139805 case LogicalTypeId::UINTEGER:
139806 // UInt32 — [0 : 4294967295]
139807 width = 10;
139808 scale = 0;
139809 break;
139810 case LogicalTypeId::UBIGINT:
139811 // UInt64 — [0 : 18446744073709551615]
139812 width = 20;
139813 scale = 0;
139814 break;
139815 case LogicalTypeId::HUGEINT:
139816 // hugeint: max size decimal (38, 0)
139817 // note that a hugeint is not guaranteed to fit in this
139818 width = 38;
139819 scale = 0;
139820 break;
139821 case LogicalTypeId::UHUGEINT:
139822 // hugeint: max size decimal (38, 0)
139823 // note that a uhugeint is not guaranteed to fit in this
139824 width = 38;
139825 scale = 0;
139826 break;
139827 case LogicalTypeId::DECIMAL:
139828 width = DecimalType::GetWidth(*this);
139829 scale = DecimalType::GetScale(*this);
139830 break;
139831 case LogicalTypeId::INTEGER_LITERAL:
139832 return IntegerLiteral::GetType(*this).GetDecimalProperties(width, scale);
139833 default:
139834 // Nonsense values to ensure initialization
139835 width = 255u;
139836 scale = 255u;
139837 // FIXME(carlo): This should be probably a throw, requires checkign the various call-sites
139838 return false;
139839 }
139840 return true;
139841}
DUCKDB_API bool GetDecimalProperties(uint8_t &width, uint8_t &scale) const
Gets the decimal properties of a numeric type. Fails if the type is not numeric.
Definition duckdb.cpp:139765

◆ Verify()

void duckdb::LogicalType::Verify ( ) const
140343 {
140344#ifdef DEBUG
140345 switch (id_) {
140346 case LogicalTypeId::DECIMAL:
140347 D_ASSERT(DecimalType::GetWidth(*this) >= 1 && DecimalType::GetWidth(*this) <= Decimal::MAX_WIDTH_DECIMAL);
140348 D_ASSERT(DecimalType::GetScale(*this) <= DecimalType::GetWidth(*this));
140349 break;
140350 case LogicalTypeId::STRUCT: {
140351 // verify child types
140352 case_insensitive_set_t child_names;
140353 bool all_empty = true;
140354 for (auto &entry : StructType::GetChildTypes(*this)) {
140355 if (entry.first.empty()) {
140356 D_ASSERT(all_empty);
140357 } else {
140358 // check for duplicate struct names
140359 all_empty = false;
140360 auto existing_entry = child_names.find(entry.first);
140361 D_ASSERT(existing_entry == child_names.end());
140362 child_names.insert(entry.first);
140363 }
140364 entry.second.Verify();
140365 }
140366 break;
140367 }
140368 case LogicalTypeId::LIST:
140369 ListType::GetChildType(*this).Verify();
140370 break;
140371 case LogicalTypeId::MAP: {
140372 MapType::KeyType(*this).Verify();
140373 MapType::ValueType(*this).Verify();
140374 break;
140375 }
140376 default:
140377 break;
140378 }
140379#endif
140380}

◆ IsSigned()

bool duckdb::LogicalType::IsSigned ( ) const
139599 {
139600 switch (id_) {
139601 case LogicalTypeId::TINYINT:
139602 case LogicalTypeId::SMALLINT:
139603 case LogicalTypeId::INTEGER:
139604 case LogicalTypeId::BIGINT:
139605 case LogicalTypeId::HUGEINT:
139606 return true;
139607 default:
139608 break;
139609 }
139610 return false;
139611}

◆ IsUnsigned()

bool duckdb::LogicalType::IsUnsigned ( ) const
139613 {
139614 switch (id_) {
139615 case LogicalTypeId::UTINYINT:
139616 case LogicalTypeId::USMALLINT:
139617 case LogicalTypeId::UINTEGER:
139618 case LogicalTypeId::UBIGINT:
139619 case LogicalTypeId::UHUGEINT:
139620 return true;
139621 default:
139622 break;
139623 }
139624 return false;
139625}

◆ IsValid()

bool duckdb::LogicalType::IsValid ( ) const
139679 {
139680 return id() != LogicalTypeId::INVALID && id() != LogicalTypeId::UNKNOWN;
139681}

◆ IsComplete()

bool duckdb::LogicalType::IsComplete ( ) const
139683 {
139684 // Check if type does not contain incomplete types
139685 return !TypeVisitor::Contains(*this, [](const LogicalType &type) {
139686 switch (type.id()) {
139687 case LogicalTypeId::INVALID:
139688 case LogicalTypeId::UNKNOWN:
139689 case LogicalTypeId::ANY:
139690 case LogicalTypeId::TEMPLATE:
139691 return true; // These are incomplete by default
139692 case LogicalTypeId::LIST:
139693 case LogicalTypeId::MAP:
139694 if (!type.AuxInfo() || type.AuxInfo()->type != ExtraTypeInfoType::LIST_TYPE_INFO) {
139695 return true; // Missing or incorrect type info
139696 }
139697 break;
139698 case LogicalTypeId::STRUCT:
139699 case LogicalTypeId::UNION:
139700 case LogicalTypeId::VARIANT:
139701 if (!type.AuxInfo() || type.AuxInfo()->type != ExtraTypeInfoType::STRUCT_TYPE_INFO) {
139702 return true; // Missing or incorrect type info
139703 }
139704 break;
139705 case LogicalTypeId::ARRAY:
139706 if (!type.AuxInfo() || type.AuxInfo()->type != ExtraTypeInfoType::ARRAY_TYPE_INFO) {
139707 return true; // Missing or incorrect type info
139708 }
139709 break;
139710 case LogicalTypeId::DECIMAL:
139711 if (!type.AuxInfo() || type.AuxInfo()->type != ExtraTypeInfoType::DECIMAL_TYPE_INFO) {
139712 return true; // Missing or incorrect type info
139713 }
139714 break;
139715 case LogicalTypeId::ENUM:
139716 if (!type.AuxInfo() || type.AuxInfo()->type != ExtraTypeInfoType::ENUM_TYPE_INFO) {
139717 return true; // Missing or incorrect type info
139718 }
139719 break;
139720 default:
139721 return false;
139722 }
139723
139724 // Type has type info, check if it is complete
139725 D_ASSERT(type.AuxInfo());
139726 switch (type.AuxInfo()->type) {
139727 case ExtraTypeInfoType::STRUCT_TYPE_INFO:
139728 return type.AuxInfo()->Cast<StructTypeInfo>().child_types.empty(); // Cannot be empty
139729 case ExtraTypeInfoType::DECIMAL_TYPE_INFO:
139730 return DecimalType::GetWidth(type) >= 1 && DecimalType::GetWidth(type) <= Decimal::MAX_WIDTH_DECIMAL &&
139731 DecimalType::GetScale(type) <= DecimalType::GetWidth(type);
139732 default:
139733 return false; // Nested types are checked by TypeVisitor recursion
139734 }
139735 });
139736}

◆ IsTemplated()

bool duckdb::LogicalType::IsTemplated ( ) const
139738 {
139739 return TypeVisitor::Contains(*this, LogicalTypeId::TEMPLATE);
139740}

◆ SupportsRegularUpdate()

True, if this type supports in-place updates.

139742 {
139743 switch (id()) {
139744 case LogicalTypeId::LIST:
139745 case LogicalTypeId::ARRAY:
139746 case LogicalTypeId::MAP:
139747 case LogicalTypeId::UNION:
139748 case LogicalTypeId::VARIANT:
139749 case LogicalTypeId::GEOMETRY: // If geometry is shredded, its parts (lists/structs) can't be regularly updated.
139750 return false;
139751 case LogicalTypeId::STRUCT: {
139752 auto &child_types = StructType::GetChildTypes(*this);
139753 for (auto &entry : child_types) {
139754 if (!entry.second.SupportsRegularUpdate()) {
139755 return false;
139756 }
139757 }
139758 return true;
139759 }
139760 default:
139761 return true;
139762 }
139763}

◆ GetInternalType()

PhysicalType duckdb::LogicalType::GetInternalType ( )
private
139097 {
139098 switch (id_) {
139099 case LogicalTypeId::BOOLEAN:
139100 return PhysicalType::BOOL;
139101 case LogicalTypeId::TINYINT:
139102 return PhysicalType::INT8;
139103 case LogicalTypeId::UTINYINT:
139104 return PhysicalType::UINT8;
139105 case LogicalTypeId::SMALLINT:
139106 return PhysicalType::INT16;
139107 case LogicalTypeId::USMALLINT:
139108 return PhysicalType::UINT16;
139109 case LogicalTypeId::SQLNULL:
139110 case LogicalTypeId::DATE:
139111 case LogicalTypeId::INTEGER:
139112 return PhysicalType::INT32;
139113 case LogicalTypeId::UINTEGER:
139114 return PhysicalType::UINT32;
139115 case LogicalTypeId::BIGINT:
139116 case LogicalTypeId::TIME:
139117 case LogicalTypeId::TIME_NS:
139118 case LogicalTypeId::TIMESTAMP:
139119 case LogicalTypeId::TIMESTAMP_SEC:
139121 case LogicalTypeId::TIMESTAMP_MS:
139122 case LogicalTypeId::TIME_TZ:
139123 case LogicalTypeId::TIMESTAMP_TZ:
139124 return PhysicalType::INT64;
139125 case LogicalTypeId::UBIGINT:
139126 return PhysicalType::UINT64;
139127 case LogicalTypeId::UHUGEINT:
139128 return PhysicalType::UINT128;
139129 case LogicalTypeId::HUGEINT:
139130 case LogicalTypeId::UUID:
139131 return PhysicalType::INT128;
139132 case LogicalTypeId::FLOAT:
139133 return PhysicalType::FLOAT;
139134 case LogicalTypeId::DOUBLE:
139135 return PhysicalType::DOUBLE;
139136 case LogicalTypeId::DECIMAL: {
139137 if (!type_info_) {
139138 return PhysicalType::INVALID;
139139 }
139140 auto width = DecimalType::GetWidth(*this);
139141 if (width <= Decimal::MAX_WIDTH_INT16) {
139142 return PhysicalType::INT16;
139143 } else if (width <= Decimal::MAX_WIDTH_INT32) {
139144 return PhysicalType::INT32;
139145 } else if (width <= Decimal::MAX_WIDTH_INT64) {
139146 return PhysicalType::INT64;
139147 } else if (width <= Decimal::MAX_WIDTH_INT128) {
139148 return PhysicalType::INT128;
139149 } else {
139150 throw InternalException("Decimal has a width of %d which is bigger than the maximum supported width of %d",
139151 width, DecimalType::MaxWidth());
139152 }
139153 }
139154 case LogicalTypeId::BIGNUM:
139155 case LogicalTypeId::VARCHAR:
139156 case LogicalTypeId::CHAR:
139157 case LogicalTypeId::BLOB:
139158 case LogicalTypeId::BIT:
139159 case LogicalTypeId::TYPE:
139160 return PhysicalType::VARCHAR;
139161 case LogicalTypeId::INTERVAL:
139162 return PhysicalType::INTERVAL;
139163 case LogicalTypeId::UNION:
139164 case LogicalTypeId::VARIANT:
139165 case LogicalTypeId::STRUCT:
139166 return PhysicalType::STRUCT;
139167 case LogicalTypeId::LIST:
139168 case LogicalTypeId::MAP:
139169 return PhysicalType::LIST;
139170 case LogicalTypeId::ARRAY:
139171 return PhysicalType::ARRAY;
139172 case LogicalTypeId::POINTER:
139173 // LCOV_EXCL_START
139174 if (sizeof(uintptr_t) == sizeof(uint32_t)) {
139175 return PhysicalType::UINT32;
139176 } else if (sizeof(uintptr_t) == sizeof(uint64_t)) {
139177 return PhysicalType::UINT64;
139178 } else {
139179 throw InternalException("Unsupported pointer size");
139180 }
139181 // LCOV_EXCL_STOP
139182 case LogicalTypeId::VALIDITY:
139183 return PhysicalType::BIT;
139184 case LogicalTypeId::ENUM: {
139185 if (!type_info_) {
139186 return PhysicalType::INVALID;
139187 }
139188 return EnumType::GetPhysicalType(*this);
139189 }
139190 case LogicalTypeId::TABLE:
139191 case LogicalTypeId::LAMBDA:
139192 case LogicalTypeId::ANY:
139193 case LogicalTypeId::INVALID:
139194 case LogicalTypeId::UNKNOWN:
139195 case LogicalTypeId::STRING_LITERAL:
139196 case LogicalTypeId::INTEGER_LITERAL:
139197 case LogicalTypeId::TEMPLATE:
139198 return PhysicalType::INVALID;
139199 case LogicalTypeId::UNBOUND:
139200 return PhysicalType::UNKNOWN;
139201 case LogicalTypeId::AGGREGATE_STATE:
139202 return PhysicalType::VARCHAR;
139203 case LogicalTypeId::GEOMETRY:
139204 return PhysicalType::VARCHAR;
139205 default:
139206 throw InternalException("Invalid LogicalType %s", ToString());
139207 }
139208}
@ UINT32
Unsigned 32-bit little-endian integer.
Definition duckdb.hpp:2758
@ INTERVAL
YEAR_MONTH or DAY_TIME interval in SQL style.
Definition duckdb.hpp:2806
@ LIST
A list of some logical data type.
Definition duckdb.hpp:2813
@ UINT16
Unsigned 16-bit little-endian integer.
Definition duckdb.hpp:2752
@ 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
@ UINT64
Unsigned 64-bit little-endian integer.
Definition duckdb.hpp:2764
@ BOOL
Boolean as 8 bit "bool" value.
Definition duckdb.hpp:2743
@ STRUCT
Struct of logical types.
Definition duckdb.hpp:2816
@ BIT
Boolean as 1 bit, LSB bit-packed ordering.
Definition duckdb.hpp:2852
@ VARCHAR
DuckDB Extensions.
Definition duckdb.hpp:2847
@ FLOAT
4-byte floating point value
Definition duckdb.hpp:2773
@ UINT8
Unsigned 8-bit little-endian integer.
Definition duckdb.hpp:2746
@ INT8
Signed 8-bit little-endian integer.
Definition duckdb.hpp:2749
@ DOUBLE
8-byte floating point value
Definition duckdb.hpp:2776

◆ DECIMAL()

LogicalType duckdb::LogicalType::DECIMAL ( uint8_t width,
uint8_t scale )
static
140538 {
140539 D_ASSERT(width >= scale);
140540 auto type_info = make_shared_ptr<DecimalTypeInfo>(width, scale);
140541 return LogicalType(LogicalTypeId::DECIMAL, std::move(type_info));
140542}

◆ VARCHAR_COLLATION()

LogicalType duckdb::LogicalType::VARCHAR_COLLATION ( string collation)
static
140561 { // NOLINT
140562 auto string_info = make_shared_ptr<StringTypeInfo>(std::move(collation));
140563 return LogicalType(LogicalTypeId::VARCHAR, std::move(string_info));
140564}

◆ LIST()

LogicalType duckdb::LogicalType::LIST ( const LogicalType & child)
static
140576 {
140577 auto info = make_shared_ptr<ListTypeInfo>(child);
140578 return LogicalType(LogicalTypeId::LIST, std::move(info));
140579}

◆ STRUCT()

LogicalType duckdb::LogicalType::STRUCT ( child_list_t< LogicalType > children)
static
140649 {
140650 auto info = make_shared_ptr<StructTypeInfo>(std::move(children));
140651 return LogicalType(LogicalTypeId::STRUCT, std::move(info));
140652}

◆ AGGREGATE_STATE()

LogicalType duckdb::LogicalType::AGGREGATE_STATE ( aggregate_state_t state_type)
static
140654 { // NOLINT
140655 auto info = make_shared_ptr<AggregateStateTypeInfo>(std::move(state_type));
140656 return LogicalType(LogicalTypeId::AGGREGATE_STATE, std::move(info));
140657}

◆ MAP() [1/2]

LogicalType duckdb::LogicalType::MAP ( const LogicalType & child)
static
140662 {
140663 D_ASSERT(child_p.id() == LogicalTypeId::STRUCT);
140664 auto &children = StructType::GetChildTypes(child_p);
140665 D_ASSERT(children.size() == 2);
140666
140667 // We do this to enforce that for every MAP created, the keys are called "key"
140668 // and the values are called "value"
140669
140670 // This is done because for Vector the keys of the STRUCT are used in equality checks.
140671 // Vector::Reference will throw if the types don't match
140672 child_list_t<LogicalType> new_children(2);
140673 new_children[0] = children[0];
140674 new_children[0].first = "key";
140675
140676 new_children[1] = children[1];
140677 new_children[1].first = "value";
140678
140679 auto child = LogicalType::STRUCT(std::move(new_children));
140680 auto info = make_shared_ptr<ListTypeInfo>(child);
140681 return LogicalType(LogicalTypeId::MAP, std::move(info));
140682}

◆ MAP() [2/2]

LogicalType duckdb::LogicalType::MAP ( LogicalType key,
LogicalType value )
static
140684 {
140685 child_list_t<LogicalType> child_types;
140686 child_types.emplace_back("key", std::move(key));
140687 child_types.emplace_back("value", std::move(value));
140688 return LogicalType::MAP(LogicalType::STRUCT(child_types));
140689}

◆ UNION()

LogicalType duckdb::LogicalType::UNION ( child_list_t< LogicalType > members)
static
140704 {
140705 D_ASSERT(!members.empty());
140706 D_ASSERT(members.size() <= UnionType::MAX_UNION_MEMBERS);
140707 // union types always have a hidden "tag" field in front
140708 members.insert(members.begin(), {"", LogicalType::UTINYINT});
140709 auto info = make_shared_ptr<StructTypeInfo>(std::move(members));
140710 return LogicalType(LogicalTypeId::UNION, std::move(info));
140711}

◆ ARRAY()

LogicalType duckdb::LogicalType::ARRAY ( const LogicalType & child,
optional_idx index )
static
140855 {
140856 if (!size.IsValid()) {
140857 // Create an incomplete ARRAY type, used for binding
140858 auto info = make_shared_ptr<ArrayTypeInfo>(child, 0);
140859 return LogicalType(LogicalTypeId::ARRAY, std::move(info));
140860 } else {
140861 auto array_size = size.GetIndex();
140862 D_ASSERT(array_size > 0);
140863 D_ASSERT(array_size <= ArrayType::MAX_ARRAY_SIZE);
140864 auto info = make_shared_ptr<ArrayTypeInfo>(child, array_size);
140865 return LogicalType(LogicalTypeId::ARRAY, std::move(info));
140866 }
140867}

◆ ENUM() [1/2]

LogicalType duckdb::LogicalType::ENUM ( Vector & ordered_data,
idx_t size )
static
140755 {
140756 return EnumTypeInfo::CreateType(ordered_data, size);
140757}

◆ ENUM() [2/2]

LogicalType duckdb::LogicalType::ENUM ( const string & enum_name,
Vector & ordered_data,
idx_t size )
static
140759 {
140760 return LogicalType::ENUM(ordered_data, size);
140761}

◆ GEOMETRY() [1/3]

LogicalType duckdb::LogicalType::GEOMETRY ( )
static
140972 {
140973 return LogicalType(LogicalTypeId::GEOMETRY);
140974}

◆ GEOMETRY() [2/3]

LogicalType duckdb::LogicalType::GEOMETRY ( const string & crs)
static
140976 {
140977 if (crs.empty()) {
140978 return LogicalType::GEOMETRY();
140979 }
140980 auto info = make_shared_ptr<GeoTypeInfo>();
140981 info->crs = CoordinateReferenceSystem(crs);
140982 return LogicalType(LogicalTypeId::GEOMETRY, std::move(info));
140983}

◆ GEOMETRY() [3/3]

LogicalType duckdb::LogicalType::GEOMETRY ( const CoordinateReferenceSystem & crs)
static
140985 {
140986 auto info = make_shared_ptr<GeoTypeInfo>();
140987 info->crs = crs;
140988 return LogicalType(LogicalTypeId::GEOMETRY, std::move(info));
140989}

◆ ANY_PARAMS()

LogicalType duckdb::LogicalType::ANY_PARAMS ( LogicalType target,
idx_t cast_score = 5 )
static
140872 { // NOLINT
140873 auto type_info = make_shared_ptr<AnyTypeInfo>(std::move(target), cast_score);
140874 return LogicalType(LogicalTypeId::ANY, std::move(type_info));
140875}

◆ TEMPLATE()

LogicalType duckdb::LogicalType::TEMPLATE ( const string & name)
static
140933 {
140934 D_ASSERT(!name.empty());
140935 auto type_info = make_shared_ptr<TemplateTypeInfo>(name);
140936 return LogicalType(LogicalTypeId::TEMPLATE, std::move(type_info));
140937}

◆ VARIANT()

keys

children

values

data

140950 {
140951 child_list_t<LogicalType> children;
140953 children.emplace_back("keys", LogicalType::LIST(LogicalTypeId::VARCHAR));
140955 children.emplace_back("children",
140956 LogicalType::LIST(LogicalType::STRUCT(
140957 {{"keys_index", LogicalType::UINTEGER}, {"values_index", LogicalType::UINTEGER}})));
140959 children.emplace_back("values", LogicalType::LIST(LogicalType::STRUCT(
140960 {{"type_id", LogicalType::UTINYINT}, {"byte_offset", LogicalType::UINTEGER}})));
140962 children.emplace_back("data", LogicalType::BLOB);
140963
140964 auto info = make_shared_ptr<StructTypeInfo>(std::move(children));
140965 return LogicalType(LogicalTypeId::VARIANT, std::move(info));
140966}
Here is the caller graph for this function:

◆ INTEGER_LITERAL()

Integer literal of the specified value.

140922 { // NOLINT
140923 if (!constant.type().IsIntegral()) {
140924 throw InternalException("INTEGER_LITERAL can only be made from literals of integer types");
140925 }
140926 auto type_info = make_shared_ptr<IntegerLiteralTypeInfo>(constant);
140927 return LogicalType(LogicalTypeId::INTEGER_LITERAL, std::move(type_info));
140928}

◆ UNBOUND()

LogicalType duckdb::LogicalType::UNBOUND ( unique_ptr< ParsedExpression > expr)
static
140740 {
140741 auto info = make_shared_ptr<UnboundTypeInfo>(std::move(expr));
140742 return LogicalType(LogicalTypeId::UNBOUND, std::move(info));
140743}

◆ TYPE()

LogicalType duckdb::LogicalType::TYPE ( )
static
140748 {
140749 return LogicalType(LogicalTypeId::TYPE);
140750}

◆ Numeric()

const vector< LogicalType > duckdb::LogicalType::Numeric ( )
static

A list of all NUMERIC types (integral and floating point types).

139263 {
139264 vector<LogicalType> types = {LogicalType::TINYINT, LogicalType::SMALLINT, LogicalType::INTEGER,
139265 LogicalType::BIGINT, LogicalType::HUGEINT, LogicalType::FLOAT,
139266 LogicalType::DOUBLE, LogicalTypeId::DECIMAL, LogicalType::UTINYINT,
139267 LogicalType::USMALLINT, LogicalType::UINTEGER, LogicalType::UBIGINT,
139268 LogicalType::UHUGEINT};
139269 return types;
139270}

◆ Integral()

const vector< LogicalType > duckdb::LogicalType::Integral ( )
static

A list of all INTEGRAL types.

139272 {
139273 vector<LogicalType> types = {LogicalType::TINYINT, LogicalType::SMALLINT, LogicalType::INTEGER,
139274 LogicalType::BIGINT, LogicalType::HUGEINT, LogicalType::UTINYINT,
139275 LogicalType::USMALLINT, LogicalType::UINTEGER, LogicalType::UBIGINT,
139276 LogicalType::UHUGEINT};
139277 return types;
139278}

◆ Real()

const vector< LogicalType > duckdb::LogicalType::Real ( )
static

A list of all REAL types.

139280 {
139281 vector<LogicalType> types = {LogicalType::FLOAT, LogicalType::DOUBLE};
139282 return types;
139283}

◆ AllTypes()

const vector< LogicalType > duckdb::LogicalType::AllTypes ( )
static

A list of ALL SQL types.

139285 {
139286 vector<LogicalType> types = {
139287 LogicalTypeId::BOOLEAN, LogicalTypeId::TINYINT, LogicalTypeId::SMALLINT,
139288 LogicalTypeId::INTEGER, LogicalTypeId::BIGINT, LogicalTypeId::DATE,
139289 LogicalTypeId::TIME, LogicalTypeId::TIMESTAMP_SEC, LogicalTypeId::TIMESTAMP_MS,
139290 LogicalTypeId::TIMESTAMP, LogicalTypeId::TIMESTAMP_NS, LogicalTypeId::DECIMAL,
139291 LogicalTypeId::FLOAT, LogicalTypeId::DOUBLE, LogicalTypeId::CHAR,
139292 LogicalTypeId::VARCHAR, LogicalTypeId::BLOB, LogicalTypeId::INTERVAL,
139293 LogicalTypeId::UTINYINT, LogicalTypeId::USMALLINT, LogicalTypeId::UINTEGER,
139294 LogicalTypeId::UBIGINT, LogicalTypeId::TIMESTAMP_TZ, LogicalTypeId::TIME_TZ,
139295 LogicalTypeId::TIME_NS, LogicalTypeId::BIT, LogicalTypeId::BIGNUM,
139296 LogicalTypeId::UHUGEINT, LogicalTypeId::HUGEINT, LogicalTypeId::UUID,
139297 LogicalTypeId::GEOMETRY, LogicalTypeId::STRUCT, LogicalTypeId::LIST,
139298 LogicalTypeId::MAP, LogicalTypeId::ENUM, LogicalTypeId::UNION,
139299 LogicalTypeId::ARRAY, LogicalTypeId::VARIANT,
139300 };
139301 return types;
139302}

◆ JSON()

LogicalType duckdb::LogicalType::JSON ( )
static
140792 {
140793 auto json_type = LogicalType(LogicalTypeId::VARCHAR);
140794 json_type.SetAlias(JSON_TYPE_NAME);
140795 return json_type;
140796}
static constexpr auto JSON_TYPE_NAME
The JSON type lives in the JSON extension, but we need to define this here for special handling.
Definition duckdb.hpp:3141

◆ IsJSONType()

bool duckdb::LogicalType::IsJSONType ( ) const
140798 {
140799 return id() == LogicalTypeId::VARCHAR && HasAlias() && GetAlias() == JSON_TYPE_NAME;
140800}

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