Skip to content

hashAggregates: group by sum decimal issue #1554

@ssathi

Description

@ssathi

Aggregating negative decimal values produces incorrect results.

table:

charge_item_name (string) charge_type (string) charge_amount (decimal(16,2)
WHT tax -300.00
WHT tax -300.00
WHT tax -300.00
WHT tax -240.00
WHT tax -300.00
WHT tax -300.00
WHT tax -300.00
WHT tax -300.00
WHT tax -300.00
WHT tax -300.00
WHT tax -300.00
WHT tax -200.00
WHT tax -300.00
WHT tax -300.00

Spark SQL query:

SELECT itemchargingtype, itemdescription, count(*) AS `count`, sum(itemamount) AS `sum`
FROM `transaction_items`
where itemdescription = 'WHT'
GROUP BY itemdescription, itemchargingtype

result:

charge_type charge_item_name count sum
tax WHT 14 1,202.88

After disabling
snappydata.sql.hashAggregateSize=-1
snappydata.sql.useOptimizedHashAggregateForSingleKey=false

it produces correct values.

result:

charge_type charge_item_name count sum
tax WHT 14 -4040.00

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions