| 833 | |
| 834 | template<CastExecutor EXECUTOR> |
| 835 | std::unique_ptr<ScalarFunction> CastFunction::bindCastFunction(const std::string& functionName, |
| 836 | const LogicalType& sourceType, const LogicalType& targetType) { |
| 837 | auto sourceTypeID = sourceType.getLogicalTypeID(); |
| 838 | auto targetTypeID = targetType.getLogicalTypeID(); |
| 839 | if (sourceTypeID == LogicalTypeID::STRING || sourceTypeID == LogicalTypeID::JSON) { |
| 840 | return bindCastFromStringFunction<EXECUTOR>(functionName, targetType); |
| 841 | } |
| 842 | switch (targetTypeID) { |
| 843 | case LogicalTypeID::STRING: { |
| 844 | return bindCastToStringFunction<EXECUTOR>(functionName, sourceType); |
| 845 | } |
| 846 | case LogicalTypeID::DOUBLE: { |
| 847 | return bindCastToNumericFunction<double, CastToDouble, EXECUTOR>(functionName, sourceType, |
| 848 | targetType); |
| 849 | } |
| 850 | case LogicalTypeID::FLOAT: { |
| 851 | return bindCastToNumericFunction<float, CastToFloat, EXECUTOR>(functionName, sourceType, |
| 852 | targetType); |
| 853 | } |
| 854 | case LogicalTypeID::DECIMAL: { |
| 855 | std::unique_ptr<ScalarFunction> scalarFunc; |
| 856 | TypeUtils::visit( |
| 857 | targetType.getPhysicalType(), |
| 858 | [&]<IntegerTypes T>(T) { |
| 859 | scalarFunc = |
| 860 | bindCastToDecimalFunction<T, EXECUTOR>(functionName, sourceType, targetType); |
| 861 | }, |
| 862 | [](auto) { UNREACHABLE_CODE; }); |
| 863 | return scalarFunc; |
| 864 | } |
| 865 | case LogicalTypeID::INT128: { |
| 866 | return bindCastToNumericFunction<int128_t, CastToInt128, EXECUTOR>(functionName, sourceType, |
| 867 | targetType); |
| 868 | } |
| 869 | case LogicalTypeID::UINT128: { |
| 870 | return bindCastToNumericFunction<uint128_t, CastToUInt128, EXECUTOR>(functionName, |
| 871 | sourceType, targetType); |
| 872 | } |
| 873 | case LogicalTypeID::SERIAL: { |
| 874 | return bindCastToNumericFunction<int64_t, CastToSerial, EXECUTOR>(functionName, sourceType, |
| 875 | targetType); |
| 876 | } |
| 877 | case LogicalTypeID::INT64: { |
| 878 | return bindCastToNumericFunction<int64_t, CastToInt64, EXECUTOR>(functionName, sourceType, |
| 879 | targetType); |
| 880 | } |
| 881 | case LogicalTypeID::INT32: { |
| 882 | return bindCastToNumericFunction<int32_t, CastToInt32, EXECUTOR>(functionName, sourceType, |
| 883 | targetType); |
| 884 | } |
| 885 | case LogicalTypeID::INT16: { |
| 886 | return bindCastToNumericFunction<int16_t, CastToInt16, EXECUTOR>(functionName, sourceType, |
| 887 | targetType); |
| 888 | } |
| 889 | case LogicalTypeID::INT8: { |
| 890 | return bindCastToNumericFunction<int8_t, CastToInt8, EXECUTOR>(functionName, sourceType, |
| 891 | targetType); |
| 892 | } |
nothing calls this directly
no test coverage detected