ulysses-you commented on a change in pull request #28853: URL: https://github.com/apache/spark/pull/28853#discussion_r442911313
########## File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategySuite.scala ########## @@ -528,6 +528,41 @@ 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_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 limit by filesMaxPartitionBytes(128MB) + assert(table.rdd.partitions.length == 100) + } + + 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) Review comment: `800 * (4 + 4) / 32 > 128`, and use 128 as maxSplitSize, `800 * (4 + 4) / 128 = 50` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org