Skip to content

Commit 6a000ec

Browse files
timsaucerclaude
andcommitted
test: fold sum/avg distinct tests into parameterized aggregation test
Move the standalone test_sum_distinct_kwarg and test_avg_distinct_kwarg from test_functions.py into the existing test_aggregation::test_aggregation parameterization, matching how distinct is already covered for median, array_agg, count, and bit_xor. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3afbc7d commit 6a000ec

2 files changed

Lines changed: 2 additions & 30 deletions

File tree

python/tests/test_aggregation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ def test_aggregation_stats(df, agg_expr, calc_expected):
192192
False,
193193
),
194194
(f.avg(column("b"), filter=column("a") != lit(1)), pa.array([5.0]), False),
195+
(f.avg(column("b"), distinct=True), pa.array([5.0]), False),
195196
(f.sum(column("b"), filter=column("a") != lit(1)), pa.array([10]), False),
197+
(f.sum(column("b"), distinct=True), pa.array([10]), False),
196198
(f.count(column("b"), distinct=True), pa.array([2]), False),
197199
(f.count(column("b"), filter=column("a") != 3), pa.array([2]), False),
198200
(f.count(), pa.array([3]), False),

python/tests/test_functions.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,36 +1957,6 @@ def test_get_field(df):
19571957
assert result.column(1) == pa.array([4, 5, 6])
19581958

19591959

1960-
def test_sum_distinct_kwarg():
1961-
ctx = SessionContext()
1962-
df = ctx.from_pydict({"a": [1, 1, 2, 3]})
1963-
distinct = (
1964-
df.aggregate([], [f.sum(column("a"), distinct=True).alias("v")])
1965-
.collect_column("v")[0]
1966-
.as_py()
1967-
)
1968-
total = (
1969-
df.aggregate([], [f.sum(column("a")).alias("v")]).collect_column("v")[0].as_py()
1970-
)
1971-
assert distinct == 6
1972-
assert total == 7
1973-
1974-
1975-
def test_avg_distinct_kwarg():
1976-
ctx = SessionContext()
1977-
df = ctx.from_pydict({"a": [1.0, 1.0, 2.0, 3.0]})
1978-
distinct = (
1979-
df.aggregate([], [f.avg(column("a"), distinct=True).alias("v")])
1980-
.collect_column("v")[0]
1981-
.as_py()
1982-
)
1983-
mean = (
1984-
df.aggregate([], [f.avg(column("a")).alias("v")]).collect_column("v")[0].as_py()
1985-
)
1986-
assert distinct == 2.0
1987-
assert mean == 1.75
1988-
1989-
19901960
def test_arrow_metadata():
19911961
ctx = SessionContext()
19921962
field = pa.field("val", pa.int64(), metadata={"key1": "value1", "key2": "value2"})

0 commit comments

Comments
 (0)