-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support and optionally parse JSON field (#1229)
- Loading branch information
1 parent
6d8e77e
commit cd11447
Showing
7 changed files
with
195 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,10 @@ function main(datasetId = 'my_dataset', tableId = 'my_table') { | |
name: 'school', | ||
type: 'BYTES', | ||
}, | ||
{ | ||
name: 'metadata', | ||
type: 'JSON', | ||
}, | ||
{ | ||
name: 'location', | ||
type: 'GEOGRAPHY', | ||
|
@@ -108,14 +112,19 @@ function main(datasetId = 'my_dataset', tableId = 'my_table') { | |
const bqTimestamp = bigquery.timestamp('2020-04-27T18:07:25.356Z'); | ||
const bqGeography = bigquery.geography('POINT(1 2)'); | ||
const schoolBuffer = Buffer.from('Test University'); | ||
|
||
// a JSON field needs to be converted to a string | ||
const metadata = JSON.stringify({ | ||
owner: 'John Doe', | ||
contact: '[email protected]', | ||
}); | ||
// Rows to be inserted into table | ||
const rows = [ | ||
{ | ||
name: 'Tom', | ||
age: '30', | ||
location: bqGeography, | ||
school: schoolBuffer, | ||
metadata: metadata, | ||
measurements: [50.05, 100.5], | ||
datesTimes: { | ||
day: bqDate, | ||
|
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.