bigquery-schema-generator is a Python library that generates BigQuery schemas from newline-delimited JSON or CSV data. Unlike BigQuery's native auto-detection which typically samples only the first 500 records, this tool processes all input data to create a more comprehensive and accurate schema. Currently at version 1.6.1, the library maintains an active release cadence, providing regular updates and bug fixes.
pip install bigquery-schema-generatorVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `SchemaGenerator` as a library to deduce a BigQuery schema from a list of Python dictionaries. The `deduce_schema_from_dict` method processes the records, and `flatten_schema` converts the internal representation into a BigQuery-compatible JSON schema format.
Upgrade to `bigquery-schema-generator` version 1.6.1 or later (`pip install --upgrade bigquery-schema-generator`).
Review generated schemas if your data contains nulls in fields that might infer as `REPEATED` types. Use the `--keep_nulls` flag or similar options if specific handling of nulls is required to prevent their conversion to `REPEATED` in some contexts.
If updating an existing table, ensure new fields in the generated schema are `NULLABLE` or `REPEATED`. If `REQUIRED` fields are critical, consider creating a new table or using BigQuery's `ALTER TABLE` statements cautiously to modify modes where permitted.
No dependency data recorded yet.