Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/13769#discussion_r67611533
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/InsertIntoHiveTableSuite.scala
---
@@ -372,4 +380,95 @@ class InsertIntoHiveTableSuite extends QueryTest with
TestHiveSingleton with Bef
assert(!logical.resolved, "Should not resolve: missing partition
data")
}
}
+
+ testPartitionedTable(
+ "SPARK-16036: better error message when insert into a table with
mismatch schema") {
+ tableName =>
+ val e = intercept[AnalysisException] {
+ sql(s"INSERT INTO TABLE $tableName PARTITION(b=1, c=2) SELECT 1,
2, 3")
+ }
+ assert(e.message.contains("the number of columns are different"))
+ }
+
+ testPartitionedTable(
+ "SPARK-16037: INSERT statement should match columns by position") {
+ tableName =>
+ withSQLConf("hive.exec.dynamic.partition.mode" -> "nonstrict") {
+ sql(s"INSERT INTO TABLE $tableName SELECT 1, 4, 2 AS c, 3 AS b")
+ checkAnswer(sql(s"SELECT a, b, c, d FROM $tableName"), Row(1, 2,
3, 4))
+ sql(s"INSERT OVERWRITE TABLE $tableName SELECT 1, 4, 2, 3")
+ checkAnswer(sql(s"SELECT a, b, c, 4 FROM $tableName"), Row(1, 2,
3, 4))
+ }
+ }
+
+ testPartitionedTable(
--- End diff --
These are new tests.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]