Skip to content

Commit

Permalink
move spark.sql.hive.verifyPartitionPath to SQLConf,fix scala style
Browse files Browse the repository at this point in the history
  • Loading branch information
lazyman500 committed Apr 6, 2015
1 parent e1d6386 commit 5bfcbfd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ private[spark] object SQLConf {
val PARQUET_FILTER_PUSHDOWN_ENABLED = "spark.sql.parquet.filterPushdown"
val PARQUET_USE_DATA_SOURCE_API = "spark.sql.parquet.useDataSourceApi"

val HIVE_VERIFY_PARTITIONPATH = "spark.sql.hive.verifyPartitionPath"

val COLUMN_NAME_OF_CORRUPT_RECORD = "spark.sql.columnNameOfCorruptRecord"
val BROADCAST_TIMEOUT = "spark.sql.broadcastTimeout"

Expand Down Expand Up @@ -119,6 +121,10 @@ private[sql] class SQLConf extends Serializable {
private[spark] def parquetUseDataSourceApi =
getConf(PARQUET_USE_DATA_SOURCE_API, "true").toBoolean

/** When true uses verifyPartitionPath to prune the path which is not exists. */
private[spark] def verifyPartitionPath =
getConf(HIVE_VERIFY_PARTITIONPATH, "true").toBoolean

/** When true the planner will use the external sort, which may spill to disk. */
private[spark] def externalSortEnabled: Boolean = getConf(EXTERNAL_SORT, "false").toBoolean

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class HadoopTableReader(
def verifyPartitionPath(
partitionToDeserializer: Map[HivePartition, Class[_ <: Deserializer]]):
Map[HivePartition, Class[_ <: Deserializer]] = {
if (!sc.getConf("spark.sql.hive.verifyPartitionPath", "true").toBoolean) {
if (!sc.conf.verifyPartitionPath) {
partitionToDeserializer
} else {
var existPathSet = collection.mutable.Set[String]()
Expand All @@ -158,9 +158,9 @@ class HadoopTableReader(
val pathPattern = new Path(pathPatternStr)
val fs = pathPattern.getFileSystem(sc.hiveconf)
val matches = fs.globStatus(pathPattern)
matches.map(fileStatus => existPathSet += fileStatus.getPath.toString)
matches.foreach(fileStatus => existPathSet += fileStatus.getPath.toString)
}
// convert /demo/data/year/month/day to /demo/data/**/**/**/
// convert /demo/data/year/month/day to /demo/data/*/*/*/
def getPathPatternByPath(parNum: Int, tempPath: Path): String = {
var path = tempPath
for (i <- (1 to parNum)) path = path.getParent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ class QueryPartitionSuite extends QueryTest {
sql("DROP TABLE table_with_partition")
sql("DROP TABLE createAndInsertTest")
}
}
}

0 comments on commit 5bfcbfd

Please sign in to comment.