Skip to content

Commit 5c08c86

Browse files
committed
[SPARK-10198] [SQL] Turn off partition verification by default
Author: Michael Armbrust <[email protected]> Closes #8404 from marmbrus/turnOffPartitionVerification.
1 parent 69c9c17 commit 5c08c86

File tree

2 files changed

+35
-31
lines changed

2 files changed

+35
-31
lines changed

sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ private[spark] object SQLConf {
312312
doc = "When true, enable filter pushdown for ORC files.")
313313

314314
val HIVE_VERIFY_PARTITION_PATH = booleanConf("spark.sql.hive.verifyPartitionPath",
315-
defaultValue = Some(true),
315+
defaultValue = Some(false),
316316
doc = "<TODO>")
317317

318318
val HIVE_METASTORE_PARTITION_PRUNING = booleanConf("spark.sql.hive.metastorePartitionPruning",

sql/hive/src/test/scala/org/apache/spark/sql/hive/QueryPartitionSuite.scala

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,54 @@
1818
package org.apache.spark.sql.hive
1919

2020
import com.google.common.io.Files
21+
import org.apache.spark.sql.test.SQLTestUtils
2122

2223
import org.apache.spark.sql.{QueryTest, _}
2324
import org.apache.spark.util.Utils
2425

2526

26-
class QueryPartitionSuite extends QueryTest {
27+
class QueryPartitionSuite extends QueryTest with SQLTestUtils {
2728

2829
private lazy val ctx = org.apache.spark.sql.hive.test.TestHive
2930
import ctx.implicits._
30-
import ctx.sql
31+
32+
protected def _sqlContext = ctx
3133

3234
test("SPARK-5068: query data when path doesn't exist"){
33-
val testData = ctx.sparkContext.parallelize(
34-
(1 to 10).map(i => TestData(i, i.toString))).toDF()
35-
testData.registerTempTable("testData")
35+
withSQLConf((SQLConf.HIVE_VERIFY_PARTITION_PATH.key, "true")) {
36+
val testData = ctx.sparkContext.parallelize(
37+
(1 to 10).map(i => TestData(i, i.toString))).toDF()
38+
testData.registerTempTable("testData")
3639

37-
val tmpDir = Files.createTempDir()
38-
// create the table for test
39-
sql(s"CREATE TABLE table_with_partition(key int,value string) " +
40-
s"PARTITIONED by (ds string) location '${tmpDir.toURI.toString}' ")
41-
sql("INSERT OVERWRITE TABLE table_with_partition partition (ds='1') " +
42-
"SELECT key,value FROM testData")
43-
sql("INSERT OVERWRITE TABLE table_with_partition partition (ds='2') " +
44-
"SELECT key,value FROM testData")
45-
sql("INSERT OVERWRITE TABLE table_with_partition partition (ds='3') " +
46-
"SELECT key,value FROM testData")
47-
sql("INSERT OVERWRITE TABLE table_with_partition partition (ds='4') " +
48-
"SELECT key,value FROM testData")
40+
val tmpDir = Files.createTempDir()
41+
// create the table for test
42+
sql(s"CREATE TABLE table_with_partition(key int,value string) " +
43+
s"PARTITIONED by (ds string) location '${tmpDir.toURI.toString}' ")
44+
sql("INSERT OVERWRITE TABLE table_with_partition partition (ds='1') " +
45+
"SELECT key,value FROM testData")
46+
sql("INSERT OVERWRITE TABLE table_with_partition partition (ds='2') " +
47+
"SELECT key,value FROM testData")
48+
sql("INSERT OVERWRITE TABLE table_with_partition partition (ds='3') " +
49+
"SELECT key,value FROM testData")
50+
sql("INSERT OVERWRITE TABLE table_with_partition partition (ds='4') " +
51+
"SELECT key,value FROM testData")
4952

50-
// test for the exist path
51-
checkAnswer(sql("select key,value from table_with_partition"),
52-
testData.toDF.collect ++ testData.toDF.collect
53-
++ testData.toDF.collect ++ testData.toDF.collect)
53+
// test for the exist path
54+
checkAnswer(sql("select key,value from table_with_partition"),
55+
testData.toDF.collect ++ testData.toDF.collect
56+
++ testData.toDF.collect ++ testData.toDF.collect)
5457

55-
// delete the path of one partition
56-
tmpDir.listFiles
57-
.find { f => f.isDirectory && f.getName().startsWith("ds=") }
58-
.foreach { f => Utils.deleteRecursively(f) }
58+
// delete the path of one partition
59+
tmpDir.listFiles
60+
.find { f => f.isDirectory && f.getName().startsWith("ds=") }
61+
.foreach { f => Utils.deleteRecursively(f) }
5962

60-
// test for after delete the path
61-
checkAnswer(sql("select key,value from table_with_partition"),
62-
testData.toDF.collect ++ testData.toDF.collect ++ testData.toDF.collect)
63+
// test for after delete the path
64+
checkAnswer(sql("select key,value from table_with_partition"),
65+
testData.toDF.collect ++ testData.toDF.collect ++ testData.toDF.collect)
6366

64-
sql("DROP TABLE table_with_partition")
65-
sql("DROP TABLE createAndInsertTest")
67+
sql("DROP TABLE table_with_partition")
68+
sql("DROP TABLE createAndInsertTest")
69+
}
6670
}
6771
}

0 commit comments

Comments
 (0)