AMC: user_id is not allowed in the final SELECT
Columns with the very high threshold such as user_id can never appear in the output, only in intermediate steps or as COUNT or COUNT DISTINCT.
Symptom
A query that returns user_id in its last SELECT cannot run. Amazon describes the rule but does not print a fixed message text.
Cause
With the very high threshold no aggregation level would release the column: the output would expose the data of a single user.
Fix
- Only count user_id: COUNT(DISTINCT user_id) for reached users.
- Use user_id in a CTE for joins or frequencies and output only aggregated values in the final SELECT.
- For audiences use an audience query, where user_id is the intended output (audience recipes).
The cause follows the Amazon documentation. Some of the fix steps are our own judgement and do not replace asking Amazon support.