Why is this situation failing? What's the neatest way to solve my problem?
SELECT * FROM myTable foo
WHERE ARRAY_AGG(SUBSTRING(UNNEST(foo.array), 'abc(.*?)xyz'))
&& ARRAY['ElementA','ElementZ']
My table has an array column, which contains unparsed Strings. What I am doing here is parsing those, element by element, and then reaggrouping again into an array, so I can compare if the processed array contains any of my expected elements
But it returns:
ERROR: column "foo.id" must appear in the GROUP BY clause or be used in an aggregate function
Do I really need to group by all the columns? Shouldn't the where filter be virtual uniquely? IS there maybe a way to deal virtually with the unnest/nest operations without affecting the rest of the query?