You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "panbingkun (via GitHub)" <gi...@apache.org> on 2023/05/25 14:38:07 UTC

[GitHub] [spark] panbingkun commented on a diff in pull request #41314: [SPARK-43794][SQL] Assign a name to the error class _LEGACY_ERROR_TEMP_1335

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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org