Skip to content
Closed
Changes from 1 commit
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 @@ -529,37 +529,39 @@ class FileSourceStrategySuite extends QueryTest with SharedSparkSession with Pre
}

test("SPARK-32019: Add spark.sql.files.minPartitionNum config") {
withSQLConf(SQLConf.FILES_MIN_PARTITION_NUM.key -> "1") {
val table =
createTable(files = Seq(
"file1" -> 1,
"file2" -> 1,
"file3" -> 1
))
assert(table.rdd.partitions.length == 1)
}
withSQLConf(SQLConf.FILES_MAX_PARTITION_BYTES.key -> "2MB") {

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.

Can we add the config spark.sql.files.openCostInBytes ? The result is based on it although we don't change the default 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.

Done

withSQLConf(SQLConf.FILES_MIN_PARTITION_NUM.key -> "1") {

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.

I think it is okay just to update the slow two tests only in this PR.

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.

Done

val table =
createTable(files = Seq(
"file1" -> 1,
"file2" -> 1,
"file3" -> 1
))
assert(table.rdd.partitions.length == 3)
}

withSQLConf(SQLConf.FILES_MIN_PARTITION_NUM.key -> "10") {
val table =
createTable(files = Seq(
"file1" -> 1,
"file2" -> 1,
"file3" -> 1
))
assert(table.rdd.partitions.length == 3)
}
withSQLConf(SQLConf.FILES_MIN_PARTITION_NUM.key -> "10") {
val table =
createTable(files = Seq(
"file1" -> 1,
"file2" -> 1,
"file3" -> 1
))
assert(table.rdd.partitions.length == 3)
}

withSQLConf(SQLConf.FILES_MIN_PARTITION_NUM.key -> "16") {
val partitions = (1 to 100).map(i => s"file$i" -> 128 * 1024 * 1024)
val table = createTable(files = partitions)
// partition is limited by filesMaxPartitionBytes(128MB)
assert(table.rdd.partitions.length == 100)
}
withSQLConf(SQLConf.FILES_MIN_PARTITION_NUM.key -> "8") {
val partitions = (1 to 12).map(i => s"file$i" -> 2 * 1024 * 1024)
val table = createTable(files = partitions)
// partition is limited by filesMaxPartitionBytes(2MB)
assert(table.rdd.partitions.length == 12)
}

withSQLConf(SQLConf.FILES_MIN_PARTITION_NUM.key -> "32") {
val partitions = (1 to 800).map(i => s"file$i" -> 4 * 1024 * 1024)
val table = createTable(files = partitions)
assert(table.rdd.partitions.length == 50)
withSQLConf(SQLConf.FILES_MIN_PARTITION_NUM.key -> "8") {

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.

8 -> 16 for keeping the original test context?

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.

Sure

val partitions = (1 to 12).map(i => s"file$i" -> 4 * 1024 * 1024)
val table = createTable(files = partitions)
assert(table.rdd.partitions.length == 24)
}
}
}

Expand Down