I have a table:
key product_code cost 1 UK 20 1 US 10 1 EU 5 2 UK 3 2 EU
Similar to @VB_ answer, use the BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING statement.
BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
The HiveQL query is therefore:
SELECT key, product_code, SUM(costs) OVER (PARTITION BY key ORDER BY key ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM test;