linhongliu-db commented on code in PR #60404:
URL: https://github.com/apache/spark/pull/60404#discussion_r4590107117


##########
core/src/main/scala/org/apache/spark/internal/config/package.scala:
##########
@@ -2934,6 +2934,17 @@ package object config {
       .checkValue(_ >= 0, "needs to be a non-negative value")
       .createWithDefault(0)
 
+  private[spark] val LEGACY_RANGE_PARTITIONER_RDD_ID_SEED =
+    ConfigBuilder("spark.rdd.rangePartitioner.legacyRddIdSeed")
+      .internal()
+      .doc("When true, RangePartitioner seeds the samples that pick its range 
bounds with the " +
+        "RDD id, so the bounds of the same data can change on every execution. 
When false, the " +
+        "seeds depend only on the partition index.")
+      .version("5.0.0")

Review Comment:
   Done in 37d9ebc: version `4.4.0`, note moved to the 4.3-to-4.4 section.



##########
docs/sql-migration-guide.md:
##########
@@ -25,6 +25,7 @@ license: |
 ## Upgrading from Spark SQL 4.4 to 5.0
 
 - Since Spark 5.0, the Spark Thrift Server refuses to start when 
`hive.server2.enable.doAs` is `true` and `hive.server2.authentication` verifies 
user identities (any recognized type other than `NONE`/`NOSASL`). It 
impersonates the connecting user for Hive metastore calls and driver-side file 
system access, but executor-side data access still runs as the server's own 
service identity, so storage-level permissions are checked against the service 
principal rather than the connecting user (SPARK-5159). Spark 4.4 logs a 
warning for the same configuration. To restore the previous behavior, set 
`spark.sql.hive.thriftServer.allowIneffectiveDoAs` to `true`. Setting 
`hive.server2.enable.doAs` to `false` also starts the server, but note that it 
stops impersonating metastore calls as well, so it is not a no-op.
+- Since Spark 5.0, the range bounds of a global sort no longer depend on an 
internal RDD id, so a `TABLESAMPLE ... REPEATABLE` (or a seeded 
`Dataset.sample`) over an `ORDER BY` returns the same rows on every execution 
when the input data, its partitioning and the sort order of its rows are 
unchanged (rows that tie on the sort key can still move between partitions). 
Range partition boundaries, and so which partition or output file a row lands 
in, can differ from earlier versions. To restore the previous behavior, set 
`spark.rdd.rangePartitioner.legacyRddIdSeed` to `true`.

Review Comment:
   Done in 37d9ebc; 7b44062 also names the other conditions the repeatability 
depends on (row order within each partition, adaptive coalescing).



##########
core/src/main/scala/org/apache/spark/Partitioner.scala:
##########
@@ -203,7 +203,11 @@ class RangePartitioner[K : Ordering : ClassTag, V](
       val sampleSize = math.min(samplePointsPerPartitionHint.toDouble * 
partitions, 1e6)
       // Assume the input partitions are roughly balanced and over-sample a 
little bit.
       val sampleSizePerPartition = math.ceil(3.0 * sampleSize / 
rdd.partitions.length).toInt
-      val (numItems, sketched) = RangePartitioner.sketch(rdd.map(_._1), 
sampleSizePerPartition)
+      // Seeds derived from the RDD id move the bounds of the same data on 
every execution, which
+      // breaks seeded samples over a global sort.

Review Comment:
   Done in 37d9ebc.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to