Shayan Masood
Shayan Masood

Reputation: 1057

Issues with Table Wildcard Functions

We have tables stored as :

Running a simple query like the following should be valid judging from the documentation, but fails.

    SELECT 
     SUM(totals.visits) AS visits,
     SUM(totals.bounces) AS bounces
    FROM 
      (TABLE_DATE_RANGE(<projectId>:<dataSetId>.ga_sessions_, 
                    TIMESTAMP('2013-12-01'), 
                    TIMESTAMP('2013-12-07'))) 

Is there an issue with TABLE_DATE_RANGE when the prefix contains '_', or the project contains '-' ? Am I supposed to be escaping any characters? I am testing date ranges on the BQ web interface currently, but will be using the API as well.

JobId: nmodal-big-query-1:job_FygE9ZzY9Fxi7UUfdQxS6RfuqIA

Upvotes: 2

Views: 495

Answers (1)

Jordan Tigani
Jordan Tigani

Reputation: 26617

If you've got non-alphanumeric chars in your dataset, table, or project it, you'll need to use the bigquery sql quotes ([]), as in

 SELECT 
   SUM(totals.visits) AS visits,
   SUM(totals.bounces) AS bounces
  FROM 
    (TABLE_DATE_RANGE([<projectId>:<dataSetId>.ga_sessions_], 
                  TIMESTAMP('2013-12-01'), 
                  TIMESTAMP('2013-12-07'))) 

Upvotes: 4

Related Questions