title: Check if these tables exist before running query and return different data based on result?
body: <p>I have the following query which works if the table exists but if not it will error out. </p>
  
  <pre><code>WITH allTables AS ( 
    SELECT 
      CONCAT(user_dim.app_info.app_id, ':', user_dim.app_info.app_platform) as app,
      user_dim.app_info.app_instance_id AS users
    FROM `table.app_events_intraday_*`, UNNEST(event_dim) AS event
    WHERE _TABLE_SUFFIX BETWEEN '20170406' AND '20170406'
  
    UNION ALL
    SELECT 
      CONCAT(user_dim.app_info.app_id, ':', user_dim.app_info.app_platform) as app,
      user_dim.app_info.app_instance_id AS users
    FROM `table.app_events_*`, UNNEST(event_dim) AS event
    WHERE _TABLE_SUFFIX BETWEEN '20170406' AND '20170406'
  ) 
  SELECT 
    app as target,
    COUNT(DISTINCT(users)) AS datapoint_value,
    UNIX_SECONDS(PARSE_TIMESTAMP('%Y%m%d', '20170406')) as datapoint_time
  FROM allTables
  GROUP BY app
  </code></pre>
  
  <p>This query selects the current day / time frame active user based on <code>_TABLE_SUFFIX</code>. The issue is that when a table doesn't exist, it returns this error:</p>
  
  <blockquote>
    <p>Error: project:table.app_events_intraday_* does not match any table.</p>
  </blockquote>
  
  <p>I know it's doing this because that table does not exist. I need to find a way to check if a table exists before querying it. Any help would be great, thanks!</p>