| 254 | } |
| 255 | |
| 256 | bool CastFunction::hasImplicitCast(const LogicalType& srcType, const LogicalType& dstType) { |
| 257 | if (LogicalTypeUtils::isNested(srcType) && LogicalTypeUtils::isNested(dstType)) { |
| 258 | if (srcType.getLogicalTypeID() == LogicalTypeID::ARRAY && |
| 259 | dstType.getLogicalTypeID() == LogicalTypeID::LIST) { |
| 260 | return hasImplicitCastArrayToList(srcType, dstType); |
| 261 | } |
| 262 | if (srcType.getLogicalTypeID() == LogicalTypeID::LIST && |
| 263 | dstType.getLogicalTypeID() == LogicalTypeID::ARRAY) { |
| 264 | return hasImplicitCastListToArray(srcType, dstType); |
| 265 | } |
| 266 | if (srcType.getLogicalTypeID() != dstType.getLogicalTypeID()) { |
| 267 | return false; |
| 268 | } |
| 269 | switch (srcType.getLogicalTypeID()) { |
| 270 | case LogicalTypeID::LIST: |
| 271 | return hasImplicitCastList(srcType, dstType); |
| 272 | case LogicalTypeID::ARRAY: |
| 273 | return hasImplicitCastArray(srcType, dstType); |
| 274 | case LogicalTypeID::STRUCT: |
| 275 | return hasImplicitCastStruct(srcType, dstType); |
| 276 | case LogicalTypeID::UNION: |
| 277 | return hasImplicitCastUnion(srcType, dstType); |
| 278 | case LogicalTypeID::MAP: |
| 279 | return hasImplicitCastMap(srcType, dstType); |
| 280 | default: |
| 281 | // LCOV_EXCL_START |
| 282 | UNREACHABLE_CODE; |
| 283 | // LCOV_EXCL_END |
| 284 | } |
| 285 | } else if (dstType.getLogicalTypeID() == LogicalTypeID::UNION) { |
| 286 | return hasImplicitCastUnion(srcType, dstType); |
| 287 | } |
| 288 | if (BuiltInFunctionsUtils::getCastCost(srcType.getLogicalTypeID(), |
| 289 | dstType.getLogicalTypeID()) != UNDEFINED_CAST_COST) { |
| 290 | return true; |
| 291 | } |
| 292 | // TODO(Jiamin): there are still other special cases |
| 293 | // We allow cast between any numerical types |
| 294 | if (LogicalTypeUtils::isNumerical(srcType) && LogicalTypeUtils::isNumerical(dstType)) { |
| 295 | return true; |
| 296 | } |
| 297 | return false; |
| 298 | } |
| 299 | |
| 300 | template<typename EXECUTOR = UnaryFunctionExecutor> |
| 301 | static std::unique_ptr<ScalarFunction> bindCastFromStringFunction(const std::string& functionName, |
nothing calls this directly
no test coverage detected