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
duckdb::DefaultCasts Struct Reference

Static Public Member Functions

static DUCKDB_API BoundCastInfo GetDefaultCastFunction (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static DUCKDB_API bool NopCast (Vector &source, Vector &result, idx_t count, CastParameters &parameters)
static DUCKDB_API bool TryVectorNullCast (Vector &source, Vector &result, idx_t count, CastParameters &parameters)
static DUCKDB_API bool ReinterpretCast (Vector &source, Vector &result, idx_t count, CastParameters &parameters)

Static Private Member Functions

static BoundCastInfo BlobCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo BitCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo DateCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo DecimalCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo EnumCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo IntervalCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo ListCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo ArrayCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo NumericCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo MapCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo PointerCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo StringCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo StructCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo TimeCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo TimeNsCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo TimeTzCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo TimestampCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo TimestampTzCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo TimestampNsCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo TimestampMsCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo TimestampSecCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo UnionCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo VariantCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo UUIDCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo GeoCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo TypeCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo BignumCastSwitch (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo ImplicitToUnionCast (BindCastInput &input, const LogicalType &source, const LogicalType &target)
static BoundCastInfo ImplicitToVariantCast (BindCastInput &input, const LogicalType &source, const LogicalType &target)

Member Function Documentation

◆ GetDefaultCastFunction()

BoundCastInfo duckdb::DefaultCasts::GetDefaultCastFunction ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
static
213730 {
213731 D_ASSERT(source != target);
213732
213733 if (target.id() == LogicalTypeId::VARIANT) {
213734 return ImplicitToVariantCast(input, source, target);
213735 }
213736
213737 // then check if were casting to a union
213738 if (source.id() != LogicalTypeId::UNION && source.id() != LogicalTypeId::SQLNULL &&
213739 source.id() != LogicalTypeId::VARIANT && target.id() == LogicalTypeId::UNION) {
213740 return ImplicitToUnionCast(input, source, target);
213741 }
213742
213743 // else, switch on source type
213744 switch (source.id()) {
213745 case LogicalTypeId::BOOLEAN:
213746 case LogicalTypeId::TINYINT:
213747 case LogicalTypeId::SMALLINT:
213748 case LogicalTypeId::INTEGER:
213749 case LogicalTypeId::BIGINT:
213750 case LogicalTypeId::UTINYINT:
213751 case LogicalTypeId::USMALLINT:
213752 case LogicalTypeId::UINTEGER:
213753 case LogicalTypeId::UBIGINT:
213754 case LogicalTypeId::UHUGEINT:
213755 case LogicalTypeId::HUGEINT:
213756 case LogicalTypeId::FLOAT:
213757 case LogicalTypeId::DOUBLE:
213758 return NumericCastSwitch(input, source, target);
213759 case LogicalTypeId::POINTER:
213760 return PointerCastSwitch(input, source, target);
213761 case LogicalTypeId::UUID:
213762 return UUIDCastSwitch(input, source, target);
213763 case LogicalTypeId::DECIMAL:
213764 return DecimalCastSwitch(input, source, target);
213765 case LogicalTypeId::DATE:
213766 return DateCastSwitch(input, source, target);
213767 case LogicalTypeId::TIME:
213768 return TimeCastSwitch(input, source, target);
213769 case LogicalTypeId::TIME_NS:
213770 return TimeNsCastSwitch(input, source, target);
213771 case LogicalTypeId::TIME_TZ:
213772 return TimeTzCastSwitch(input, source, target);
213773 case LogicalTypeId::TIMESTAMP:
213774 return TimestampCastSwitch(input, source, target);
213775 case LogicalTypeId::TIMESTAMP_TZ:
213776 return TimestampTzCastSwitch(input, source, target);
213778 return TimestampNsCastSwitch(input, source, target);
213779 case LogicalTypeId::TIMESTAMP_MS:
213780 return TimestampMsCastSwitch(input, source, target);
213781 case LogicalTypeId::TIMESTAMP_SEC:
213782 return TimestampSecCastSwitch(input, source, target);
213783 case LogicalTypeId::INTERVAL:
213784 return IntervalCastSwitch(input, source, target);
213785 case LogicalTypeId::VARCHAR:
213786 return StringCastSwitch(input, source, target);
213787 case LogicalTypeId::BLOB:
213788 return BlobCastSwitch(input, source, target);
213789 case LogicalTypeId::BIT:
213790 return BitCastSwitch(input, source, target);
213791 case LogicalTypeId::SQLNULL:
213792 return NullTypeCast;
213793 case LogicalTypeId::MAP:
213794 return MapCastSwitch(input, source, target);
213795 case LogicalTypeId::STRUCT:
213796 return StructCastSwitch(input, source, target);
213797 case LogicalTypeId::LIST:
213798 return ListCastSwitch(input, source, target);
213799 case LogicalTypeId::UNION:
213800 return UnionCastSwitch(input, source, target);
213801 case LogicalTypeId::VARIANT:
213802 return VariantCastSwitch(input, source, target);
213803 case LogicalTypeId::ENUM:
213804 return EnumCastSwitch(input, source, target);
213805 case LogicalTypeId::ARRAY:
213806 return ArrayCastSwitch(input, source, target);
213807 case LogicalTypeId::GEOMETRY:
213808 return GeoCastSwitch(input, source, target);
213809 case LogicalTypeId::TYPE:
213810 return TypeCastSwitch(input, source, target);
213811 case LogicalTypeId::BIGNUM:
213812 return BignumCastSwitch(input, source, target);
213813 case LogicalTypeId::AGGREGATE_STATE:
213814 return AggregateStateToBlobCast;
213815 default:
213816 return nullptr;
213817 }
213818}
@ TIMESTAMP_NS
us
Definition duckdb.hpp:2886

◆ NopCast()

bool duckdb::DefaultCasts::NopCast ( Vector & source,
Vector & result,
idx_t count,
CastParameters & parameters )
static
213673 {
213674 result.Reference(source);
213675 return true;
213676}

◆ TryVectorNullCast()

bool duckdb::DefaultCasts::TryVectorNullCast ( Vector & source,
Vector & result,
idx_t count,
CastParameters & parameters )
static
213697 {
213698 bool success = true;
213699 if (VectorOperations::HasNotNull(source, count)) {
213700 HandleCastError::AssignError(TryCast::UnimplementedCastMessage(source.GetType(), result.GetType()), parameters);
213701 success = false;
213702 }
213703 result.SetVectorType(VectorType::CONSTANT_VECTOR);
213704 ConstantVector::SetNull(result, true);
213705 return success;
213706}

◆ ReinterpretCast()

bool duckdb::DefaultCasts::ReinterpretCast ( Vector & source,
Vector & result,
idx_t count,
CastParameters & parameters )
static
213708 {
213709 result.Reinterpret(source);
213710 return true;
213711}

◆ BlobCastSwitch()

BoundCastInfo duckdb::DefaultCasts::BlobCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
212963 {
212964 // now switch on the result type
212965 switch (target.id()) {
212966 case LogicalTypeId::VARCHAR:
212967 // blob to varchar
212968 return BoundCastInfo(&VectorCastHelpers::StringCast<string_t, duckdb::CastFromBlob>);
212969 case LogicalTypeId::UUID:
212970 // blob to uuid
212971 return BoundCastInfo(&VectorCastHelpers::TryCastStrictLoop<string_t, hugeint_t, duckdb::TryCastBlobToUUID>);
212972 case LogicalTypeId::AGGREGATE_STATE:
212973 return DefaultCasts::ReinterpretCast;
212974 case LogicalTypeId::BIT:
212975 return BoundCastInfo(&VectorCastHelpers::StringCast<string_t, duckdb::CastFromBlobToBit>);
212976
212977 default:
212978 return DefaultCasts::TryVectorNullCast;
212979 }
212980}

◆ BitCastSwitch()

BoundCastInfo duckdb::DefaultCasts::BitCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
212915 {
212916 // now switch on the result type
212917 switch (target.id()) {
212918 // Numerics
212919 case LogicalTypeId::BOOLEAN:
212920 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, bool, CastFromBitToNumeric>);
212921 case LogicalTypeId::TINYINT:
212922 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, int8_t, CastFromBitToNumeric>);
212923 case LogicalTypeId::SMALLINT:
212924 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, int16_t, CastFromBitToNumeric>);
212925 case LogicalTypeId::INTEGER:
212926 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, int32_t, CastFromBitToNumeric>);
212927 case LogicalTypeId::BIGINT:
212928 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, int64_t, CastFromBitToNumeric>);
212929 case LogicalTypeId::UTINYINT:
212930 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, uint8_t, CastFromBitToNumeric>);
212931 case LogicalTypeId::USMALLINT:
212932 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, uint16_t, CastFromBitToNumeric>);
212933 case LogicalTypeId::UINTEGER:
212934 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, uint32_t, CastFromBitToNumeric>);
212935 case LogicalTypeId::UBIGINT:
212936 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, uint64_t, CastFromBitToNumeric>);
212937 case LogicalTypeId::HUGEINT:
212938 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, hugeint_t, CastFromBitToNumeric>);
212939 case LogicalTypeId::UHUGEINT:
212940 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, uhugeint_t, CastFromBitToNumeric>);
212941 case LogicalTypeId::FLOAT:
212942 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, float, CastFromBitToNumeric>);
212943 case LogicalTypeId::DOUBLE:
212944 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, double, CastFromBitToNumeric>);
212945
212946 case LogicalTypeId::BLOB:
212947 return BoundCastInfo(&VectorCastHelpers::StringCast<string_t, CastFromBitToBlob>);
212948
212949 case LogicalTypeId::VARCHAR:
212950 return BoundCastInfo(&VectorCastHelpers::StringCast<string_t, CastFromBitToString>);
212951
212952 default:
212953 return DefaultCasts::TryVectorNullCast;
212954 }
212955}

◆ DateCastSwitch()

BoundCastInfo duckdb::DefaultCasts::DateCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
215537 {
215538 // now switch on the result type
215539 switch (target.id()) {
215540 case LogicalTypeId::VARCHAR:
215541 // date to varchar
215542 return BoundCastInfo(&VectorCastHelpers::StringCast<date_t, duckdb::StringCast>);
215543 case LogicalTypeId::TIMESTAMP:
215544 case LogicalTypeId::TIMESTAMP_TZ:
215545 // date to timestamp
215546 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<date_t, timestamp_t, duckdb::TryCast>);
215548 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<date_t, timestamp_ns_t, duckdb::TryCastToTimestampNS>);
215549 case LogicalTypeId::TIMESTAMP_SEC:
215550 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<date_t, timestamp_t, duckdb::TryCastToTimestampSec>);
215551 case LogicalTypeId::TIMESTAMP_MS:
215552 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<date_t, timestamp_t, duckdb::TryCastToTimestampMS>);
215553 default:
215554 return TryVectorNullCast;
215555 }
215556}

◆ DecimalCastSwitch()

BoundCastInfo duckdb::DefaultCasts::DecimalCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
213578 {
213579 // now switch on the result type
213580 switch (target.id()) {
213581 case LogicalTypeId::BOOLEAN:
213582 return FromDecimalCast<bool>;
213583 case LogicalTypeId::TINYINT:
213584 return FromDecimalCast<int8_t>;
213585 case LogicalTypeId::SMALLINT:
213586 return FromDecimalCast<int16_t>;
213587 case LogicalTypeId::INTEGER:
213588 return FromDecimalCast<int32_t>;
213589 case LogicalTypeId::BIGINT:
213590 return FromDecimalCast<int64_t>;
213591 case LogicalTypeId::UTINYINT:
213592 return FromDecimalCast<uint8_t>;
213593 case LogicalTypeId::USMALLINT:
213594 return FromDecimalCast<uint16_t>;
213595 case LogicalTypeId::UINTEGER:
213596 return FromDecimalCast<uint32_t>;
213597 case LogicalTypeId::UBIGINT:
213598 return FromDecimalCast<uint64_t>;
213599 case LogicalTypeId::HUGEINT:
213600 return FromDecimalCast<hugeint_t>;
213601 case LogicalTypeId::UHUGEINT:
213602 return FromDecimalCast<uhugeint_t>;
213603 case LogicalTypeId::DECIMAL: {
213604 // decimal to decimal cast
213605 // first we need to figure out the source and target internal types
213606 switch (source.InternalType()) {
213607 case PhysicalType::INT16:
213608 return DecimalDecimalCastSwitch<int16_t, NumericHelper>;
213609 case PhysicalType::INT32:
213610 return DecimalDecimalCastSwitch<int32_t, NumericHelper>;
213611 case PhysicalType::INT64:
213612 return DecimalDecimalCastSwitch<int64_t, NumericHelper>;
213613 case PhysicalType::INT128:
213614 return DecimalDecimalCastSwitch<hugeint_t, Hugeint>;
213615 default:
213616 throw NotImplementedException("Unimplemented internal type for decimal in decimal_decimal cast");
213617 }
213618 }
213619 case LogicalTypeId::FLOAT:
213620 return FromDecimalCast<float>;
213621 case LogicalTypeId::DOUBLE:
213622 return FromDecimalCast<double>;
213623 case LogicalTypeId::VARCHAR: {
213624 switch (source.InternalType()) {
213625 case PhysicalType::INT16:
213626 return DecimalToStringCast<int16_t>;
213627 case PhysicalType::INT32:
213628 return DecimalToStringCast<int32_t>;
213629 case PhysicalType::INT64:
213630 return DecimalToStringCast<int64_t>;
213631 case PhysicalType::INT128:
213632 return DecimalToStringCast<hugeint_t>;
213633 default:
213634 throw InternalException("Unimplemented internal decimal type");
213635 }
213636 }
213637 default:
213638 return DefaultCasts::TryVectorNullCast;
213639 }
213640}
@ 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

◆ EnumCastSwitch()

BoundCastInfo duckdb::DefaultCasts::EnumCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
213935 {
213936 auto enum_physical_type = source.InternalType();
213937
213938 if (target.id() == LogicalTypeId::ENUM) {
213939 // This means they are both ENUMs, but of different types.
213940 switch (enum_physical_type) {
213941 case PhysicalType::UINT8:
213942 return EnumEnumCastSwitch<uint8_t>(input, source, target);
213944 return EnumEnumCastSwitch<uint16_t>(input, source, target);
213946 return EnumEnumCastSwitch<uint32_t>(input, source, target);
213947 default:
213948 throw InternalException("ENUM can only have unsigned integers (except UINT64) as physical types");
213949 }
213950 }
213951 if (target == LogicalType::VARCHAR) {
213952 switch (enum_physical_type) {
213953 case PhysicalType::UINT8:
213954 return EnumToVarcharCast<uint8_t>;
213956 return EnumToVarcharCast<uint16_t>;
213958 return EnumToVarcharCast<uint32_t>;
213959 default:
213960 throw InternalException("ENUM can only have unsigned integers (except UINT64) as physical types");
213961 }
213962 }
213963 // Otherwise, fall back to ANY cast
213964 return BoundCastInfo(EnumToAnyCast, BindEnumCast(input, source, target), InitEnumCastLocalState);
213965}
@ 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

◆ IntervalCastSwitch()

BoundCastInfo duckdb::DefaultCasts::IntervalCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
215753 {
215754 // now switch on the result type
215755 switch (target.id()) {
215756 case LogicalTypeId::VARCHAR:
215757 // time to varchar
215758 return BoundCastInfo(&VectorCastHelpers::StringCast<interval_t, duckdb::StringCast>);
215759 default:
215760 return TryVectorNullCast;
215761 }
215762}

◆ ListCastSwitch()

BoundCastInfo duckdb::DefaultCasts::ListCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
214296 {
214297 switch (target.id()) {
214298 case LogicalTypeId::LIST:
214299 return BoundCastInfo(ListCast::ListToListCast, ListBoundCastData::BindListToListCast(input, source, target),
214300 ListBoundCastData::InitListLocalState);
214301 case LogicalTypeId::VARCHAR:
214302 return BoundCastInfo(
214303 ListToVarcharCast,
214304 ListBoundCastData::BindListToListCast(input, source, LogicalType::LIST(LogicalType::VARCHAR)),
214305 ListBoundCastData::InitListLocalState);
214306 case LogicalTypeId::ARRAY:
214307 return BoundCastInfo(ListToArrayCast, BindListToArrayCast(input, source, target),
214308 ListBoundCastData::InitListLocalState);
214309 default:
214310 return DefaultCasts::TryVectorNullCast;
214311 }
214312}

◆ ArrayCastSwitch()

BoundCastInfo duckdb::DefaultCasts::ArrayCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
212226 {
212227 switch (target.id()) {
212228 case LogicalTypeId::VARCHAR: {
212229 auto size = ArrayType::GetSize(source);
212230 return BoundCastInfo(
212231 ArrayToVarcharCast,
212232 ArrayBoundCastData::BindArrayToArrayCast(input, source, LogicalType::ARRAY(LogicalType::VARCHAR, size)),
212233 ArrayBoundCastData::InitArrayLocalState);
212234 }
212235 case LogicalTypeId::ARRAY:
212236 return BoundCastInfo(ArrayToArrayCast, ArrayBoundCastData::BindArrayToArrayCast(input, source, target),
212237 ArrayBoundCastData::InitArrayLocalState);
212238 case LogicalTypeId::LIST:
212239 return BoundCastInfo(ArrayToListCast, BindArrayToListCast(input, source, target),
212240 ArrayBoundCastData::InitArrayLocalState);
212241 default:
212242 return DefaultCasts::TryVectorNullCast;
212243 };
212244}
GOpaque< Size > size(const GMat &src)

◆ NumericCastSwitch()

BoundCastInfo duckdb::DefaultCasts::NumericCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
214574 {
214575 switch (source.id()) {
214576 case LogicalTypeId::BOOLEAN:
214577 return InternalNumericCastSwitch<bool>(source, target);
214578 case LogicalTypeId::TINYINT:
214579 return InternalNumericCastSwitch<int8_t>(source, target);
214580 case LogicalTypeId::SMALLINT:
214581 return InternalNumericCastSwitch<int16_t>(source, target);
214582 case LogicalTypeId::INTEGER:
214583 return InternalNumericCastSwitch<int32_t>(source, target);
214584 case LogicalTypeId::BIGINT:
214585 return InternalNumericCastSwitch<int64_t>(source, target);
214586 case LogicalTypeId::UTINYINT:
214587 return InternalNumericCastSwitch<uint8_t>(source, target);
214588 case LogicalTypeId::USMALLINT:
214589 return InternalNumericCastSwitch<uint16_t>(source, target);
214590 case LogicalTypeId::UINTEGER:
214591 return InternalNumericCastSwitch<uint32_t>(source, target);
214592 case LogicalTypeId::UBIGINT:
214593 return InternalNumericCastSwitch<uint64_t>(source, target);
214594 case LogicalTypeId::HUGEINT:
214595 return InternalNumericCastSwitch<hugeint_t>(source, target);
214596 case LogicalTypeId::UHUGEINT:
214597 return InternalNumericCastSwitch<uhugeint_t>(source, target);
214598 case LogicalTypeId::FLOAT:
214599 return InternalNumericCastSwitch<float>(source, target);
214600 case LogicalTypeId::DOUBLE:
214601 return InternalNumericCastSwitch<double>(source, target);
214602 default:
214603 throw InternalException("NumericCastSwitch called with non-numeric argument");
214604 }
214605}

◆ MapCastSwitch()

BoundCastInfo duckdb::DefaultCasts::MapCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
214466 {
214467 switch (target.id()) {
214468 case LogicalTypeId::MAP:
214469 return BoundCastInfo(ListCast::ListToListCast, ListBoundCastData::BindListToListCast(input, source, target),
214470 ListBoundCastData::InitListLocalState);
214471 case LogicalTypeId::VARCHAR: {
214472 auto varchar_type = LogicalType::MAP(LogicalType::VARCHAR, LogicalType::VARCHAR);
214473 return BoundCastInfo(MapToVarcharCast, ListBoundCastData::BindListToListCast(input, source, varchar_type),
214474 ListBoundCastData::InitListLocalState);
214475 }
214476 default:
214477 return TryVectorNullCast;
214478 }
214479}
static bool MapToVarcharCast(Vector &source, Vector &result, idx_t count, CastParameters &parameters)
Definition duckdb.cpp:214338

◆ PointerCastSwitch()

BoundCastInfo duckdb::DefaultCasts::PointerCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
214614 {
214615 // now switch on the result type
214616 switch (target.id()) {
214617 case LogicalTypeId::VARCHAR:
214618 // pointer to varchar
214619 return BoundCastInfo(&VectorCastHelpers::StringCast<uintptr_t, duckdb::CastFromPointer>);
214620 default:
214621 return nullptr;
214622 }
214623}

◆ StringCastSwitch()

BoundCastInfo duckdb::DefaultCasts::StringCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
215088 {
215089 switch (target.id()) {
215090 case LogicalTypeId::DATE:
215091 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, date_t, duckdb::TryCastErrorMessage>);
215092 case LogicalTypeId::TIME:
215093 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, dtime_t, duckdb::TryCastErrorMessage>);
215094 case LogicalTypeId::TIME_NS:
215095 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, dtime_ns_t, duckdb::TryCastErrorMessage>);
215096 case LogicalTypeId::TIME_TZ:
215097 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, dtime_tz_t, duckdb::TryCastErrorMessage>);
215098 case LogicalTypeId::TIMESTAMP:
215099 return BoundCastInfo(&VectorCastHelpers::TryCastErrorLoop<string_t, timestamp_t, duckdb::TryCastErrorMessage>);
215100 case LogicalTypeId::TIMESTAMP_TZ:
215101 return BoundCastInfo(
215102 &VectorCastHelpers::TryCastErrorLoop<string_t, timestamp_tz_t, duckdb::TryCastErrorMessage>);
215104 return BoundCastInfo(
215105 &VectorCastHelpers::TryCastStrictLoop<string_t, timestamp_ns_t, duckdb::TryCastToTimestampNS>);
215106 case LogicalTypeId::TIMESTAMP_SEC:
215107 return BoundCastInfo(
215108 &VectorCastHelpers::TryCastStrictLoop<string_t, timestamp_t, duckdb::TryCastToTimestampSec>);
215109 case LogicalTypeId::TIMESTAMP_MS:
215110 return BoundCastInfo(
215111 &VectorCastHelpers::TryCastStrictLoop<string_t, timestamp_t, duckdb::TryCastToTimestampMS>);
215112 case LogicalTypeId::BLOB:
215113 return BoundCastInfo(&VectorCastHelpers::TryCastStringLoop<string_t, string_t, duckdb::TryCastToBlob>);
215114 case LogicalTypeId::BIT:
215115 return BoundCastInfo(&VectorCastHelpers::TryCastStringLoop<string_t, string_t, duckdb::TryCastToBit>);
215116 case LogicalTypeId::UUID:
215117 return BoundCastInfo(&VectorCastHelpers::TryCastStringLoop<string_t, hugeint_t, duckdb::TryCastToUUID>);
215118 case LogicalTypeId::GEOMETRY:
215119 return BoundCastInfo(&VectorCastHelpers::TryCastStringLoop<string_t, string_t, duckdb::TryCastToGeometry>);
215120 case LogicalTypeId::SQLNULL:
215121 return &DefaultCasts::TryVectorNullCast;
215122 case LogicalTypeId::VARCHAR:
215123 return &DefaultCasts::ReinterpretCast;
215124 case LogicalTypeId::LIST:
215125 // the second argument allows for a secondary casting function to be passed in the CastParameters
215126 return BoundCastInfo(
215127 &StringToNestedTypeCast<VectorStringToList>,
215128 ListBoundCastData::BindListToListCast(input, LogicalType::LIST(LogicalType::VARCHAR), target),
215129 ListBoundCastData::InitListLocalState);
215130 case LogicalTypeId::ARRAY:
215131 // the second argument allows for a secondary casting function to be passed in the CastParameters
215132 return BoundCastInfo(&StringToNestedTypeCast<VectorStringToArray>,
215133 ArrayBoundCastData::BindArrayToArrayCast(
215134 input, LogicalType::ARRAY(LogicalType::VARCHAR, optional_idx()), target),
215135 ArrayBoundCastData::InitArrayLocalState);
215136 case LogicalTypeId::STRUCT:
215137 return BoundCastInfo(&StringToNestedTypeCast<VectorStringToStruct>,
215138 StructBoundCastData::BindStructToStructCast(input, InitVarcharStructType(target), target),
215139 StructBoundCastData::InitStructCastLocalState);
215140 case LogicalTypeId::MAP:
215141 return BoundCastInfo(&StringToNestedTypeCast<VectorStringToMap>,
215142 MapBoundCastData::BindMapToMapCast(
215143 input, LogicalType::MAP(LogicalType::VARCHAR, LogicalType::VARCHAR), target),
215144 InitMapCastLocalState);
215145 case LogicalTypeId::BIGNUM:
215146 return BoundCastInfo(&VectorCastHelpers::TryCastStringLoop<string_t, bignum_t, TryCastToBignum>);
215147 default:
215148 return VectorStringCastNumericSwitch(input, source, target);
215149 }
215150}

◆ StructCastSwitch()

BoundCastInfo duckdb::DefaultCasts::StructCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
215505 {
215506 switch (target.id()) {
215507 case LogicalTypeId::STRUCT:
215508 return BoundCastInfo(StructToStructCast, StructBoundCastData::BindStructToStructCast(input, source, target),
215509 StructBoundCastData::InitStructCastLocalState);
215510 case LogicalTypeId::VARCHAR: {
215511 // bind a cast in which we convert all child entries to VARCHAR entries
215512 auto &struct_children = StructType::GetChildTypes(source);
215513 child_list_t<LogicalType> varchar_children;
215514 for (auto &child_entry : struct_children) {
215515 varchar_children.push_back(make_pair(child_entry.first, LogicalType::VARCHAR));
215516 }
215517 auto varchar_type = LogicalType::STRUCT(varchar_children);
215518 return BoundCastInfo(StructToVarcharCast,
215519 StructBoundCastData::BindStructToStructCast(input, source, varchar_type),
215520 StructBoundCastData::InitStructCastLocalState);
215521 }
215522 case LogicalTypeId::MAP: {
215523 return BoundCastInfo(StructToMapCast, StructToMapBoundCastData::BindStructToMapCast(input, source, target),
215524 StructToMapBoundCastData::InitStructToMapCastLocalState);
215525 }
215526 default:
215527 return TryVectorNullCast;
215528 }
215529}
static bool StructToVarcharCast(Vector &source, Vector &result, idx_t count, CastParameters &parameters)
Definition duckdb.cpp:215288

◆ TimeCastSwitch()

BoundCastInfo duckdb::DefaultCasts::TimeCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
215558 {
215559 // now switch on the result type
215560 switch (target.id()) {
215561 case LogicalTypeId::VARCHAR:
215562 // time to varchar
215563 return BoundCastInfo(&VectorCastHelpers::StringCast<dtime_t, duckdb::StringCast>);
215564 case LogicalTypeId::TIME_TZ:
215565 // time to time with time zone
215566 return BoundCastInfo(&VectorCastHelpers::TemplatedCastLoop<dtime_t, dtime_tz_t, duckdb::Cast>);
215567 default:
215568 return TryVectorNullCast;
215569 }
215570}

◆ TimeNsCastSwitch()

BoundCastInfo duckdb::DefaultCasts::TimeNsCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
215572 {
215573 // now switch on the result type
215574 switch (target.id()) {
215575 case LogicalTypeId::VARCHAR:
215576 // time (ns) to varchar
215577 return BoundCastInfo(&VectorCastHelpers::StringCast<dtime_ns_t, duckdb::StringCast>);
215578 case LogicalTypeId::TIME:
215579 // time (ns) to time (µs)
215580 return BoundCastInfo(&VectorCastHelpers::TemplatedCastLoop<dtime_ns_t, dtime_t, duckdb::Cast>);
215581 default:
215582 return TryVectorNullCast;
215583 }
215584}

◆ TimeTzCastSwitch()

BoundCastInfo duckdb::DefaultCasts::TimeTzCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
215587 {
215588 // now switch on the result type
215589 switch (target.id()) {
215590 case LogicalTypeId::VARCHAR:
215591 // time with time zone to varchar
215592 return BoundCastInfo(&VectorCastHelpers::StringCast<dtime_tz_t, duckdb::StringCastTZ>);
215593 case LogicalTypeId::TIME:
215594 // time with time zone to time
215595 return BoundCastInfo(&VectorCastHelpers::TemplatedCastLoop<dtime_tz_t, dtime_t, duckdb::Cast>);
215596 default:
215597 return TryVectorNullCast;
215598 }
215599}

◆ TimestampCastSwitch()

BoundCastInfo duckdb::DefaultCasts::TimestampCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
215602 {
215603 // now switch on the result type
215604 switch (target.id()) {
215605 case LogicalTypeId::VARCHAR:
215606 // timestamp to varchar
215607 return BoundCastInfo(&VectorCastHelpers::StringCast<timestamp_t, duckdb::StringCast>);
215608 case LogicalTypeId::DATE:
215609 // timestamp to date
215610 return BoundCastInfo(&VectorCastHelpers::TemplatedCastLoop<timestamp_t, date_t, duckdb::Cast>);
215611 case LogicalTypeId::TIME:
215612 // timestamp to time
215613 return BoundCastInfo(&VectorCastHelpers::TemplatedCastLoop<timestamp_t, dtime_t, duckdb::Cast>);
215614 case LogicalTypeId::TIME_TZ:
215615 // timestamp to time_tz
215616 return BoundCastInfo(&VectorCastHelpers::TemplatedCastLoop<timestamp_t, dtime_tz_t, duckdb::Cast>);
215617 case LogicalTypeId::TIMESTAMP_TZ:
215618 // timestamp (us) to timestamp with time zone
215619 return ReinterpretCast;
215621 // timestamp (us) to timestamp (ns)
215622 return BoundCastInfo(
215623 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampUsToNs>);
215624 case LogicalTypeId::TIMESTAMP_MS:
215625 // timestamp (us) to timestamp (ms)
215626 return BoundCastInfo(
215627 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampUsToMs>);
215628 case LogicalTypeId::TIMESTAMP_SEC:
215629 // timestamp (us) to timestamp (s)
215630 return BoundCastInfo(
215631 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampUsToSec>);
215632 default:
215633 return TryVectorNullCast;
215634 }
215635}

◆ TimestampTzCastSwitch()

BoundCastInfo duckdb::DefaultCasts::TimestampTzCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
215638 {
215639 // now switch on the result type
215640 switch (target.id()) {
215641 case LogicalTypeId::VARCHAR:
215642 // timestamp with time zone to varchar
215643 return BoundCastInfo(&VectorCastHelpers::StringCast<timestamp_t, duckdb::StringCastTZ>);
215644 case LogicalTypeId::TIME_TZ:
215645 // timestamp with time zone to time with time zone.
215646 return BoundCastInfo(&VectorCastHelpers::TemplatedCastLoop<timestamp_t, dtime_tz_t, duckdb::Cast>);
215647 case LogicalTypeId::TIMESTAMP:
215648 // timestamp with time zone to timestamp (us)
215649 return ReinterpretCast;
215650 default:
215651 return TryVectorNullCast;
215652 }
215653}

◆ TimestampNsCastSwitch()

BoundCastInfo duckdb::DefaultCasts::TimestampNsCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
215656 {
215657 // now switch on the result type
215658 switch (target.id()) {
215659 case LogicalTypeId::VARCHAR:
215660 // timestamp (ns) to varchar
215661 return BoundCastInfo(&VectorCastHelpers::StringCast<timestamp_ns_t, duckdb::StringCast>);
215662 case LogicalTypeId::DATE:
215663 // timestamp (ns) to date
215664 return BoundCastInfo(&VectorCastHelpers::TemplatedCastLoop<timestamp_t, date_t, duckdb::CastTimestampNsToDate>);
215665 case LogicalTypeId::TIME:
215666 // timestamp (ns) to time
215667 return BoundCastInfo(
215668 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, dtime_t, duckdb::CastTimestampNsToTime>);
215669 case LogicalTypeId::TIME_NS:
215670 // timestamp (ns) to time (ns)
215671 return BoundCastInfo(
215672 &VectorCastHelpers::TemplatedCastLoop<timestamp_ns_t, dtime_ns_t, duckdb::CastTimestampNsToTimeNs>);
215673 case LogicalTypeId::TIMESTAMP:
215674 // timestamp (ns) to timestamp (us)
215675 return BoundCastInfo(
215676 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampNsToUs>);
215677 case LogicalTypeId::TIMESTAMP_TZ:
215678 // timestamp (ns) to timestamp with time zone (us)
215679 return BoundCastInfo(
215680 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampNsToUs>);
215681 default:
215682 return TryVectorNullCast;
215683 }
215684}

◆ TimestampMsCastSwitch()

BoundCastInfo duckdb::DefaultCasts::TimestampMsCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
215687 {
215688 // now switch on the result type
215689 switch (target.id()) {
215690 case LogicalTypeId::VARCHAR:
215691 // timestamp (ms) to varchar
215692 return BoundCastInfo(&VectorCastHelpers::StringCast<timestamp_t, duckdb::CastFromTimestampMS>);
215693 case LogicalTypeId::DATE:
215694 // timestamp (ms) to date
215695 return BoundCastInfo(&VectorCastHelpers::TemplatedCastLoop<timestamp_t, date_t, duckdb::CastTimestampMsToDate>);
215696 case LogicalTypeId::TIME:
215697 // timestamp (ms) to time
215698 return BoundCastInfo(
215699 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, dtime_t, duckdb::CastTimestampMsToTime>);
215700 case LogicalTypeId::TIMESTAMP:
215701 // timestamp (ms) to timestamp (us)
215702 return BoundCastInfo(
215703 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampMsToUs>);
215705 // timestamp (ms) to timestamp (ns)
215706 return BoundCastInfo(
215707 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampMsToNs>);
215708 case LogicalTypeId::TIMESTAMP_TZ:
215709 // timestamp (ms) to timestamp with timezone (us)
215710 return BoundCastInfo(
215711 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampMsToUs>);
215712 default:
215713 return TryVectorNullCast;
215714 }
215715}

◆ TimestampSecCastSwitch()

BoundCastInfo duckdb::DefaultCasts::TimestampSecCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
215718 {
215719 // now switch on the result type
215720 switch (target.id()) {
215721 case LogicalTypeId::VARCHAR:
215722 // timestamp (s) to varchar
215723 return BoundCastInfo(&VectorCastHelpers::StringCast<timestamp_t, duckdb::CastFromTimestampSec>);
215724 case LogicalTypeId::DATE:
215725 // timestamp (s) to date
215726 return BoundCastInfo(
215727 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, date_t, duckdb::CastTimestampSecToDate>);
215728 case LogicalTypeId::TIME:
215729 // timestamp (s) to time
215730 return BoundCastInfo(
215731 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, dtime_t, duckdb::CastTimestampSecToTime>);
215732 case LogicalTypeId::TIMESTAMP_MS:
215733 // timestamp (s) to timestamp (ms)
215734 return BoundCastInfo(
215735 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampSecToMs>);
215736 case LogicalTypeId::TIMESTAMP:
215737 // timestamp (s) to timestamp (us)
215738 return BoundCastInfo(
215739 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampSecToUs>);
215740 case LogicalTypeId::TIMESTAMP_TZ:
215741 // timestamp (s) to timestamp with timezone (us)
215742 return BoundCastInfo(
215743 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampSecToUs>);
215745 // timestamp (s) to timestamp (ns)
215746 return BoundCastInfo(
215747 &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampSecToNs>);
215748 default:
215749 return TryVectorNullCast;
215750 }
215751}

◆ UnionCastSwitch()

BoundCastInfo duckdb::DefaultCasts::UnionCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
216255 {
216256 D_ASSERT(source.id() == LogicalTypeId::UNION);
216257 switch (target.id()) {
216258 case LogicalTypeId::VARCHAR: {
216259 // bind a cast in which we convert all members to VARCHAR first
216260 child_list_t<LogicalType> varchar_members;
216261 for (idx_t member_idx = 0; member_idx < UnionType::GetMemberCount(source); member_idx++) {
216262 varchar_members.push_back(make_pair(UnionType::GetMemberName(source, member_idx), LogicalType::VARCHAR));
216263 }
216264 auto varchar_type = LogicalType::UNION(std::move(varchar_members));
216265 return BoundCastInfo(UnionToVarcharCast, BindUnionToUnionCast(input, source, varchar_type),
216266 InitUnionToUnionLocalState);
216267 }
216268 case LogicalTypeId::UNION:
216269 return BoundCastInfo(UnionToUnionCast, BindUnionToUnionCast(input, source, target), InitUnionToUnionLocalState);
216270 default:
216271 return TryVectorNullCast;
216272 }
216273}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ VariantCastSwitch()

BoundCastInfo duckdb::DefaultCasts::VariantCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
217040 {
217041 D_ASSERT(source.id() == LogicalTypeId::VARIANT);
217042 switch (target.id()) {
217043 case LogicalTypeId::BOOLEAN:
217044 case LogicalTypeId::TINYINT:
217045 case LogicalTypeId::SMALLINT:
217046 case LogicalTypeId::INTEGER:
217047 case LogicalTypeId::BIGINT:
217048 case LogicalTypeId::DATE:
217049 case LogicalTypeId::TIMESTAMP:
217050 case LogicalTypeId::TIMESTAMP_SEC:
217051 case LogicalTypeId::TIMESTAMP_MS:
217053 case LogicalTypeId::DOUBLE:
217054 case LogicalTypeId::FLOAT:
217055 case LogicalTypeId::BLOB:
217056 case LogicalTypeId::BIT:
217057 case LogicalTypeId::BIGNUM:
217058 case LogicalTypeId::INTERVAL:
217059 case LogicalTypeId::HUGEINT:
217060 case LogicalTypeId::DECIMAL:
217061 case LogicalTypeId::UTINYINT:
217062 case LogicalTypeId::USMALLINT:
217063 case LogicalTypeId::UINTEGER:
217064 case LogicalTypeId::UBIGINT:
217065 case LogicalTypeId::UHUGEINT:
217066 case LogicalTypeId::TIME:
217067 case LogicalTypeId::LIST:
217068 case LogicalTypeId::STRUCT:
217069 case LogicalTypeId::TIME_TZ:
217070 case LogicalTypeId::TIME_NS:
217071 case LogicalTypeId::TIMESTAMP_TZ:
217072 case LogicalTypeId::MAP:
217073 case LogicalTypeId::UNION:
217074 case LogicalTypeId::UUID:
217075 case LogicalTypeId::ARRAY:
217076 return BoundCastInfo(CastFromVARIANT);
217077 case LogicalTypeId::GEOMETRY:
217078 return BoundCastInfo(CastFromVARIANT);
217079 case LogicalTypeId::VARCHAR: {
217080 return BoundCastInfo(CastFromVARIANT);
217081 }
217082 default:
217083 return TryVectorNullCast;
217084 }
217085}

◆ UUIDCastSwitch()

BoundCastInfo duckdb::DefaultCasts::UUIDCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
216282 {
216283 // now switch on the result type
216284 switch (target.id()) {
216285 case LogicalTypeId::VARCHAR:
216286 // uuid to varchar
216287 return BoundCastInfo(&VectorCastHelpers::StringCast<hugeint_t, duckdb::CastFromUUID>);
216288 case LogicalTypeId::BLOB:
216289 // uuid to blob
216290 return BoundCastInfo(&VectorCastHelpers::StringCast<hugeint_t, duckdb::CastFromUUIDToBlob>);
216291 default:
216292 return TryVectorNullCast;
216293 }
216294}

◆ GeoCastSwitch()

BoundCastInfo duckdb::DefaultCasts::GeoCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
213981 {
213982 // now switch on the result type
213983 switch (target.id()) {
213984 case LogicalTypeId::VARCHAR:
213985 return GeometryToVarcharCast;
213986 case LogicalTypeId::GEOMETRY: {
213987 // If the coordinate reference systems differ, we may not be able to cast
213988 if (GeoType::HasCRS(source) && GeoType::HasCRS(target)) {
213989 auto &target_crs = GeoType::GetCRS(target);
213990 auto &source_crs = GeoType::GetCRS(source);
213991
213992 // TODO: Use client context (and allow extensions) to determine if the cast is okay (crs's are equivalent)
213993
213994 if (!source_crs.Equals(target_crs)) {
213995 throw BinderException("Cannot cast GEOMETRY with CRS '" + source_crs.GetIdentifier() +
213996 "' to GEOMETRY with different CRS '" + target_crs.GetIdentifier() + "'");
213997 }
213998 }
213999 // The actual data representation stays the same, so we can do a reinterpret cast
214000 return DefaultCasts::ReinterpretCast;
214001 }
214002 default:
214003 return TryVectorNullCast;
214004 }
214005}

◆ TypeCastSwitch()

BoundCastInfo duckdb::DefaultCasts::TypeCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
215770 {
215771 // now switch on the result type
215772 if (target == LogicalType::VARCHAR) {
215773 // type to varchar
215774 return BoundCastInfo(&VectorCastHelpers::StringCast<string_t, duckdb::CastFromType>);
215775 }
215776 return nullptr;
215777}

◆ BignumCastSwitch()

BoundCastInfo duckdb::DefaultCasts::BignumCastSwitch ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
212864 {
212865 D_ASSERT(source.id() == LogicalTypeId::BIGNUM);
212866 // now switch on the result type
212867 switch (target.id()) {
212868 case LogicalTypeId::TINYINT:
212869 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<bignum_t, int8_t, BignumToIntCast>);
212870 case LogicalTypeId::UTINYINT:
212871 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<bignum_t, uint8_t, BignumToIntCast>);
212872
212873 case LogicalTypeId::SMALLINT:
212874 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<bignum_t, int16_t, BignumToIntCast>);
212875
212876 case LogicalTypeId::USMALLINT:
212877 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<bignum_t, uint16_t, BignumToIntCast>);
212878
212879 case LogicalTypeId::INTEGER:
212880 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<bignum_t, int32_t, BignumToIntCast>);
212881
212882 case LogicalTypeId::UINTEGER:
212883 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<bignum_t, uint32_t, BignumToIntCast>);
212884
212885 case LogicalTypeId::BIGINT:
212886 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<bignum_t, int64_t, BignumToIntCast>);
212887
212888 case LogicalTypeId::UBIGINT:
212889 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<bignum_t, uint64_t, BignumToIntCast>);
212890
212891 case LogicalTypeId::HUGEINT:
212892 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<bignum_t, hugeint_t, BignumToIntCast>);
212893
212894 case LogicalTypeId::UHUGEINT:
212895 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<bignum_t, uhugeint_t, BignumToIntCast>);
212896
212897 case LogicalTypeId::VARCHAR:
212898 return BoundCastInfo(&VectorCastHelpers::StringCast<bignum_t, BignumCastToVarchar>);
212899 case LogicalTypeId::DOUBLE:
212900 return BoundCastInfo(&VectorCastHelpers::TryCastLoop<bignum_t, double, BignumToDoubleCast>);
212901 default:
212902 return TryVectorNullCast;
212903 }
212904}

◆ ImplicitToUnionCast()

BoundCastInfo duckdb::DefaultCasts::ImplicitToUnionCast ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
216021 {
216022 D_ASSERT(target.id() == LogicalTypeId::UNION);
216023 if (StructToUnionCast::AllowImplicitCastFromStruct(source, target)) {
216024 return StructToUnionCast::Bind(input, source, target);
216025 }
216026 auto cast_data = BindToUnionCast(input, source, target);
216027 return BoundCastInfo(&ToUnionCast, std::move(cast_data), InitToUnionLocalState);
216028}

◆ ImplicitToVariantCast()

BoundCastInfo duckdb::DefaultCasts::ImplicitToVariantCast ( BindCastInput & input,
const LogicalType & source,
const LogicalType & target )
staticprivate
218886 {
218887 return BoundCastInfo(variant::CastToVARIANT);
218888}

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