Skip to content

jtratner/protoc-gen-bq-schema

 
 

Repository files navigation

protoc-gen-bq-schema

protoc-gen-bq-schema is a plugin for ProtocolBuffer compiler. It converts messages written in .proto format into schema files in JSON for BigQuery. So you can reuse existing data definitions in .proto for BigQuery with this plugin.

Installation

go get github.com/GoogleCloudPlatform/protoc-gen-bq-schema

Usage

protoc --bq-schema_out=path/to/outdir foo.proto

protoc and protoc-gen-bq-schema commands must be found in $PATH.

The generated JSON schema files are suffixed with .schema and their base names are named after their package names and bq_table_name options.

Example

Suppose that we have the following foo.proto.

package foo;
import "bq_table_name.proto"

message Bar {
  option (gen_bq_schema.table_name) = "bar_table";

  message Nested {
    repeated int32 a = 1;
  }

  required int32 a = 1;
  optional Nested b = 2;
  repeated string c = 3;
}

message Baz {
  required int32 a = 1;
}

protoc --bq-schema_out=. foo.proto will generate a file named foo/bar_table.schema. The message foo.Baz is ignored because it doesn't have option gen_bq_schema.table_name.

License

protoc-gen-bq-schema is licensed under the Apache License version 2.0. This is not an official Google product.

About

protoc-gen-bq-schema helps you to send your Protocol Buffer messages to BigQuery.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published