cloud-fan commented on code in PR #52153: URL: https://github.com/apache/spark/pull/52153#discussion_r2309671282
########## sql/core/src/test/scala/org/apache/spark/sql/execution/PlannerSuite.scala: ########## @@ -1406,6 +1406,87 @@ class PlannerSuite extends SharedSparkSession with AdaptiveSparkPlanHelper { assert(planned.exists(_.isInstanceOf[GlobalLimitExec])) assert(planned.exists(_.isInstanceOf[LocalLimitExec])) } + + test("SPARK-53401: repartitionById should throw an exception for negative partition id") { + val df = spark.range(10).toDF("id") + val repartitioned = df.repartitionById(10, $"id" - 5) + + val e = intercept[SparkException] { + repartitioned.collect() + } + // The error is caught as ArrayIndexOutOfBoundsException wrapped in SparkException + assert(e.getMessage.contains("Index -5 out of bounds")) + } + + test("SPARK-53401: repartitionById should throw an exception for partition id >= numPartitions") { Review Comment: wait, how can this happen if we do mod/pmod? -- 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-unsubscr...@spark.apache.org 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