Doing Query and Cost Analysis for BQ in Metabase

An idea suggested by the datafold team to better understand costly queries was just plugin information schema into metabase. This is possible but a bit tricky. You need to add a true dataset and not information schema directly otherwise you'll get errors (I'm not sure why):

Screen Shot 2022-01-20 at 11.52.55 AM.png

When adding, just add a true dataset here:

Screen Shot 2022-01-20 at 11.50.15 AM.png

Then you can query via SQL as:

Screen Shot 2022-01-21 at 2.49.31 AM.png

Save this as a subview and then you can slice and dice with metabases visual query engine.

Alternatively save this as a snippet:

Screen Shot 2022-01-21 at 2.50.47 AM.png

WITH base_queries as (

  SELECT creation_time, user_email, job_type, statement_type, 
                 total_bytes_processed, total_bytes_billed, query 
  FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
  ORDER BY creation_time DESC

)