Skip to content

Commit

Permalink
fix more formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
khwilson committed Oct 13, 2024
1 parent 15ead92 commit 2156906
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernels/codegen_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ Result<std::shared_ptr<DataType>> WidenDecimalToMaxPrecision(
return Status::TypeError(
"An unknown DecimalType was passed to WidenDecimalToMaxPrecision: " +
type->ToString());
};
}
}

bool HasDecimal(const std::vector<TypeHolder>& types) {
Expand Down
21 changes: 17 additions & 4 deletions python/pyarrow/tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,11 @@ def test_sum_array(arrow_type):
@pytest.mark.parametrize("arrow_type", [pa.decimal128(3, 2), pa.decimal256(3, 2)])
def test_sum_decimal_array(arrow_type):
from decimal import Decimal
max_precision_type = pa.decimal128(38, arrow_type.scale) if pa.types.is_decimal128(arrow_type) else pa.decimal256(76, arrow_type.scale)
max_precision_type = (
pa.decimal128(38, arrow_type.scale)
if pa.types.is_decimal128(arrow_type)
else pa.decimal256(76, arrow_type.scale)
)
expected_sum = Decimal("5.79")
zero = Decimal("0.00")

Expand Down Expand Up @@ -420,16 +424,25 @@ def test_sum_chunked_array(arrow_type):
@pytest.mark.parametrize('arrow_type', [pa.decimal128(3, 2), pa.decimal256(3, 2)])
def test_sum_chunked_array_decimal_type(arrow_type):
from decimal import Decimal
max_precision_type = pa.decimal128(38, arrow_type.scale) if pa.types.is_decimal128(arrow_type) else pa.decimal256(76, arrow_type.scale)
max_precision_type = (
pa.decimal128(38, arrow_type.scale)
if pa.types.is_decimal128(arrow_type)
else pa.decimal256(76, arrow_type.scale)
)
expected_sum = Decimal("5.79")
zero = Decimal("0.00")

arr = pa.chunked_array([pa.array([Decimal("1.23"), Decimal("4.56")], type=arrow_type)])
arr = pa.chunked_array(
[
pa.array([Decimal("1.23"), Decimal("4.56")], type=arrow_type)
]
)
assert pc.sum(arr).as_py() == expected_sum
assert pc.sum(arr).type == max_precision_type

arr = pa.chunked_array([
pa.array([Decimal("1.23")], type=arrow_type), pa.array([Decimal("4.56")], type=arrow_type)
pa.array([Decimal("1.23")], type=arrow_type),
pa.array([Decimal("4.56")], type=arrow_type)
])
assert pc.sum(arr).as_py() == expected_sum
assert pc.sum(arr).type == max_precision_type
Expand Down

0 comments on commit 2156906

Please sign in to comment.