Repository navigation
Conversation
2190ef0 to
9f66a97
Compare
67cd38c to
1aa676b
Compare
JingsongLi
left a comment
There was a problem hiding this comment.
On Spark 3.5.9, 35 write-distribution cases passed and eight version-specific cases were skipped. The AQE tests verified actual stage task counts and row readback. The new connector option description needs its scope stated.
| .intType() | ||
| .noDefaultValue() | ||
| .withDescription( | ||
| "Defines a custom parallelism for the sink. " |
There was a problem hiding this comment.
[P2] Document that this setting controls only the fixed-bucket write shuffle
This description becomes the public Spark connector configuration. It currently promises custom sink parallelism with no mention of table mode, and only describes an unset value. The implementation and passing tests show that bucket-unaware writes retain their input partition count, and zero or negative values leave Spark's choice in place. Please state that a positive value controls the final fixed-bucket V1/V2 write shuffle and that unset or non-positive values use Spark's default planning.
There was a problem hiding this comment.
I reran V2WriteRequireDistributionTest on f56878b404 with Spark 3.5.9. All 35 applicable cases passed, including the V1 and V2 writes with write.parallelism=7, 0, and -1. The documentation now states the fixed-bucket scope. Please also say that a positive value sets the write shuffle parallelism and that zero or negative values use the same Spark planning as an unset option.
There was a problem hiding this comment.
@JingsongLi Thanks for reviewing! Agreed. I’ve updated the write.parallelism documentation to clarify that, for fixed-bucket tables, a positive value sets the number of shuffle partitions for the write. Setting it to zero or a negative value uses the same Spark planning as leaving it unset.
1aa676b to
f56878b
Compare
f56878b to
785cc85
Compare
|
What is the relationship to |
|
@JingsongLi Thanks for reviewing! I think Both options address write parallelism for fixed-bucket tables, but they solve different problems. Before this PR, the Paimon Spark connector had no dedicated option to set the number of shuffle partitions for a write.
|
JingsongLi
left a comment
There was a problem hiding this comment.
I verified on Spark 3.2.4 and 3.5.9 that fixed-bucket INSERT and INSERT OVERWRITE respect the table/session setting under AQE, including row readback on a partitioned primary-key table. The per-write option behaves differently.
|
|
||
| override def requiredNumPartitions(): Int = { | ||
| if (!PaimonWriteRequirement.requiresQueryPreparation && table.bucketMode() == HASH_FIXED) { | ||
| writeParallelism(coreOptions).getOrElse(0) |
There was a problem hiding this comment.
[P2] Make the scope of per-write parallelism explicit
On Spark 4.0.5 with AQE enabled, an existing fixed-bucket table with write.parallelism=7 writes with seven tasks even when df.writeTo(table).option("write.parallelism", "3").append() requests three, or "0" requests Spark's adaptive default. The physical plan confirms AppendDataExec. V1 saveAsTable append has the same behavior. This makes it easy for a job to appear to set its own task count while still using the table's value. Please either bind the operation option ahead of the table/session value in both paths, preserving zero as an explicit fallback, or document that this setting is supported only as a table or session property.
There was a problem hiding this comment.
@JingsongLi Thanks for reviewing!I agreed. I updated both V2 writeTo(...).append() and V1 saveAsTable append to honor the per-write write.parallelism option for fixed-bucket tables. I added regression tests for both paths. With the table set to 7, an explicit 3 produces three write tasks. An explicit 0 lets AQE choose the task count even with the session set to 5.
… standard option precedence.
Purpose
Closes #11412 . Related to #4742.
Add
write.parallelismto Spark's V1 and V2 write paths for tables inHASH_FIXEDbucket mode. A positive value sets the number of Spark partitions in the final shuffle by table partition and bucket. This lets users tune the number of write tasks independentlyof the table's bucket count and other shuffles in the query. When the option is unset, zero, or negative, Spark continues to choose the write parallelism.
For example, the following table uses 16 buckets and requests 7 write tasks:
Users can also set a session default with
SET spark.paimon.write.parallelism=7.Tests
V2WriteRequireDistributionTestto check the actual write-stage task count with AQE enabled for both V1 and V2. Coverage includes explicit and default parallelism, a custom bucket function, and bucket-unaware tables retaining their input partitions.