gengliangwang commented on a change in pull request #34985:
URL: https://github.com/apache/spark/pull/34985#discussion_r773911926



##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/AnsiCastSuiteBase.scala
##########
@@ -139,29 +139,35 @@ abstract class AnsiCastSuiteBase extends CastSuiteBase {
       cast(Literal(134.12), DecimalType(3, 2)), "cannot be represented")
   }
 
-  test("ANSI mode: disallow type conversions between Numeric types and 
Timestamp type") {
-    import DataTypeTestUtils.numericTypes
-    checkInvalidCastFromNumericType(TimestampType)
-    var errorMsg =
-      "you can use functions 
TIMESTAMP_SECONDS/TIMESTAMP_MILLIS/TIMESTAMP_MICROS instead"
-    verifyCastFailure(cast(Literal(0L), TimestampType), Some(errorMsg))
-
-    val timestampLiteral = Literal(1L, TimestampType)
-    errorMsg = "you can use functions UNIX_SECONDS/UNIX_MILLIS/UNIX_MICROS 
instead."
-    numericTypes.foreach { numericType =>
-      verifyCastFailure(cast(timestampLiteral, numericType), Some(errorMsg))
+  test("ANSI mode: disallow type conversions between Numeric types and 
Timestamp type"

Review comment:
       updated

##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/AnsiCastSuiteBase.scala
##########
@@ -139,29 +139,35 @@ abstract class AnsiCastSuiteBase extends CastSuiteBase {
       cast(Literal(134.12), DecimalType(3, 2)), "cannot be represented")
   }
 
-  test("ANSI mode: disallow type conversions between Numeric types and 
Timestamp type") {
-    import DataTypeTestUtils.numericTypes
-    checkInvalidCastFromNumericType(TimestampType)
-    var errorMsg =
-      "you can use functions 
TIMESTAMP_SECONDS/TIMESTAMP_MILLIS/TIMESTAMP_MICROS instead"
-    verifyCastFailure(cast(Literal(0L), TimestampType), Some(errorMsg))
-
-    val timestampLiteral = Literal(1L, TimestampType)
-    errorMsg = "you can use functions UNIX_SECONDS/UNIX_MILLIS/UNIX_MICROS 
instead."
-    numericTypes.foreach { numericType =>
-      verifyCastFailure(cast(timestampLiteral, numericType), Some(errorMsg))
+  test("ANSI mode: disallow type conversions between Numeric types and 
Timestamp type"
+    + s"${SQLConf.ALLOW_CAST_BETWEEN_DATETIME_AND_NUMERIC_IN_ANSI.key} is 
false") {
+    withSQLConf(SQLConf.ALLOW_CAST_BETWEEN_DATETIME_AND_NUMERIC_IN_ANSI.key -> 
"false") {
+      import DataTypeTestUtils.numericTypes
+      checkInvalidCastFromNumericType(TimestampType)
+      var errorMsg =
+        "you can use functions 
TIMESTAMP_SECONDS/TIMESTAMP_MILLIS/TIMESTAMP_MICROS instead"
+      verifyCastFailure(cast(Literal(0L), TimestampType), Some(errorMsg))
+
+      val timestampLiteral = Literal(1L, TimestampType)
+      errorMsg = "you can use functions UNIX_SECONDS/UNIX_MILLIS/UNIX_MICROS 
instead."
+      numericTypes.foreach { numericType =>
+        verifyCastFailure(cast(timestampLiteral, numericType), Some(errorMsg))
+      }
     }
   }
 
-  test("ANSI mode: disallow type conversions between Numeric types and Date 
type") {
-    import DataTypeTestUtils.numericTypes
-    checkInvalidCastFromNumericType(DateType)
-    var errorMsg = "you can use function DATE_FROM_UNIX_DATE instead"
-    verifyCastFailure(cast(Literal(0L), DateType), Some(errorMsg))
-    val dateLiteral = Literal(1, DateType)
-    errorMsg = "you can use function UNIX_DATE instead"
-    numericTypes.foreach { numericType =>
-      verifyCastFailure(cast(dateLiteral, numericType), Some(errorMsg))
+  test("ANSI mode: disallow type conversions between Numeric types and Date 
type"

Review comment:
       updated




-- 
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]

Reply via email to