Ask questions based on a view and not a table

Hi,

I’m a newbie and I’m starting to learn SQL so I’m not very technical nor experienced, so please excuse my lack of professional lingo :slight_smile:

I’ve created a View in my database (we use postgresql) because I need some complex joins among my tables in order to get my point.

My plan is to use such View as default table to build Queries with the “visual builder” since I need other non-technical users to create questions, slicing/dicing data in order to have few easy charts.

Unfortunately I can’t see my view in the list of tables, but if I enter the sql editor and run a select from it I get all my data back!

What am I doing wrong? Maybe it’s not possible to use views as input for the query builder?

Thanks, Marco

Metabase doesn’t know about the view you just added. Sync your database again and it should show up in the menu

Thanks camsaul, it did the trick! I was under the assumption that Metabase could read live my db modifications without needing to sync it.

It sounds like you were having the same issue that I am having right now but got it working, did you do anything more than syncing the database to get you view to show up in the list?

No, I just had to sync it and the trick was done.

Dang… I’ve synced it, even fully disconnected and reconnected it, and it still only shows the view when I query using sql.

What kind of database are you using (postgre, mysql, etc.)?

Ouch… Unfortunately I have no clue on how to help you! I’m using postgre, running locally on my laptop via Mapp Stack. I don’t work on the real DB but I use a dump so it’s safer.

Hmm, maybe I’ll try migrating to mysql or postgre (I’m using sqlite right now).

If it works in mysql/postgre but not sqlite can you file an issue?

If it doesn’t work with one of those either, can you share the view with us here so we can try to figure out why it’s not being picked up?

In general, Metabase expects to work with views (see extended ramblings at http://www.metabase.com/blog/Joins) and they should JustWork.

It looks like it was an issue with sqlite. I migrated my database into MySQL and the views are working perfectly now. Where do I file an issue?

Turns out there was a bug in the sqlite driver we used. We've reverted and this will be fixed in 0.21.

1 Like

We are using MB 0.29.3 with PostgreSQL 9.4. We have tried creating Materialized Views and Views in our schema and have re-synced the schema several times. We have also saved the database definition after syncing. The tables in the schema do appear in the Questions drop down and new tables seem appear without the need to sync but views do not show up in the drop down regardless of syncing. Any ideas what we else we should be doing to work with views in PostgreSQL.

@bill.tulskie And you checked database access for those views by running a native SQL query in Metabase?

Hi, I have this exact problem. I created a view in pgAdmin4, resynced the db in Metabase, but I still can only see the tables and not the views. Anyone? Thanks!

Hi @fabiolanza
Have you checked that the Postgres user that Metabase using can access the View? Which version of Metabase and Postgres? Depending on the size of your database, it might take several minutes to sync - and sometimes you might need to refresh the browser to get an updated listing.

1 Like

It worked, I had to refresh the page with F5. Thanks.

1 Like