From f98a6a2b242bf340f1a46c053bc3b2f5551fbc47 Mon Sep 17 00:00:00 2001 From: Stephen O'Kennedy Date: Wed, 15 Jan 2025 16:09:04 +0100 Subject: [PATCH 1/2] Enums are now treated as type STRING in BigQuery * Enums are now represented as INTEGERS in BigQuery schemas. * Updated pluging_test to reflect the change. --- go.mod | 4 ++-- go.sum | 4 ++++ pkg/converter/convert.go | 2 +- pkg/converter/plugin_test.go | 4 ++-- protos/bq_field.pb.go | 4 ++-- protos/bq_table.pb.go | 4 ++-- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index b2b8d47..939fa0a 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module github.com/GoogleCloudPlatform/protoc-gen-bq-schema/v2 go 1.21 require ( - github.com/golang/glog v1.2.3 - google.golang.org/protobuf v1.35.2 + github.com/golang/glog v1.2.4 + google.golang.org/protobuf v1.36.3 ) diff --git a/go.sum b/go.sum index 7dc6d99..b8c9826 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,10 @@ github.com/golang/glog v1.2.3 h1:oDTdz9f5VGVVNGu/Q7UXKWYsD0873HXLHdJUNBsSEKM= github.com/golang/glog v1.2.3/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/glog v1.2.4 h1:CNNw5U8lSiiBk7druxtSHHTsRWcxKoac6kZKm2peBBc= +github.com/golang/glog v1.2.4/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU= +google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= diff --git a/pkg/converter/convert.go b/pkg/converter/convert.go index 9a3bedf..c1591b7 100644 --- a/pkg/converter/convert.go +++ b/pkg/converter/convert.go @@ -47,7 +47,7 @@ var ( descriptor.FieldDescriptorProto_TYPE_STRING: "STRING", descriptor.FieldDescriptorProto_TYPE_BYTES: "BYTES", - descriptor.FieldDescriptorProto_TYPE_ENUM: "STRING", + descriptor.FieldDescriptorProto_TYPE_ENUM: "INTEGER", descriptor.FieldDescriptorProto_TYPE_BOOL: "BOOLEAN", diff --git a/pkg/converter/plugin_test.go b/pkg/converter/plugin_test.go index 083c2ed..9b955e6 100644 --- a/pkg/converter/plugin_test.go +++ b/pkg/converter/plugin_test.go @@ -309,8 +309,8 @@ func TestTypes(t *testing.T) { { "name": "bool", "type": "BOOLEAN", "mode": "NULLABLE" }, { "name": "str", "type": "STRING", "mode": "NULLABLE" }, { "name": "bytes", "type": "BYTES", "mode": "NULLABLE" }, - { "name": "enum1", "type": "STRING", "mode": "NULLABLE" }, - { "name": "enum2", "type": "STRING", "mode": "NULLABLE" }, + { "name": "enum1", "type": "INTEGER", "mode": "NULLABLE" }, + { "name": "enum2", "type": "INTEGER", "mode": "NULLABLE" }, { "name": "grp1", "type": "RECORD", "mode": "NULLABLE", "fields": [{ "name": "i1", "type": "INTEGER", "mode": "NULLABLE" }] diff --git a/protos/bq_field.pb.go b/protos/bq_field.pb.go index c4817c2..bb102f9 100644 --- a/protos/bq_field.pb.go +++ b/protos/bq_field.pb.go @@ -14,8 +14,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 -// protoc v5.26.1 +// protoc-gen-go v1.35.2 +// protoc v5.29.2 // source: bq_field.proto package protos diff --git a/protos/bq_table.pb.go b/protos/bq_table.pb.go index f13bd91..aea511a 100644 --- a/protos/bq_table.pb.go +++ b/protos/bq_table.pb.go @@ -14,8 +14,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 -// protoc v5.26.1 +// protoc-gen-go v1.35.2 +// protoc v5.29.2 // source: bq_table.proto package protos From d426afcdc425fd15794eb9a954fbf5ef2236aee7 Mon Sep 17 00:00:00 2001 From: Stephen O'Kennedy Date: Wed, 15 Jan 2025 16:09:04 +0100 Subject: [PATCH 2/2] Enums are now treated as type INTEGER in BigQuery * Enums are now represented as INTEGERS in BigQuery schemas. * Updated pluging_test to reflect the change. --- go.mod | 4 ++-- go.sum | 4 ++++ pkg/converter/convert.go | 2 +- pkg/converter/plugin_test.go | 4 ++-- protos/bq_field.pb.go | 4 ++-- protos/bq_table.pb.go | 4 ++-- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index b2b8d47..939fa0a 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module github.com/GoogleCloudPlatform/protoc-gen-bq-schema/v2 go 1.21 require ( - github.com/golang/glog v1.2.3 - google.golang.org/protobuf v1.35.2 + github.com/golang/glog v1.2.4 + google.golang.org/protobuf v1.36.3 ) diff --git a/go.sum b/go.sum index 7dc6d99..b8c9826 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,10 @@ github.com/golang/glog v1.2.3 h1:oDTdz9f5VGVVNGu/Q7UXKWYsD0873HXLHdJUNBsSEKM= github.com/golang/glog v1.2.3/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/glog v1.2.4 h1:CNNw5U8lSiiBk7druxtSHHTsRWcxKoac6kZKm2peBBc= +github.com/golang/glog v1.2.4/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU= +google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= diff --git a/pkg/converter/convert.go b/pkg/converter/convert.go index 9a3bedf..c1591b7 100644 --- a/pkg/converter/convert.go +++ b/pkg/converter/convert.go @@ -47,7 +47,7 @@ var ( descriptor.FieldDescriptorProto_TYPE_STRING: "STRING", descriptor.FieldDescriptorProto_TYPE_BYTES: "BYTES", - descriptor.FieldDescriptorProto_TYPE_ENUM: "STRING", + descriptor.FieldDescriptorProto_TYPE_ENUM: "INTEGER", descriptor.FieldDescriptorProto_TYPE_BOOL: "BOOLEAN", diff --git a/pkg/converter/plugin_test.go b/pkg/converter/plugin_test.go index 083c2ed..9b955e6 100644 --- a/pkg/converter/plugin_test.go +++ b/pkg/converter/plugin_test.go @@ -309,8 +309,8 @@ func TestTypes(t *testing.T) { { "name": "bool", "type": "BOOLEAN", "mode": "NULLABLE" }, { "name": "str", "type": "STRING", "mode": "NULLABLE" }, { "name": "bytes", "type": "BYTES", "mode": "NULLABLE" }, - { "name": "enum1", "type": "STRING", "mode": "NULLABLE" }, - { "name": "enum2", "type": "STRING", "mode": "NULLABLE" }, + { "name": "enum1", "type": "INTEGER", "mode": "NULLABLE" }, + { "name": "enum2", "type": "INTEGER", "mode": "NULLABLE" }, { "name": "grp1", "type": "RECORD", "mode": "NULLABLE", "fields": [{ "name": "i1", "type": "INTEGER", "mode": "NULLABLE" }] diff --git a/protos/bq_field.pb.go b/protos/bq_field.pb.go index c4817c2..bb102f9 100644 --- a/protos/bq_field.pb.go +++ b/protos/bq_field.pb.go @@ -14,8 +14,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 -// protoc v5.26.1 +// protoc-gen-go v1.35.2 +// protoc v5.29.2 // source: bq_field.proto package protos diff --git a/protos/bq_table.pb.go b/protos/bq_table.pb.go index f13bd91..aea511a 100644 --- a/protos/bq_table.pb.go +++ b/protos/bq_table.pb.go @@ -14,8 +14,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 -// protoc v5.26.1 +// protoc-gen-go v1.35.2 +// protoc v5.29.2 // source: bq_table.proto package protos