Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/16593#discussion_r96849182
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
---
@@ -1384,4 +1394,96 @@ class HiveDDLSuite
assert(e2.message.contains("Hive data source can only be used with
tables"))
}
}
+
+ test("the columns order in catalog should respect the order when create
table") {
+ withTable("t", "t1", "t2", "t3") {
+ val structType = Seq(("a", IntegerType), ("b", IntegerType),
+ ("c", StringType), ("d", StringType))
+ val partStructType = Seq(("c", StringType), ("d", StringType))
+
+ sql(
+ """CREATE TABLE IF NOT EXISTS t(a int, b int, c string, d string)
+ | using parquet
+ | partitioned by (c, d)""".stripMargin)
+ var table =
spark.sessionState.catalog.getTableMetadata(TableIdentifier("t"))
+ assert(table.schema.map(s => (s.name, s.dataType)) == structType)
+ assert(table.partitionSchema.map(s => (s.name, s.dataType)) ==
partStructType)
+
+ val structType1 = Seq(("b", IntegerType), ("a", IntegerType),
+ ("d", StringType), ("c", StringType))
+ val partStructType1 = Seq(("d", StringType), ("c", StringType))
+
+ sql(
+ """CREATE TABLE IF NOT EXISTS t1(b int, a int, c string, d string)
--- End diff --
let's not add new test for the legacy hive syntax anymore, please use
`create table xxx using hive`
---
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]