In this code:
SELECT
kgi.ingredient_id,
STRING_AGG(val, ', ') AS aka
FROM {{ ref('stg_bq_kg__ingredients') }} AS kgi,
UNNEST(synonyms) AS synonym,
UNNEST(synonym.values) AS val
GROUP BY kgi.ingredient_id
I get L: 7 | P: 1 | AM06 | Inconsistent column references in 'GROUP BY/ORDER BY' clauses. | [ambiguous.column_references] but I am not quite sure why since the column is being referenced clearly.
Note I am using dbt_templater in my .sqlfluff.