Filter from a json type column does not work

hi everyone !
I’d like to create a text type field filter where the user can pick the name of the attribute he wants in a dropdown menu. I’m writing a postgresql query for that.
The problem is that the column has json type (example : {“fr”:“quelquechose”,“en”:“something”}) and when I extract the string I want, I do not have the dropdown menu.
Is there someone who can help me ? I would really appreciate !
have a great day !

Hi @A_user
Metabase currently does not handle JSON or array columns:
https://github.com/metabase/metabase/issues/708 - upvote by clicking :+1: on the first post

thanks for your answer @flamber !
we saw it on the documentation so we converted it in a string this way inside the postgresql query :
json_column::json ->> 'fr'
this expression gives us a string column but there is still no dropdown menu for the field filter.... any idea ?

@A_user You would have to do that in a View. Then when Metabase sync+scan that View, then it would be possible to show it in a dropdown - if the Field Type is set to Category (or one of the other types):
https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html#creating-sql-question-filters-using-field-filter-variables

1 Like

When i try to create a view, i get this error: "ERROR: cannot execute CREATE VIEW in a read-only transaction"

@A_user You cannot use write-commands from within Metabase. You have to create the View on your database. Metabase is a reporting tool and should only read data.

1 Like

I solved this by creating a view on my database. thanks :slight_smile: