| 386 | } |
| 387 | |
| 388 | bool ExpressionUtil::tryCombineDataType(const expression_vector& expressions, LogicalType& result) { |
| 389 | std::vector<Value> secondaryValues; |
| 390 | std::vector<LogicalType> primaryTypes; |
| 391 | for (auto& expr : expressions) { |
| 392 | if (expr->expressionType != ExpressionType::LITERAL) { |
| 393 | primaryTypes.push_back(expr->getDataType().copy()); |
| 394 | continue; |
| 395 | } |
| 396 | auto literalExpr = expr->constPtrCast<LiteralExpression>(); |
| 397 | if (literalExpr->getValue().allowTypeChange()) { |
| 398 | secondaryValues.push_back(literalExpr->getValue()); |
| 399 | continue; |
| 400 | } |
| 401 | primaryTypes.push_back(expr->getDataType().copy()); |
| 402 | } |
| 403 | if (!LogicalTypeUtils::tryGetMaxLogicalType(primaryTypes, result)) { |
| 404 | return false; |
| 405 | } |
| 406 | for (auto& value : secondaryValues) { |
| 407 | if (compatible(value, result)) { |
| 408 | continue; |
| 409 | } |
| 410 | if (!LogicalTypeUtils::tryGetMaxLogicalType(result, value.getDataType(), result)) { |
| 411 | return false; |
| 412 | } |
| 413 | } |
| 414 | return true; |
| 415 | } |
| 416 | |
| 417 | bool ExpressionUtil::canCastStatically(const Expression& expr, const LogicalType& targetType) { |
| 418 | switch (expr.expressionType) { |
nothing calls this directly
no test coverage detected