Skip to content

Commit 9f621e7

Browse files
committed
fix
1 parent a6a0810 commit 9f621e7

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

sql/hive/src/test/scala/org/apache/spark/sql/hive/client/HiveClientSuite.scala

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ package org.apache.spark.sql.hive.client
1919

2020
import org.apache.hadoop.conf.Configuration
2121
import org.apache.hadoop.hive.conf.HiveConf
22+
import org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
23+
import org.apache.hadoop.hive.serde2.`lazy`.LazySimpleSerDe
24+
import org.apache.hadoop.mapred.TextInputFormat
2225
import org.scalatest.BeforeAndAfterAll
2326

27+
import org.apache.spark.sql.catalyst.TableIdentifier
2428
import org.apache.spark.sql.catalyst.catalog._
2529
import org.apache.spark.sql.catalyst.dsl.expressions._
2630
import org.apache.spark.sql.catalyst.expressions._
27-
import org.apache.spark.sql.types.{BooleanType, IntegerType, LongType}
31+
import org.apache.spark.sql.types.{BooleanType, IntegerType, LongType, StructType}
2832

2933
// TODO: Refactor this to `HivePartitionFilteringSuite`
3034
class HiveClientSuite(version: String)
@@ -46,7 +50,22 @@ class HiveClientSuite(version: String)
4650
val hadoopConf = new Configuration()
4751
hadoopConf.setBoolean(tryDirectSqlKey, tryDirectSql)
4852
val client = buildClient(hadoopConf)
49-
client.runSqlHive("CREATE TABLE test (value INT) PARTITIONED BY (ds INT, h INT, chunk STRING)")
53+
val tableSchema =
54+
new StructType().add("value", "int").add("ds", "int").add("h", "int").add("chunk", "string")
55+
val table = CatalogTable(
56+
identifier = TableIdentifier("test", Some("default")),
57+
tableType = CatalogTableType.MANAGED,
58+
schema = tableSchema,
59+
partitionColumnNames = Seq("ds", "h", "chunk"),
60+
storage = CatalogStorageFormat(
61+
locationUri = None,
62+
inputFormat = Some(classOf[TextInputFormat].getName),
63+
outputFormat = Some(classOf[HiveIgnoreKeyTextOutputFormat[_, _]].getName),
64+
serde = Some(classOf[LazySimpleSerDe].getName()),
65+
compressed = false,
66+
properties = Map.empty
67+
))
68+
client.createTable(table, ignoreIfExists = false)
5069

5170
val partitions =
5271
for {

sql/hive/src/test/scala/org/apache/spark/sql/hive/client/HiveVersionSuite.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ private[client] abstract class HiveVersionSuite(version: String) extends SparkFu
3939
hadoopConf.set("datanucleus.schema.autoCreateAll", "true")
4040
hadoopConf.set("hive.metastore.schema.verification", "false")
4141
}
42+
// Since Hive 3.0, HIVE-19310 skipped `ensureDbInit` if `hive.in.test=false`.
43+
if (version == "3.1") {
44+
hadoopConf.set("hive.in.test", "true")
45+
}
4246
HiveClientBuilder.buildClient(
4347
version,
4448
hadoopConf,

0 commit comments

Comments
 (0)