Skip to content

Commit

Permalink
[VL] Support cast timestamp to date
Browse files Browse the repository at this point in the history
  • Loading branch information
zml1206 committed Dec 12, 2024
1 parent e12db45 commit 49f81d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,13 @@ class MiscOperatorSuite extends VeloxWholeStageTransformerSuite with AdaptiveSpa
assert(plan2.find(_.isInstanceOf[ProjectExecTransformer]).isDefined)
}

test("cast timestamp to date") {
val query = "select cast(ts as date) from values (timestamp'2024-01-01 00:00:00') as tab(ts)"
runQueryAndCompare(query) {
checkGlutenOperatorMatch[ProjectExecTransformer]
}
}

test("timestamp broadcast join") {
spark.range(0, 5).createOrReplaceTempView("right")
spark.sql("SELECT id, timestamp_micros(id) as ts from right").createOrReplaceTempView("left")
Expand Down
10 changes: 6 additions & 4 deletions cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,12 @@ bool SubstraitToVeloxPlanValidator::validateCast(
case TypeKind::VARBINARY:
LOG_VALIDATION_MSG("Invalid input type in casting: ARRAY/MAP/ROW/VARBINARY.");
return false;
case TypeKind::TIMESTAMP: {
LOG_VALIDATION_MSG("Casting from TIMESTAMP is not supported or has incorrect result.");
return false;
}
case TypeKind::TIMESTAMP:
// Only support cast timestamp to date
if (!toType->isDate()) {
LOG_VALIDATION_MSG("Casting from TIMESTAMP is not supported or has incorrect result.");
return false;
}
default: {
}
}
Expand Down

0 comments on commit 49f81d9

Please sign in to comment.