This is an automated email from the ASF dual-hosted git repository.
JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new d98a147413 [python] Introduce 'product' aggregator function (#8718)
d98a147413 is described below
commit d98a1474132af0eb96a7dbff73b056157db3fdcc
Author: AuroraVoyage <[email protected]>
AuthorDate: Tue Jul 28 21:19:52 2026 +0800
[python] Introduce 'product' aggregator function (#8718)
---
.../pypaimon/tests/test_field_aggregators.py | 68 ++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/paimon-python/pypaimon/tests/test_field_aggregators.py
b/paimon-python/pypaimon/tests/test_field_aggregators.py
index 7ce1e013bb..9fe0047cc6 100644
--- a/paimon-python/pypaimon/tests/test_field_aggregators.py
+++ b/paimon-python/pypaimon/tests/test_field_aggregators.py
@@ -475,6 +475,17 @@ class FieldProductAggTest(unittest.TestCase):
self.assertIsNone(agg.retract(None, 5))
self.assertIsNone(agg.retract(None, None))
+ def test_long_boundary_product(self):
+ agg = _make("product", "BIGINT")
+
+ self.assertEqual(
+ agg.agg(3037000499, 3037000499),
+ 9223372030926249001,
+ )
+
+ with self.assertRaises(ArithmeticError):
+ agg.agg(3037000500, 3037000500)
+
def test_non_numeric_type_rejected_at_construction(self):
with self.assertRaises(ValueError) as ctx:
_make("product", "VARCHAR")
@@ -494,6 +505,42 @@ class FieldProductAggTest(unittest.TestCase):
BigDecimal("1234567890123456790234567890123456789"),
)
+ result = agg.agg(
+ BigDecimal("9999999999999999999"),
+ BigDecimal("9999999999999999999"),
+ )
+
+ self.assertEqual(
+ result,
+ BigDecimal("99999999999999999980000000000000000001"),
+ )
+
+ # with scale
+ agg = _make("product", "DECIMAL(38,18)")
+
+ result = agg.agg(
+ BigDecimal("1.234567890123456789"),
+ BigDecimal("2.000000000000000001"),
+ )
+ self.assertEqual(
+ result,
+ BigDecimal("2.469135780246913579"),
+ )
+
+ def test_decimal_product_precision_overflow(self):
+ agg = _make("product", "DECIMAL(38,0)")
+
+ # digits > precision, so return None
+ self.assertIsNone(agg.agg(
+ BigDecimal("99999999999999999999999999999999999999"),
+ BigDecimal("10"),
+ ))
+
+ self.assertIsNone(agg.agg(
+ BigDecimal("9999999999999999999"),
+ BigDecimal("99999999999999999991"),
+ ))
+
def test_decimal_divide_requires_exact_result(self):
agg = _make("product", "DECIMAL(38,0)")
@@ -503,6 +550,27 @@ class FieldProductAggTest(unittest.TestCase):
BigDecimal("3"),
)
+ agg = _make("product", "DECIMAL(38,18)")
+
+ with self.assertRaises(ArithmeticError):
+ agg.retract(
+ BigDecimal("1.000000000000000000"),
+ BigDecimal("3.000000000000000000"),
+ )
+
+ def test_decimal_divide_high_precision_exact(self):
+ agg = _make("product", "DECIMAL(38,0)")
+
+ result = agg.retract(
+ BigDecimal("99999999999999999999999999999999999998"),
+ BigDecimal("2"),
+ )
+
+ self.assertEqual(
+ result,
+ BigDecimal("49999999999999999999999999999999999999"),
+ )
+
def test_float_divide_by_zero(self):
agg = _make("product", "FLOAT")