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

Function parseArrayType

src/common/types/types.cpp:1355–1370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1353}
1354
1355LogicalType parseArrayType(const std::string& trimmedStr, main::ClientContext* context) {
1356 auto leftBracketPos = trimmedStr.find_last_of('[');
1357 auto rightBracketPos = trimmedStr.find_last_of(']');
1358 auto childType =
1359 LogicalType(LogicalType::convertFromString(trimmedStr.substr(0, leftBracketPos), context));
1360 auto numElements = std::strtoll(
1361 trimmedStr.substr(leftBracketPos + 1, rightBracketPos - leftBracketPos - 1).c_str(),
1362 nullptr, 0 /* base */);
1363 if (numElements <= 0) {
1364 // Note: the parser already guarantees that the number of elements is a non-negative
1365 // number. However, we still need to check whether the number of elements is 0.
1366 throw BinderException("The number of elements in an array must be greater than 0. Given: " +
1367 std::to_string(numElements) + ".");
1368 }
1369 return LogicalType::ARRAY(std::move(childType), numElements);
1370}
1371
1372std::vector<StructField> parseStructTypeInfo(const std::string& structTypeStr,
1373 main::ClientContext* context, std::string defType) {

Callers 2

isBuiltInTypeMethod · 0.85
convertFromStringMethod · 0.85

Calls 1

LogicalTypeClass · 0.50

Tested by

no test coverage detected