8

I am trying query the table and store the result in another BigQuery table using python BigQuery API. But when I use standard SQL in query part it throws invalid table name error. How to use standard SQL in BigQuery API? I am using airflow BigQuery hoooks

'configuration': {
        'query': {
            'destinationTable': {
                'tableId': u 'our_table_name',
                'datasetId': 'our_dataset_id',
                'projectId': 'our_project_id'
            },
            'useLegacySql': False,
            'allowLargeResults': True,
            'writeDisposition': 'WRITE_TRUNCATE',
            'query': u'SELECT * FROM `projectID.datasetId.tablename`',
            
        }
    }

Exception: BigQuery job failed. Final error was: {u'reason': u'invalid', u'message': u'Invalid table name: `projectId:datasetId.tableId`', u'location': u'`projectId:datasetId.tableId`'}.
5
  • can you share job id to look at specific details Commented Mar 22, 2017 at 4:48
  • @MoshaPasumansky job id: job_lIaunDu3LHrgwm_KDOoxwmH39xw Commented Mar 23, 2017 at 16:41
  • I also need project name please Commented Mar 23, 2017 at 16:48
  • @MoshaPasumansky did you get project Id? Commented Mar 23, 2017 at 17:07
  • Thanks, I got it - answer posted. Commented Mar 23, 2017 at 17:12

1 Answer 1

11

The error is confusing, but the root cause is that this query was interpreted as Legacy SQL, not as Standard SQL. In JSON (unlike, say, in Python), boolean literals true and false must be lowercase, per JSON standard Section 3:

A JSON value MUST be an object, array, number, or string, or one of
the following three literal names:

  false null true

The literal names MUST be lowercase. No other literal names are
allowed.

So if you change

        `'useLegacySql': False,`

to

        `'useLegacySql': false,`

it should work

Sign up to request clarification or add additional context in comments.

2 Comments

yes, it works. I changed into 'useLegacySql': 'false'. Thank you so much
@MJK you should mark this as an answered question if it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.