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

Method tryCombineDataType

src/binder/expression/expression_util.cpp:388–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

386}
387
388bool 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
417bool ExpressionUtil::canCastStatically(const Expression& expr, const LogicalType& targetType) {
418 switch (expr.expressionType) {

Callers

nothing calls this directly

Calls 6

compatibleFunction · 0.85
getDataTypeMethod · 0.80
allowTypeChangeMethod · 0.80
push_backMethod · 0.45
copyMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected