https://github.com/thedumbterminal/jsonschema-bigquery
Convert JSON schema to Google BigQuery schema
https://github.com/thedumbterminal/jsonschema-bigquery
bigquery json-schema node-js node-module nodejs nodejs-module nodejs-modules
Last synced: 4 months ago
JSON representation
Convert JSON schema to Google BigQuery schema
- Host: GitHub
- URL: https://github.com/thedumbterminal/jsonschema-bigquery
- Owner: thedumbterminal
- License: mit
- Created: 2018-07-21T21:31:21.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-07-04T13:31:43.000Z (4 months ago)
- Last Synced: 2025-07-04T15:10:35.174Z (4 months ago)
- Topics: bigquery, json-schema, node-js, node-module, nodejs, nodejs-module, nodejs-modules
- Language: JavaScript
- Homepage:
- Size: 1.33 MB
- Stars: 26
- Watchers: 5
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# jsonschema-bigquery
[](https://www.npmjs.com/package/jsonschema-bigquery)
[](https://github.com/thedumbterminal/jsonschema-bigquery/actions/workflows/main.yml)
Convert JSON schema to Google BigQuery schema
This includes the ability to:
1. Create tables
1. Patch tables
Further enhancements are planned: delete tables (dev only), create dataset, set data ACLs
Note that some features involve bespoke interpretation of schema details suited to our environment.
## Install
npm install jsonschema-bigquery
## Consume
jsbq -p -d -j --preventAdditionalObjectProperties --continueOnError
For embedded usage the following will allow and support runtime schema conversion and table maintenance:
const jsonSchemaBigquery = require('jsonschema-bigquery')
const bigquerySchema = jsonSchemaBigquery.run(jsonSchemaObject, options)
Please ensure that the input JSON schema is dereferenced so that all external references have been resolved. [json-schema-ref-parser](https://www.npmjs.com/package/json-schema-ref-parser) can do this, prior to using this module.
### Options
```
{
preventAdditionalObjectProperties: true,
continueOnError: false
}
```
- `preventAdditionalObjectProperties` - boolean, check for additional object properties in schemas.
- `continueOnError` - boolean, continues conversion if problem JSON is encountered. Problems will be excluded from resulting schema.
### Usage with bq CLI tool
Google maintains a CLI tool called `bq` which allows the management of BigQuery tables:
https://cloud.google.com/bigquery/docs/reference/bq-cli-reference
To create a table from a JSON schema using other options that our `jsbq` does not support, use the following commands:
First, output the generated GBQ schema to a file:
```
npx jsbq -j test/integration/samples/complex/input.json > /tmp/schema.json
```
Then run the `bq` command to create a table:
```
bq mk --schema=/tmp/schema.json test_dataset.test_table
```
Please see the bq reference for table creation options:
https://cloud.google.com/bigquery/docs/reference/bq-cli-reference#bq_mk
## Test
npm test