Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ object SQLConf {
.booleanConf
.createWithDefault(true)

val DEFAULT_PARALLELISM = buildConf("spark.sql.default.parallelism")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spark.sql.default.parallelism -> spark.sql.sessionLocalDefaultParallelism?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Em.. is it better to keep similar with spark.default.parallelism? so we can set this config easy. sessionLocalDefaultParallelism seems complex.

.doc("This config behavior is same as spark.default.parallelism, and this value can be " +
"isolated across sessions. Note: always use sc.defaultParallelism as default number.")

@maropu maropu Jun 10, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

The session-local default number of partitions and and this value is widely used inside physical plans.
If not set, the physical plans refer to `spark.default.parallelism` instead.

.version("3.1.0")
.intConf
.checkValue(_ > 0, "The value of spark.sql.default.parallelism must be positive")
.createOptional

val SHUFFLE_PARTITIONS = buildConf("spark.sql.shuffle.partitions")
.doc("The default number of partitions to use when shuffling data for joins or aggregations. " +
"Note: For structured streaming, this configuration cannot be changed between query " +
Expand Down Expand Up @@ -2784,6 +2792,8 @@ class SQLConf extends Serializable with Logging {

def cacheVectorizedReaderEnabled: Boolean = getConf(CACHE_VECTORIZED_READER_ENABLED)

def defaultParallelism: Option[Int] = getConf(DEFAULT_PARALLELISM)

def defaultNumShufflePartitions: Int = getConf(SHUFFLE_PARTITIONS)

def numShufflePartitions: Int = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ class SparkSession private(
*/
@transient lazy val conf: RuntimeConfig = new RuntimeConfig(sessionState.conf)

/**
* Same as `spark.default.parallelism`, can be isolated across sessions.
*
* @since 3.1.0
*/
def defaultParallelism: Int = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to not have this API, as SparkSession should provide high-level logical APIs, not physical ones.

sessionState.conf.defaultParallelism.getOrElse(sparkContext.defaultParallelism)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we add a config, whose only usage is to let users get the config value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said above. If add this config, I will move the exists defaultParallelism which in sql module follow up. e.g. FilePartition.maxSplitBytes()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just do this in this pr ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do, otherwise it's a useless config

}

/**
* An interface to register custom [[org.apache.spark.sql.util.QueryExecutionListener]]s
* that listen for execution metrics.
Expand Down