panbingkun commented on code in PR #41314:
URL: https://github.com/apache/spark/pull/41314#discussion_r1205618825
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TimeTravelSpec.scala:
##########
@@ -38,21 +38,25 @@ object TimeTravelSpec {
val ts = timestamp.get
assert(ts.resolved && ts.references.isEmpty &&
!SubqueryExpression.hasSubquery(ts))
if (!Cast.canAnsiCast(ts.dataType, TimestampType)) {
- throw QueryCompilationErrors.invalidTimestampExprForTimeTravel(ts)
+ throw QueryCompilationErrors.invalidTimestampExprForTimeTravel(
+ "INVALID_TIME_TRAVEL_TIMESTAMP_EXPR.DATA_TYPE", ts, ts.dataType)
}
val tsToEval = ts.transform {
case r: RuntimeReplaceable => r.replacement
case _: Unevaluable =>
- throw QueryCompilationErrors.invalidTimestampExprForTimeTravel(ts)
+ throw QueryCompilationErrors.invalidTimestampExprForTimeTravel(
+ "INVALID_TIME_TRAVEL_TIMESTAMP_EXPR.UNEVALUABLE", ts)
case e if !e.deterministic =>
- throw QueryCompilationErrors.invalidTimestampExprForTimeTravel(ts)
+ throw QueryCompilationErrors.invalidTimestampExprForTimeTravel(
+ "INVALID_TIME_TRAVEL_TIMESTAMP_EXPR.NON_DETERMINISTIC", ts)
}
val tz = Some(conf.sessionLocalTimeZone)
// Set `ansiEnabled` to false, so that it can return null for invalid
input and we can provide
// better error message.
val value = Cast(tsToEval, TimestampType, tz, ansiEnabled = false).eval()
if (value == null) {
- throw QueryCompilationErrors.invalidTimestampExprForTimeTravel(ts)
+ throw QueryCompilationErrors.invalidTimestampExprForTimeTravel(
Review Comment:
Although logically speaking, one is `can't ansi cast` and the other is
`can't cast`, they should belong to a kind of errors.
Perhaps one is called `INVALID_TIME_TRAVEL_TIMESTAMP_EXPR.ANSI_DATA_TYPE`,
and the other is called `INVALID_TIME_TRAVEL_TIMESTAMP_EXPR.DATA_TYPE`?
Will it cause confusion for users?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]