I am trying to create a BigQuery external table by reading a file from Google Drive - it works with inline scheme but failed with autodetect
flag.
Document referenced:
https://cloud.google.com/bigquery/external-data-drive
Schema File:
$ bq mkdef --autodetect --source_format=CSV "https://drive.google.com/open?id=<file-id>" > schema.json
schema.json:
{
"autodetect": true,
"csvOptions": {
"encoding": "UTF-8",
"quote": "\""
},
"sourceFormat": "CSV",
"sourceUris": [
"https://drive.google.com/open?id=<file-id>"
]
}
External Table:
$ bq mk --external_table_definition=schema.json mydataset.mytable
BigQuery error in mk operation: Access Denied: BigQuery BigQuery: No OAuth token with Google Drive scope was found.
It works, with inline schema:
$ bq mk --external_table_definition=col1:INTEGER,col2:STRING@CSV=https://drive.google.com/open?id=<file-id> mydataset.mytable
Table 'myproject:mydataset.mytable' successfully created.
Note: I have enabled Google Drive access by using
gcloud auth login --enable-gdrive-access