Filter Postgresql list in model

I have a model defined as

SELECT
  p.*,
  array_agg(c.name) as categories
FROM
  product p
  LEFT JOIN product_t_category pc ON pc.product = p.id
  LEFT JOIN t_category c ON c.id = pc.category
GROUP BY p.id

When I try to filter to categories column from the model visualization, I get a query error because I am comparing an array with a string.

Is there a way to get Metabase to understand that the categories column contains a list and filter accoring to that information?

Currently I solved the issue by converting the field to a string, but it is a quite suboptimal solution

unfortunately no, as we don't understand arrays yet. You need to save that as a view in the database but with the arrays flattened

1 Like