aboutsummaryrefslogtreecommitdiff
path: root/sql/hive/src/test/scala
diff options
context:
space:
mode:
authorgatorsmile <gatorsmile@gmail.com>2016-09-04 15:04:33 +0800
committerWenchen Fan <wenchen@databricks.com>2016-09-04 15:04:33 +0800
commit6b156e2fcf9c0c1ed0770a7ad9c54fa374760e17 (patch)
tree593ff90402b847fe4ed225e961d4d34e506eb62b /sql/hive/src/test/scala
parente9b58e9ef89a9118b6d5a466d10db8e30d61f850 (diff)
downloadspark-6b156e2fcf9c0c1ed0770a7ad9c54fa374760e17.tar.gz
spark-6b156e2fcf9c0c1ed0770a7ad9c54fa374760e17.tar.bz2
spark-6b156e2fcf9c0c1ed0770a7ad9c54fa374760e17.zip
[SPARK-17324][SQL] Remove Direct Usage of HiveClient in InsertIntoHiveTable
### What changes were proposed in this pull request? This is another step to get rid of HiveClient from `HiveSessionState`. All the metastore interactions should be through `ExternalCatalog` interface. However, the existing implementation of `InsertIntoHiveTable ` still requires Hive clients. This PR is to remove HiveClient by moving the metastore interactions into `ExternalCatalog`. ### How was this patch tested? Existing test cases Author: gatorsmile <gatorsmile@gmail.com> Closes #14888 from gatorsmile/removeClientFromInsertIntoHiveTable.
Diffstat (limited to 'sql/hive/src/test/scala')
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/client/VersionsSuite.scala12
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala38
2 files changed, 44 insertions, 6 deletions
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/client/VersionsSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/client/VersionsSuite.scala
index 10b6cd1024..9a10957c8e 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/client/VersionsSuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/client/VersionsSuite.scala
@@ -337,12 +337,12 @@ class VersionsSuite extends SparkFunSuite with Logging {
client.loadPartition(
emptyDir,
- "default.src_part",
+ "default",
+ "src_part",
partSpec,
replace = false,
holdDDLTime = false,
- inheritTableSpecs = false,
- isSkewedStoreAsSubdir = false)
+ inheritTableSpecs = false)
}
test(s"$version: loadDynamicPartitions") {
@@ -352,12 +352,12 @@ class VersionsSuite extends SparkFunSuite with Logging {
client.loadDynamicPartitions(
emptyDir,
- "default.src_part",
+ "default",
+ "src_part",
partSpec,
replace = false,
numDP = 1,
- false,
- false)
+ holdDDLTime = false)
}
test(s"$version: renamePartitions") {
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
index 7f3d96de85..eff32805bf 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
@@ -932,6 +932,44 @@ class HiveDDLSuite
}
}
+ test("insert skewed table") {
+ val tabName = "tab1"
+ withTable(tabName) {
+ // Spark SQL does not support creating skewed table. Thus, we have to use Hive client.
+ val client = spark.sharedState.externalCatalog.asInstanceOf[HiveExternalCatalog].client
+ client.runSqlHive(
+ s"""
+ |CREATE Table $tabName(col1 int, col2 int)
+ |PARTITIONED BY (part1 string, part2 string)
+ |SKEWED BY (col1) ON (3, 4) STORED AS DIRECTORIES
+ """.stripMargin)
+ val hiveTable =
+ spark.sessionState.catalog.getTableMetadata(TableIdentifier(tabName, Some("default")))
+
+ assert(hiveTable.unsupportedFeatures.contains("skewed columns"))
+
+ // Call loadDynamicPartitions against a skewed table with enabling list bucketing
+ sql(
+ s"""
+ |INSERT OVERWRITE TABLE $tabName
+ |PARTITION (part1='a', part2)
+ |SELECT 3, 4, 'b'
+ """.stripMargin)
+
+ // Call loadPartitions against a skewed table with enabling list bucketing
+ sql(
+ s"""
+ |INSERT INTO TABLE $tabName
+ |PARTITION (part1='a', part2='b')
+ |SELECT 1, 2
+ """.stripMargin)
+
+ checkAnswer(
+ sql(s"SELECT * from $tabName"),
+ Row(3, 4, "a", "b") :: Row(1, 2, "a", "b") :: Nil)
+ }
+ }
+
test("desc table for data source table - no user-defined schema") {
Seq("parquet", "json", "orc").foreach { fileFormat =>
withTable("t1") {