maropu commented on a change in pull request #26472: [SPARK-29838][SQL]
PostgreSQL dialect: cast to timestamp
URL: https://github.com/apache/spark/pull/26472#discussion_r348433796
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/PostgreSQLDialectQuerySuite.scala
##########
@@ -39,4 +39,15 @@ class PostgreSQLDialectQuerySuite extends QueryTest with
SharedSparkSession {
intercept[IllegalArgumentException](sql(s"select cast('$input' as
boolean)").collect())
}
}
+
+ test("cast to timestamp") {
+ Seq(1, 0.1, 1.toDouble, 5.toFloat, true, 3.toByte, 4.toShort) foreach {
value =>
+ val actualResult = intercept[AnalysisException](
+ sql(s"SELECT CAST(${value} AS timestamp)")
+ ).getMessage
+ val expectedResult = s"cannot cast type ${value.getClass} to timestamp"
+ assert(actualResult.contains(expectedResult))
+ }
+ }
Review comment:
Can you move these tests to `SQLQueryTestSuite`,e.g.,
`input/postgreSQL/cast.sql`?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]