You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ru...@apache.org on 2025/11/13 02:29:21 UTC
(spark) branch master updated: [SPARK-54315][PYTHON][TESTS] Optimize test `ApplyInArrowTests.test_arrow_batch_slicing`
This is an automated email from the ASF dual-hosted git repository.
ruifengz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 65b69a0d9fd5 [SPARK-54315][PYTHON][TESTS] Optimize test `ApplyInArrowTests.test_arrow_batch_slicing`
65b69a0d9fd5 is described below
commit 65b69a0d9fd58378eb46ed3e368925d228039b6c
Author: Ruifeng Zheng <ru...@apache.org>
AuthorDate: Thu Nov 13 10:29:10 2025 +0800
[SPARK-54315][PYTHON][TESTS] Optimize test `ApplyInArrowTests.test_arrow_batch_slicing`
### What changes were proposed in this pull request?
Optimize test `ApplyInArrowTests.test_arrow_batch_slicing`
### Why are the changes needed?
before
```
Starting test(python3.11): pyspark.sql.tests.connect.arrow.test_parity_arrow_grouped_map (temp output: /__w/spark/spark/python/target/84531e82-addd-4a47-bb65-9006099020a0/python3.11__pyspark.sql.tests.connect.arrow.test_parity_arrow_grouped_map__l8scrw6b.log)
Finished test(python3.11): pyspark.sql.tests.connect.arrow.test_parity_arrow_grouped_map (100s)
```
after
```
Starting test(python3.11): pyspark.sql.tests.connect.arrow.test_parity_arrow_grouped_map (temp output: /__w/spark/spark/python/target/f8e27057-d295-433e-99a2-a429a48278d5/python3.11__pyspark.sql.tests.connect.arrow.test_parity_arrow_grouped_map__ss4itrd9.log)
Finished test(python3.11): pyspark.sql.tests.connect.arrow.test_parity_arrow_grouped_map (39s)
```
### Does this PR introduce _any_ user-facing change?
No, test-only
### How was this patch tested?
CI
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #53011 from zhengruifeng/opt_test_grouped.
Authored-by: Ruifeng Zheng <ru...@apache.org>
Signed-off-by: Ruifeng Zheng <ru...@apache.org>
---
python/pyspark/sql/tests/arrow/test_arrow_grouped_map.py | 10 +++++-----
python/pyspark/sql/tests/pandas/test_pandas_grouped_map.py | 10 +++++-----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/python/pyspark/sql/tests/arrow/test_arrow_grouped_map.py b/python/pyspark/sql/tests/arrow/test_arrow_grouped_map.py
index 56a9ed322c15..cb8d74f72427 100644
--- a/python/pyspark/sql/tests/arrow/test_arrow_grouped_map.py
+++ b/python/pyspark/sql/tests/arrow/test_arrow_grouped_map.py
@@ -356,14 +356,14 @@ class ApplyInArrowTestsMixin:
self.assertEqual(df2.join(df2).count(), 1)
def test_arrow_batch_slicing(self):
- df = self.spark.range(10000000).select(
- (sf.col("id") % 2).alias("key"), sf.col("id").alias("v")
- )
+ n = 100000
+
+ df = self.spark.range(n).select((sf.col("id") % 2).alias("key"), sf.col("id").alias("v"))
cols = {f"col_{i}": sf.col("v") + i for i in range(20)}
df = df.withColumns(cols)
def min_max_v(table):
- assert len(table) == 10000000 / 2, len(table)
+ assert len(table) == n / 2, len(table)
return pa.Table.from_pydict(
{
"key": [table.column("key")[0].as_py()],
@@ -376,7 +376,7 @@ class ApplyInArrowTestsMixin:
df.groupby("key").agg(sf.min("v").alias("min"), sf.max("v").alias("max")).sort("key")
).collect()
- for maxRecords, maxBytes in [(1000, 2**31 - 1), (0, 1048576), (1000, 1048576)]:
+ for maxRecords, maxBytes in [(1000, 2**31 - 1), (0, 4096), (1000, 4096)]:
with self.subTest(maxRecords=maxRecords, maxBytes=maxBytes):
with self.sql_conf(
{
diff --git a/python/pyspark/sql/tests/pandas/test_pandas_grouped_map.py b/python/pyspark/sql/tests/pandas/test_pandas_grouped_map.py
index 8bf0e7235efc..a86ef3e4f3f3 100644
--- a/python/pyspark/sql/tests/pandas/test_pandas_grouped_map.py
+++ b/python/pyspark/sql/tests/pandas/test_pandas_grouped_map.py
@@ -938,14 +938,14 @@ class ApplyInPandasTestsMixin:
self.assertEqual(row[1], 123)
def test_arrow_batch_slicing(self):
- df = self.spark.range(100000).select(
- (sf.col("id") % 2).alias("key"), sf.col("id").alias("v")
- )
+ n = 100000
+
+ df = self.spark.range(n).select((sf.col("id") % 2).alias("key"), sf.col("id").alias("v"))
cols = {f"col_{i}": sf.col("v") + i for i in range(20)}
df = df.withColumns(cols)
def min_max_v(pdf):
- assert len(pdf) == 100000 / 2, len(pdf)
+ assert len(pdf) == n / 2, len(pdf)
return pd.DataFrame(
{
"key": [pdf.key.iloc[0]],
@@ -958,7 +958,7 @@ class ApplyInPandasTestsMixin:
df.groupby("key").agg(sf.min("v").alias("min"), sf.max("v").alias("max")).sort("key")
).collect()
- for maxRecords, maxBytes in [(1000, 4096), (0, 4096), (1000, 4096)]:
+ for maxRecords, maxBytes in [(1000, 2**31 - 1), (0, 4096), (1000, 4096)]:
with self.subTest(maxRecords=maxRecords, maxBytes=maxBytes):
with self.sql_conf(
{
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org