Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Dec 27, 2024
1 parent 2b99fff commit 446e56a
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,29 +269,33 @@ bool SubstraitToVeloxPlanValidator::validateCast(
const auto& toType = SubstraitParser::parseType(castExpr.type());
core::TypedExprPtr input = exprConverter_->toVeloxExpr(castExpr.input(), inputType);

// Only support cast from date to timestamp
if (toType->kind() == TypeKind::TIMESTAMP && !input->type()->isDate()) {
LOG_VALIDATION_MSG(
"Casting from " + input->type()->toString() + " to " + toType->toString() + " is not supported.");
return false;
// Only support casting from date or varchar to timestamp.
switch (toType->kind()) {
case TypeKind::TIMESTAMP: {
if (!input->type()->isDate() && input->type()->kind() != TypeKind::VARCHAR) {
LOG_VALIDATION_MSG(
"Casting from " + input->type()->toString() + " to " + toType->toString() + " is not supported.");
return false;
}
}
default: {
}
}

if (toType->isIntervalYearMonth()) {
LOG_VALIDATION_MSG("Casting to " + toType->toString() + " is not supported.");
if (input->type()->isIntervalYearMonth() || toType->isIntervalYearMonth()) {
LOG_VALIDATION_MSG("Casting from/to IntervalYearMonthType is not supported.");
return false;
}

// Casting from some types is not supported. See CastExpr::applyPeeled.
if (input->type()->isDate()) {
// Only support cast date to varchar & timestamp
// Only support casting from date to varchar or timestamp
if (toType->kind() != TypeKind::VARCHAR && toType->kind() != TypeKind::TIMESTAMP) {
LOG_VALIDATION_MSG("Casting from DATE to " + toType->toString() + " is not supported.");
return false;
}
} else if (input->type()->isIntervalYearMonth()) {
LOG_VALIDATION_MSG("Casting from INTERVAL_YEAR_MONTH is not supported.");
return false;
}

switch (input->type()->kind()) {
case TypeKind::ARRAY:
case TypeKind::MAP:
Expand Down

0 comments on commit 446e56a

Please sign in to comment.