MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / isCompilable

Method isCompilable

src/Functions/FunctionsConversion.cpp:2898–2925  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2896
2897
2898bool FunctionCast::isCompilable() const
2899{
2900 if (getName() != "CAST" || argument_types.size() != 2)
2901 return false;
2902
2903 const auto & input_type = argument_types[0];
2904 const auto & result_type = getResultType();
2905 auto denull_input_type = removeNullable(input_type);
2906 auto denull_result_type = removeNullable(result_type);
2907 if (!canBeNativeType(denull_input_type) || !canBeNativeType(denull_result_type))
2908 return false;
2909
2910 return castBothTypes(denull_input_type.get(), denull_result_type.get(), [](const auto & left, const auto & right)
2911 {
2912 using LeftDataType = std::decay_t<decltype(left)>;
2913 using RightDataType = std::decay_t<decltype(right)>;
2914 if constexpr (IsDataTypeDecimalOrNumber<LeftDataType> && IsDataTypeDecimalOrNumber<RightDataType>)
2915 {
2916 if constexpr (IsDataTypeNumber<LeftDataType> && IsDataTypeNumber<RightDataType>)
2917 return true;
2918 else if constexpr (IsDataTypeNumber<LeftDataType> && IsDataTypeDecimal<RightDataType>)
2919 return true;
2920 else if constexpr (IsDataTypeDecimal<LeftDataType> && IsDataTypeNumber<RightDataType>)
2921 return true;
2922 }
2923 return false;
2924 });
2925}
2926
2927llvm::Value * FunctionCast::compile(llvm::IRBuilderBase & builder, const ValuesWithType & arguments) const
2928{

Callers

nothing calls this directly

Calls 7

getResultTypeFunction · 0.85
castBothTypesFunction · 0.85
getNameFunction · 0.70
removeNullableFunction · 0.50
canBeNativeTypeFunction · 0.50
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected