cloud-fan commented on code in PR #45409:
URL: https://github.com/apache/spark/pull/45409#discussion_r1515426129


##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/SaveIntoDataSourceCommandSuite.scala:
##########
@@ -71,6 +71,39 @@ class SaveIntoDataSourceCommandSuite extends QueryTest with 
SharedSparkSession {
 
     FakeV1DataSource.data = null
   }
+
+  test("Data type support") {
+
+    val dataSource = DataSource(
+      sparkSession = spark,
+      className = "jdbc",
+      partitionColumns = Nil,
+      options = Map())
+
+    val df = spark.range(1).selectExpr(
+        "cast('a' as binary) a", "true b", "cast(1 as byte) c", "1.23 d")
+    dataSource.planForWriting(SaveMode.ErrorIfExists, df.logicalPlan)
+
+    withSQLConf("spark.databricks.variant.enabled" -> "true") {
+      // Variant and Interval types are disallowed by default.
+      val unsupportedTypes = Seq(
+          "parse_json('1') v",
+          "array(parse_json('1'))",
+          "struct(1, parse_json('1')) s",
+          "map(1, parse_json('1')) s",
+          "INTERVAL '1' MONTH i",
+          "make_ym_interval(1, 2) ym",
+          "make_dt_interval(1, 2, 3, 4) dt")
+
+      unsupportedTypes.foreach { expr =>
+        val df = spark.range(1).selectExpr(expr)
+        val e = intercept[AnalysisException] {
+          dataSource.planForWriting(SaveMode.ErrorIfExists, df.logicalPlan)
+        }
+        assert(e.getMessage.contains("UNSUPPORTED_DATA_TYPE_FOR_DATASOURCE"))

Review Comment:
   let's use `checkError` for it.



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