From d3cbc5a6b8cd6b133a60c14f8a8c0a20d34b1f8d Mon Sep 17 00:00:00 2001 From: Yuqi Zhang Date: Mon, 18 Nov 2024 12:50:55 -0800 Subject: [PATCH 1/2] Update type mapping in convert.go Per https://cloud.google.com/bigquery/docs/write-api#data_type_conversions, the duration protobuf type should be mapped to INTERVAL type on BigQuery side. --- pkg/converter/convert.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/converter/convert.go b/pkg/converter/convert.go index de49954..f545cb3 100644 --- a/pkg/converter/convert.go +++ b/pkg/converter/convert.go @@ -27,7 +27,7 @@ var ( ".google.protobuf.BoolValue": "BOOLEAN", ".google.protobuf.StringValue": "STRING", ".google.protobuf.BytesValue": "BYTES", - ".google.protobuf.Duration": "STRING", + ".google.protobuf.Duration": "INTERVAL", ".google.protobuf.Timestamp": "TIMESTAMP", } typeFromFieldType = map[descriptor.FieldDescriptorProto_Type]string{ From 84a120ff15a77a68b63ff17dfc1486a53fd09964 Mon Sep 17 00:00:00 2001 From: Yuqi Zhang Date: Mon, 18 Nov 2024 15:39:55 -0800 Subject: [PATCH 2/2] Update plugin_test.go --- pkg/converter/plugin_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/converter/plugin_test.go b/pkg/converter/plugin_test.go index c35f0d6..083c2ed 100644 --- a/pkg/converter/plugin_test.go +++ b/pkg/converter/plugin_test.go @@ -416,7 +416,7 @@ func TestWellKnownTypes(t *testing.T) { { "name": "bool", "type": "BOOLEAN", "mode": "NULLABLE" }, { "name": "str", "type": "STRING", "mode": "NULLABLE" }, { "name": "bytes", "type": "BYTES", "mode": "NULLABLE" }, - { "name": "du", "type": "STRING", "mode": "NULLABLE" }, + { "name": "du", "type": "INTERVAL", "mode": "NULLABLE" }, { "name": "t", "type": "TIMESTAMP", "mode": "NULLABLE" } ]`, })