dataengref errors

Home / Hive / Query compilation

Hive: SemanticException [Error 10025]: Expression not in GROUP BY key

org.apache.hadoop.hive.ql.parse.SemanticExceptionFAILED: SemanticException [Error 10025]: Line 1:19 Expression not in GROUP BY key 'customer_name'

A SELECT column is neither in GROUP BY nor inside an aggregate. MySQL in permissive mode accepts this and picks an arbitrary value; Hive rejects it.

Causes · Fixes · Source

Common causes

  1. A descriptive column (name, region) is selected next to an aggregate without being grouped.How to confirm: The message names the column.

How to fix it

Add the column to GROUP BY, or wrap it in an aggregate such as MAX() or ANY_VALUE()-style logic if any value will do.

SELECT customer_id, MAX(customer_name) AS customer_name, SUM(amount)
FROM orders
GROUP BY customer_id;

Where the message comes from

Message template in the source: Expression not in GROUP BY key

References

Related errors

Last checked: