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

Method tryGetMaxLogicalTypeID

src/common/types/types.cpp:1686–1739  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1684}
1685
1686bool LogicalTypeUtils::tryGetMaxLogicalTypeID(const LogicalTypeID& left, const LogicalTypeID& right,
1687 LogicalTypeID& result) {
1688 if (canAlwaysCast(left) && canAlwaysCast(right)) {
1689 if (alwaysCastOrder(left) > alwaysCastOrder(right)) {
1690 result = left;
1691 } else {
1692 result = right;
1693 }
1694 return true;
1695 }
1696 if (left == right || canAlwaysCast(left)) {
1697 result = right;
1698 return true;
1699 }
1700 if (canAlwaysCast(right)) {
1701 result = left;
1702 return true;
1703 }
1704 auto leftToRight = BuiltInFunctionsUtils::getCastCost(left, right);
1705 auto rightToLeft = BuiltInFunctionsUtils::getCastCost(right, left);
1706 if (leftToRight != UNDEFINED_CAST_COST || rightToLeft != UNDEFINED_CAST_COST) {
1707 if (leftToRight < rightToLeft) {
1708 result = right;
1709 } else {
1710 result = left;
1711 }
1712 return true;
1713 }
1714 if (isIntegral(left) && isIntegral(right)) {
1715 if (isUnsigned(left) && !isUnsigned(right)) {
1716 result = joinDifferentSignIntegrals(right, left);
1717 return true;
1718 } else if (isUnsigned(right) && !isUnsigned(left)) {
1719 result = joinDifferentSignIntegrals(left, right);
1720 return true;
1721 }
1722 }
1723
1724 // check timestamp combination
1725 // note: this will become obsolete if implicit casting
1726 // between timestamps is allowed
1727 auto leftOrder = internalTimeOrder(left);
1728 auto rightOrder = internalTimeOrder(right);
1729 if (leftOrder && rightOrder) {
1730 if (leftOrder > rightOrder) {
1731 result = left;
1732 } else {
1733 result = right;
1734 }
1735 return true;
1736 }
1737
1738 return false;
1739}
1740
1741static inline bool isSemanticallyNested(LogicalTypeID ID) {
1742 return LogicalTypeUtils::isNested(ID);

Callers

nothing calls this directly

Calls 4

canAlwaysCastFunction · 0.85
alwaysCastOrderFunction · 0.85
internalTimeOrderFunction · 0.85

Tested by

no test coverage detected