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

Function tryCombineStructTypes

src/common/types/types.cpp:1536–1558  ·  view source on GitHub ↗

If we can match child labels and combine their types, then we can combine the struct

Source from the content-addressed store, hash-verified

1534// If we can match child labels and combine their types, then we can combine
1535// the struct
1536static bool tryCombineStructTypes(const LogicalType& left, const LogicalType& right,
1537 LogicalType& result) {
1538 const auto& leftFields = StructType::getFields(left);
1539 const auto& rightFields = StructType::getFields(right);
1540 if (leftFields.size() != rightFields.size()) {
1541 return false;
1542 }
1543 std::vector<StructField> newFields;
1544 for (auto i = 0u; i < leftFields.size(); i++) {
1545 if (leftFields[i].getName() != rightFields[i].getName()) {
1546 return false;
1547 }
1548 LogicalType combinedType;
1549 if (LogicalTypeUtils::tryGetMaxLogicalType(leftFields[i].getType(),
1550 rightFields[i].getType(), combinedType)) {
1551 newFields.push_back(StructField(leftFields[i].getName(), std::move(combinedType)));
1552 } else {
1553 return false;
1554 }
1555 }
1556 result = LogicalType::STRUCT(std::move(newFields));
1557 return true;
1558}
1559
1560// If we can combine the key and value, then we cna combine the map
1561static bool tryCombineMapTypes(const LogicalType& left, const LogicalType& right,

Callers 1

tryGetMaxLogicalTypeMethod · 0.85

Calls 5

StructFieldClass · 0.85
sizeMethod · 0.45
getNameMethod · 0.45
getTypeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected