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

Function tryCombineDecimalTypes

src/common/types/types.cpp:1745–1760  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1743}
1744
1745static inline bool tryCombineDecimalTypes(const LogicalType& left, const LogicalType& right,
1746 LogicalType& result) {
1747 auto precisionLeft = DecimalType::getPrecision(left);
1748 auto scaleLeft = DecimalType::getScale(left);
1749 auto precisionRight = DecimalType::getPrecision(right);
1750 auto scaleRight = DecimalType::getScale(right);
1751 auto resultingScale = std::max(scaleLeft, scaleRight);
1752 auto resultingPrecision =
1753 std::max(precisionLeft - scaleLeft, precisionRight - scaleRight) + resultingScale;
1754 if (resultingPrecision > DECIMAL_PRECISION_LIMIT) {
1755 result = LogicalType::DOUBLE();
1756 return true;
1757 }
1758 result = LogicalType::DECIMAL(resultingPrecision, resultingScale);
1759 return true;
1760}
1761
1762static inline bool tryCombineDecimalWithNumeric(const LogicalType& dec, const LogicalType& nonDec,
1763 LogicalType& result) {

Callers 1

tryGetMaxLogicalTypeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected