Skip to content

Commit

Permalink
[SPARK-27844][SQL] Avoid hard-coded config: spark.rdd.parallelListing…
Browse files Browse the repository at this point in the history
…Threshold in SQL module

## What changes were proposed in this pull request?

Avoid hard-coded config: `spark.rdd.parallelListingThreshold`.

## How was this patch tested?

N/A

Closes apache#24708 from wangyum/spark.rdd.parallelListingThreshold.

Authored-by: Yuming Wang <yumwang@ebay.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
  • Loading branch information
wangyum authored and dongjoon-hyun committed May 26, 2019
1 parent 193304b commit 447bfde
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs._
import org.apache.hadoop.mapred.{FileInputFormat, JobConf}

import org.apache.spark.internal.config.RDD_PARALLEL_LISTING_THRESHOLD
import org.apache.spark.sql.{AnalysisException, Row, SparkSession}
import org.apache.spark.sql.catalyst.TableIdentifier
import org.apache.spark.sql.catalyst.analysis.Resolver
Expand Down Expand Up @@ -613,7 +614,7 @@ case class AlterTableRecoverPartitionsCommand(
val hadoopConf = spark.sessionState.newHadoopConf()
val fs = root.getFileSystem(hadoopConf)

val threshold = spark.conf.get("spark.rdd.parallelListingThreshold", "10").toInt
val threshold = spark.sparkContext.conf.get(RDD_PARALLEL_LISTING_THRESHOLD)
val pathFilter = getPathFilter(hadoopConf)

val evalPool = ThreadUtils.newForkJoinPool("AlterTableRecoverPartitionsCommand", 8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.apache.hadoop.fs.Path
import org.scalatest.BeforeAndAfterEach

import org.apache.spark.internal.config
import org.apache.spark.internal.config.RDD_PARALLEL_LISTING_THRESHOLD
import org.apache.spark.sql.{AnalysisException, QueryTest, Row, SaveMode}
import org.apache.spark.sql.catalyst.TableIdentifier
import org.apache.spark.sql.catalyst.analysis.{FunctionRegistry, NoSuchPartitionException, NoSuchTableException, TempTableAlreadyExistsException}
Expand Down Expand Up @@ -1122,13 +1123,13 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
}

test("alter table: recover partitions (sequential)") {
withSQLConf("spark.rdd.parallelListingThreshold" -> "10") {
withSQLConf(RDD_PARALLEL_LISTING_THRESHOLD.key -> "10") {
testRecoverPartitions()
}
}

test("alter table: recover partition (parallel)") {
withSQLConf("spark.rdd.parallelListingThreshold" -> "0") {
withSQLConf(RDD_PARALLEL_LISTING_THRESHOLD.key -> "0") {
testRecoverPartitions()
}
}
Expand Down

0 comments on commit 447bfde

Please sign in to comment.