Skip to content

Commit

Permalink
* Makefile fixes for compiling with proper descriptorpb
Browse files Browse the repository at this point in the history
* Add is_primary to field to help with generating materializedviews later
  • Loading branch information
Chris committed Nov 24, 2022
1 parent 135534d commit f7acf01
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

BQ_PLUGIN=bin/protoc-gen-bq-schema
GO_PLUGIN=bin/protoc-gen-go
PROTOC_GEN_GO_PKG=google.golang.org/protobuf/compiler/protogen
PROTOC_GEN_GO_PKG=google.golang.org/protobuf/cmd/protoc-gen-go
GLOG_PKG=github.com/golang/glog
PROTO_SRC=bq_table.proto bq_field.proto
PROTO_GENFILES=protos/bq_table.pb.go protos/bq_field.pb.go
PROTO_PKG=google.golang.org/protobuf/proto
PKGMAP=Mgoogle/protobuf/descriptor.proto=$(PROTOC_GEN_GO_PKG)/descriptor
PKGMAP=Mgoogle/protobuf/descriptor.proto=google.golang.org/protobuf/types/descriptorpb
EXAMPLES_PROTO=examples/foo.proto

install: $(BQ_PLUGIN)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ go install github.com/chreds/protoc-gen-bq-schema@latest

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

Make sure protoc-gen-go version installed is from google.golang.org/protobuf/cmd/protoc-gen-go@latest
(See: https://developers.google.com/protocol-buffers/docs/reference/go-generated)

Do NOT use deprecated github.com/golang/protobuf/protoc-gen-go/plugin

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

Expand Down
3 changes: 3 additions & 0 deletions bq_field.proto
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ message BigQueryFieldOptions {

// Optionally add PolicyTag for a field in BigQuery schema.
string policy_tags = 6;

// Whether is primary key, doesn't impact table schema but can be looked up later (for example for generating materialized views).
bool is_primary = 7;
}


Expand Down
2 changes: 1 addition & 1 deletion pkg/converter/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path"
"strings"

protos "github.com/chreds/protoc-gen-bq-schema/protos"
"github.com/chreds/protoc-gen-bq-schema/protos"
"github.com/golang/glog"
"google.golang.org/protobuf/types/pluginpb"
"google.golang.org/protobuf/encoding/prototext"
Expand Down
46 changes: 30 additions & 16 deletions protos/bq_field.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions protos/bq_table.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f7acf01

Please sign in to comment.