MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / convertFromString

Method convertFromString

src/common/types/types.cpp:727–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

725}
726
727LogicalType LogicalType::convertFromString(const std::string& str, main::ClientContext* context) {
728 LogicalType type;
729 auto trimmedStr = StringUtils::ltrim(StringUtils::rtrim(str));
730 auto upperDataTypeString = StringUtils::getUpper(trimmedStr);
731 if (upperDataTypeString.ends_with("[]")) {
732 type = parseListType(trimmedStr, context);
733 } else if (upperDataTypeString.ends_with("]")) {
734 type = parseArrayType(trimmedStr, context);
735 } else if (upperDataTypeString.starts_with("STRUCT")) {
736 type = parseStructType(trimmedStr, context);
737 } else if (upperDataTypeString.starts_with("MAP")) {
738 type = parseMapType(trimmedStr, context);
739 } else if (upperDataTypeString.starts_with("UNION")) {
740 type = parseUnionType(trimmedStr, context);
741 } else if (upperDataTypeString.starts_with("DECIMAL") ||
742 upperDataTypeString.starts_with("NUMERIC")) {
743 type = parseDecimalType(trimmedStr);
744 } else if (tryGetIDFromString(upperDataTypeString, type.typeID)) {
745 type.physicalType = LogicalType::getPhysicalType(type.typeID, type.extraTypeInfo);
746 } else if (context != nullptr) {
747 auto transaction = transaction::Transaction::Get(*context);
748 type = catalog::Catalog::Get(*context)->getType(transaction, upperDataTypeString);
749 } else {
750 throw common::RuntimeException{"Invalid datatype string: " + str};
751 }
752 return type;
753}
754
755void LogicalType::serialize(Serializer& serializer) const {
756 serializer.serializeValue(typeID);

Callers

nothing calls this directly

Calls 10

ltrimFunction · 0.85
rtrimFunction · 0.85
parseListTypeFunction · 0.85
parseArrayTypeFunction · 0.85
parseStructTypeFunction · 0.85
parseMapTypeFunction · 0.85
parseUnionTypeFunction · 0.85
parseDecimalTypeFunction · 0.85
tryGetIDFromStringFunction · 0.85
getTypeMethod · 0.45

Tested by

no test coverage detected