Created
March 4, 2016 16:23
-
-
Save chipoglesby/50c746a8dd01befbb69a to your computer and use it in GitHub Desktop.
Use Google Apps Script to Create A BigQuery Table with nested JSON fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createBigQueryTable() { | |
| projectId = "xxx"; | |
| datasetId = "xxx"; | |
| var tableId = 'xxx'; | |
| var table = { | |
| tableReference: { | |
| projectId: projectId, | |
| datasetId: datasetId, | |
| tableId: tableId | |
| }, | |
| schema: { | |
| fields: [ | |
| // This example is for the Google Maps API. You can change the fields as needed, but this is used to demostrated nested fields. | |
| {name: 'location', type: 'RECORD', "fields": [{name: 'lat', type: 'FLOAT'},{name: 'lng', type: 'FLOAT'}]}, | |
| {name: 'id', type: 'STRING'}, | |
| {name: 'place_id', type: 'STRING'}, | |
| {name: 'reference', type: 'STRING'} | |
| ] | |
| } | |
| }; | |
| table = BigQuery.Tables.insert(table, projectId, datasetId); | |
| Logger.log('Table created: %s', table.id); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment