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

Method tryGetMaxLogicalType

src/common/types/types.cpp:1810–1879  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1808}
1809
1810bool LogicalTypeUtils::tryGetMaxLogicalType(const LogicalType& left, const LogicalType& right,
1811 LogicalType& result) {
1812 if (canAlwaysCast(left.typeID) && canAlwaysCast(right.typeID)) {
1813 if (alwaysCastOrder(left.typeID) > alwaysCastOrder(right.typeID)) {
1814 result = left.copy();
1815 } else {
1816 result = right.copy();
1817 }
1818 return true;
1819 }
1820 if (left == right || canAlwaysCast(left.typeID)) {
1821 result = right.copy();
1822 return true;
1823 }
1824 if (canAlwaysCast(right.typeID)) {
1825 result = left.copy();
1826 return true;
1827 }
1828 if (left.typeID == LogicalTypeID::DECIMAL && right.typeID == LogicalTypeID::DECIMAL) {
1829 return tryCombineDecimalTypes(left, right, result);
1830 }
1831 if (left.typeID == LogicalTypeID::DECIMAL && LogicalTypeUtils::isNumerical(right.typeID)) {
1832 return tryCombineDecimalWithNumeric(left, right, result);
1833 }
1834 if (right.typeID == LogicalTypeID::DECIMAL && LogicalTypeUtils::isNumerical(left.typeID)) {
1835 return tryCombineDecimalWithNumeric(right, left, result);
1836 }
1837 if (isSemanticallyNested(left.typeID) || isSemanticallyNested(right.typeID)) {
1838 if (left.typeID == LogicalTypeID::LIST && right.typeID == LogicalTypeID::ARRAY) {
1839 return tryCombineListArrayTypes(left, right, result);
1840 }
1841 if (left.typeID == LogicalTypeID::ARRAY && right.typeID == LogicalTypeID::LIST) {
1842 return tryCombineListArrayTypes(right, left, result);
1843 }
1844 if (left.typeID != right.typeID) {
1845 return false;
1846 }
1847 switch (left.typeID) {
1848 case LogicalTypeID::LIST:
1849 return tryCombineListTypes(left, right, result);
1850 case LogicalTypeID::ARRAY:
1851 return tryCombineArrayTypes(left, right, result);
1852 case LogicalTypeID::STRUCT:
1853 return tryCombineStructTypes(left, right, result);
1854 case LogicalTypeID::MAP:
1855 return tryCombineMapTypes(left, right, result);
1856 // LCOV_EXCL_START
1857 case LogicalTypeID::UNION:
1858 throw ConversionException("Union casting is not supported");
1859 // return tryCombineUnionTypes(left, right, result);
1860 default:
1861 throw RuntimeException(std::format("Casting between {} and {} is not implemented.",
1862 left.toString(), right.toString()));
1863 // LCOV_EXCL_END
1864 }
1865 }
1866 auto resultID = LogicalTypeID::ANY;
1867 if (!tryGetMaxLogicalTypeID(left.typeID, right.typeID, resultID)) {

Callers

nothing calls this directly

Calls 13

canAlwaysCastFunction · 0.85
alwaysCastOrderFunction · 0.85
tryCombineDecimalTypesFunction · 0.85
isSemanticallyNestedFunction · 0.85
tryCombineListArrayTypesFunction · 0.85
tryCombineListTypesFunction · 0.85
tryCombineArrayTypesFunction · 0.85
tryCombineStructTypesFunction · 0.85
tryCombineMapTypesFunction · 0.85
LogicalTypeClass · 0.50
copyMethod · 0.45

Tested by

no test coverage detected