7.0.0 • Published 1 year ago

jsonschema-bigquery v7.0.0

Weekly downloads
64
License
MIT
Repository
github
Last release
1 year ago

jsonschema-bigquery

npm Node.js CI

Convert JSON schema to Google BigQuery schema

This includes the ability to:

  1. Create tables
  2. 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 <gbq project> -d <gbq dataset> -j <json schema file> --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 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
6.1.0

1 year ago

6.0.0

1 year ago

7.0.0

1 year ago

5.1.0

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

4.1.0

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

3.4.0

4 years ago

3.3.0

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago