You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/08/27 03:59:09 UTC

[GitHub] [spark] zhengruifeng opened a new pull request, #37683: [SPARK-40240][PYTHON] PySpark rdd.takeSample should validate `num > maxSampleSize` at first

zhengruifeng opened a new pull request, #37683:
URL: https://github.com/apache/spark/pull/37683

   ### What changes were proposed in this pull request?
   to make the PySpark `rdd.takeSample` behave like the scala side
   
   
   ### Why are the changes needed?
   `rdd.takeSample` in Spark-Core checks the `num > maxsize - int(numStDev * sqrt(maxsize))` at first, while in the PySpark, it may skip this validation:
   
   ```scala
   scala> sc.range(0, 10).takeSample(false, Int.MaxValue)
   java.lang.IllegalArgumentException: requirement failed: Cannot support a sample size > Int.MaxValue - 10.0 * math.sqrt(Int.MaxValue)
     at scala.Predef$.require(Predef.scala:281)
     at org.apache.spark.rdd.RDD.$anonfun$takeSample$1(RDD.scala:620)
     at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
     at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
     at org.apache.spark.rdd.RDD.withScope(RDD.scala:406)
     at org.apache.spark.rdd.RDD.takeSample(RDD.scala:615)
     ... 47 elided
   ```
   
   ```python
   In [2]: sc.range(0, 10).takeSample(False, sys.maxsize)
   Out[2]: [9, 6, 8, 5, 7, 2, 0, 3, 4, 1]  
   ```
   
   
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   
   ### How was this patch tested?
   added doctest


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] zhengruifeng commented on pull request #37683: [SPARK-40240][PYTHON] PySpark rdd.takeSample should correctly validate `num > maxSampleSize`

Posted by GitBox <gi...@apache.org>.
zhengruifeng commented on PR #37683:
URL: https://github.com/apache/spark/pull/37683#issuecomment-1229321902

   Merged into master, thanks @HyukjinKwon for review


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] zhengruifeng closed pull request #37683: [SPARK-40240][PYTHON] PySpark rdd.takeSample should correctly validate `num > maxSampleSize`

Posted by GitBox <gi...@apache.org>.
zhengruifeng closed pull request #37683: [SPARK-40240][PYTHON] PySpark rdd.takeSample should correctly validate `num > maxSampleSize`
URL: https://github.com/apache/spark/pull/37683


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org