| 725 | } |
| 726 | |
| 727 | LogicalType 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 | |
| 755 | void LogicalType::serialize(Serializer& serializer) const { |
| 756 | serializer.serializeValue(typeID); |
nothing calls this directly
no test coverage detected