auroflow commented on code in PR #28937:
URL: https://github.com/apache/flink/pull/28937#discussion_r3765756720
##########
flink-python/pyflink/dataframe/tests/test_dataframe.py:
##########
@@ -468,6 +468,81 @@ def test_lit_rejects_non_dataframe_data_type(self):
pf.lit(1, object())
+class DataFrameAggregationTests(PyFlinkDataFrameUTTestCase):
+ def setUp(self):
+ super().setUp()
+ self.dataframe = pf.from_records(
+ [
+ ("engineering", "east", 10),
+ ("engineering", "west", 20),
+ ("sales", "east", 5),
+ ],
+ schema=["department", "region", "amount"],
+ )
+
+ def test_global_aggregation_preserves_positional_and_named_order(self):
+ result = self.dataframe.agg(
+ pf.col("amount").sum.alias("total_amount"),
+ row_count=pf.col("amount").count,
+ )
+
+ self.assert_dataframe_schema(
+ result,
+ ["total_amount", "row_count"],
+ [TableDataTypes.BIGINT(), TableDataTypes.BIGINT().not_null()],
+ )
+
+ def test_grouped_aggregation_emits_string_and_expression_keys_first(self):
+ grouped = self.dataframe.group_by("department", pf.col("region"))
+
+ self.assertIsInstance(grouped, pf.GroupedDataFrame)
+ result = grouped.agg(
+ pf.col("amount").sum.alias("total_amount"),
+ row_count=pf.col("amount").count,
+ )
+
+ self.assert_dataframe_schema(
+ result,
+ ["department", "region", "total_amount", "row_count"],
+ [
+ TableDataTypes.STRING(),
+ TableDataTypes.STRING(),
+ TableDataTypes.BIGINT(),
+ TableDataTypes.BIGINT().not_null(),
+ ],
+ )
+
+ def test_aggregation_python_contract_validation(self):
Review Comment:
Agreed, I split it into separate tests.
--
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]