Skip to content

Commit

Permalink
chore: generate json schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredgunnar committed Nov 10, 2021
1 parent d21a4bc commit 86a789a
Show file tree
Hide file tree
Showing 36 changed files with 1,026 additions and 8 deletions.
2 changes: 1 addition & 1 deletion encoding/protobq/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"cloud.google.com/go/bigquery"
"github.com/google/go-cmp/cmp"
"go.einride.tech/protobuf-bigquery/encoding/protobq"
publicv1 "go.einride.tech/protobuf-bigquery/internal/examples/proto/gen/einride/bigquery/public/v1"
publicv1 "go.einride.tech/protobuf-bigquery/internal/examples/proto/gen/go/einride/bigquery/public/v1"
"google.golang.org/api/iterator"
"google.golang.org/genproto/googleapis/example/library/v1"
"google.golang.org/protobuf/encoding/prototext"
Expand Down
2 changes: 1 addition & 1 deletion encoding/protobq/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"cloud.google.com/go/bigquery"
"go.einride.tech/protobuf-bigquery/encoding/protobq"
publicv1 "go.einride.tech/protobuf-bigquery/internal/examples/proto/gen/einride/bigquery/public/v1"
publicv1 "go.einride.tech/protobuf-bigquery/internal/examples/proto/gen/go/einride/bigquery/public/v1"
"golang.org/x/oauth2/google"
"google.golang.org/api/iterator"
"google.golang.org/protobuf/proto"
Expand Down
2 changes: 1 addition & 1 deletion encoding/protobq/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"cloud.google.com/go/bigquery"
"cloud.google.com/go/civil"
examplev1 "go.einride.tech/protobuf-bigquery/internal/examples/proto/gen/einride/bigquery/example/v1"
examplev1 "go.einride.tech/protobuf-bigquery/internal/examples/proto/gen/go/einride/bigquery/example/v1"
expr "google.golang.org/genproto/googleapis/api/expr/v1beta1"
"google.golang.org/genproto/googleapis/example/library/v1"
"google.golang.org/genproto/googleapis/type/datetime"
Expand Down
2 changes: 1 addition & 1 deletion encoding/protobq/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"cloud.google.com/go/bigquery"
"cloud.google.com/go/civil"
examplev1 "go.einride.tech/protobuf-bigquery/internal/examples/proto/gen/einride/bigquery/example/v1"
examplev1 "go.einride.tech/protobuf-bigquery/internal/examples/proto/gen/go/einride/bigquery/example/v1"
expr "google.golang.org/genproto/googleapis/api/expr/v1beta1"
"google.golang.org/genproto/googleapis/example/library/v1"
"google.golang.org/genproto/googleapis/type/datetime"
Expand Down
2 changes: 1 addition & 1 deletion encoding/protobq/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"

"cloud.google.com/go/bigquery"
examplev1 "go.einride.tech/protobuf-bigquery/internal/examples/proto/gen/einride/bigquery/example/v1"
examplev1 "go.einride.tech/protobuf-bigquery/internal/examples/proto/gen/go/einride/bigquery/example/v1"
"google.golang.org/genproto/googleapis/example/library/v1"
"google.golang.org/protobuf/proto"
"gotest.tools/v3/assert"
Expand Down
2 changes: 1 addition & 1 deletion encoding/protobq/unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"cloud.google.com/go/bigquery"
"cloud.google.com/go/civil"
examplev1 "go.einride.tech/protobuf-bigquery/internal/examples/proto/gen/einride/bigquery/example/v1"
examplev1 "go.einride.tech/protobuf-bigquery/internal/examples/proto/gen/go/einride/bigquery/example/v1"
expr "google.golang.org/genproto/googleapis/api/expr/v1beta1"
"google.golang.org/genproto/googleapis/example/library/v1"
"google.golang.org/genproto/googleapis/type/datetime"
Expand Down
7 changes: 6 additions & 1 deletion internal/examples/proto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ build/protoc-gen-go: ../../../go.mod
$(info [$@] building binary...)
@go build -o $@ google.golang.org/protobuf/cmd/protoc-gen-go

.PHONY: build/protoc-gen-bq-json-schema
build/protoc-gen-bq-json-schema:
$(info [$@] building binary...)
@go build -o $@ ../../../protoc-gen-bq-json-schema

.PHONY: buf-lint
buf-lint: $(buf)
$(info [$@] linting proto schemas...)
Expand All @@ -28,7 +33,7 @@ clang-format: $(clang_format)
$(shell find einride -type f -name '*.proto')

.PHONY: buf-generate
buf-generate: $(buf) build/protoc-gen-go
buf-generate: $(buf) build/protoc-gen-go build/protoc-gen-bq-json-schema
$(info [$@] generating protobuf stubs...)
@$(buf) generate \
--template buf.gen.yaml \
Expand Down
7 changes: 6 additions & 1 deletion internal/examples/proto/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ managed:

plugins:
- name: go
out: gen
out: gen/go
opt: module=go.einride.tech/protobuf-bigquery/internal/examples/proto/gen
path: ./build/protoc-gen-go

- name: bq-json-schema
out: gen/json
opt: format=true
path: ./build/protoc-gen-bq-json-schema
151 changes: 151 additions & 0 deletions internal/examples/proto/gen/json/DogecoinTransaction.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
[
{
"name": "hash",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "size",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "virtual_size",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "version",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "lock_time",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "block_hash",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "block_number",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "block_timestamp",
"type": "TIMESTAMP",
"mode": "NULLABLE"
},
{
"name": "block_timestamp_month",
"type": "DATE",
"mode": "NULLABLE"
},
{
"name": "input_count",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "output_count",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "is_coinbase",
"type": "BOOLEAN",
"mode": "NULLABLE"
},
{
"name": "inputs",
"type": "RECORD",
"mode": "REPEATED",
"fields": [
{
"name": "index",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "spent_transaction_hash",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "spent_output_index",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "script_asm",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "script_hex",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "sequence",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "required_signatures",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "type",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "addresses",
"type": "STRING",
"mode": "REPEATED"
}
]
},
{
"name": "outputs",
"type": "RECORD",
"mode": "REPEATED",
"fields": [
{
"name": "index",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "script_asm",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "script_hex",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "required_signatures",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "type",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "addresses",
"type": "STRING",
"mode": "REPEATED"
}
]
}
]
36 changes: 36 additions & 0 deletions internal/examples/proto/gen/json/ExampleDateTime.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[
{
"name": "date_time",
"type": "RECORD",
"mode": "NULLABLE",
"fields": [
{
"name": "datetime",
"type": "DATETIME",
"mode": "NULLABLE"
},
{
"name": "utc_offset",
"type": "FLOAT",
"mode": "NULLABLE"
},
{
"name": "time_zone",
"type": "RECORD",
"mode": "NULLABLE",
"fields": [
{
"name": "id",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "version",
"type": "STRING",
"mode": "NULLABLE"
}
]
}
]
}
]
7 changes: 7 additions & 0 deletions internal/examples/proto/gen/json/ExampleEnum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"name": "enum_value",
"type": "STRING",
"mode": "NULLABLE"
}
]
34 changes: 34 additions & 0 deletions internal/examples/proto/gen/json/ExampleList.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "int64_list",
"type": "INTEGER",
"mode": "REPEATED"
},
{
"name": "string_list",
"type": "STRING",
"mode": "REPEATED"
},
{
"name": "enum_list",
"type": "STRING",
"mode": "REPEATED"
},
{
"name": "nested_list",
"type": "RECORD",
"mode": "REPEATED",
"fields": [
{
"name": "string_list",
"type": "STRING",
"mode": "REPEATED"
}
]
},
{
"name": "float_value_list",
"type": "FLOAT",
"mode": "REPEATED"
}
]
Loading

0 comments on commit 86a789a

Please sign in to comment.