diff --git a/bigquery/storage/managedwriter/adapt/protoconversion.go b/bigquery/storage/managedwriter/adapt/protoconversion.go index 411febd24308..5cc00c2ed17d 100644 --- a/bigquery/storage/managedwriter/adapt/protoconversion.go +++ b/bigquery/storage/managedwriter/adapt/protoconversion.go @@ -63,6 +63,7 @@ var bqTypeToFieldTypeMap = map[storagepb.TableFieldSchema_Type]descriptorpb.Fiel storagepb.TableFieldSchema_TIME: descriptorpb.FieldDescriptorProto_TYPE_INT64, storagepb.TableFieldSchema_TIMESTAMP: descriptorpb.FieldDescriptorProto_TYPE_INT64, storagepb.TableFieldSchema_RANGE: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE, + storagepb.TableFieldSchema_JSON: descriptorpb.FieldDescriptorProto_TYPE_STRING, } var allowedRangeTypes = []storagepb.TableFieldSchema_Type{ @@ -107,6 +108,7 @@ var bqTypeToWrapperMap = map[storagepb.TableFieldSchema_Type]string{ storagepb.TableFieldSchema_STRING: ".google.protobuf.StringValue", storagepb.TableFieldSchema_TIME: ".google.protobuf.Int64Value", storagepb.TableFieldSchema_TIMESTAMP: ".google.protobuf.Int64Value", + storagepb.TableFieldSchema_JSON: ".google.protobuf.StringValue", } // filename used by well known types proto diff --git a/bigquery/storage/managedwriter/adapt/protoconversion_test.go b/bigquery/storage/managedwriter/adapt/protoconversion_test.go index be15ab19d30b..73f9ebbb134d 100644 --- a/bigquery/storage/managedwriter/adapt/protoconversion_test.go +++ b/bigquery/storage/managedwriter/adapt/protoconversion_test.go @@ -100,6 +100,65 @@ func TestSchemaToProtoConversion(t *testing.T) { }, }, }, + { + description: "json type", + bq: &storagepb.TableSchema{ + Fields: []*storagepb.TableFieldSchema{ + {Name: "json_required", Type: storagepb.TableFieldSchema_JSON, Mode: storagepb.TableFieldSchema_REQUIRED}, + {Name: "json_optional", Type: storagepb.TableFieldSchema_JSON, Mode: storagepb.TableFieldSchema_NULLABLE}, + }}, + wantProto2: &descriptorpb.DescriptorProto{ + Name: proto.String("root"), + Field: []*descriptorpb.FieldDescriptorProto{ + { + Name: proto.String("json_required"), + Number: proto.Int32(1), + Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), + Label: descriptorpb.FieldDescriptorProto_LABEL_REQUIRED.Enum()}, + { + Name: proto.String("json_optional"), + Number: proto.Int32(2), + Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), + Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), + }, + }, + }, + wantProto2Normalized: &descriptorpb.DescriptorProto{ + Name: proto.String("root"), + Field: []*descriptorpb.FieldDescriptorProto{ + { + Name: proto.String("json_required"), + Number: proto.Int32(1), + Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), + Label: descriptorpb.FieldDescriptorProto_LABEL_REQUIRED.Enum(), + }, + { + Name: proto.String("json_optional"), + Number: proto.Int32(2), + Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), + Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), + }, + }, + }, + wantProto3: &descriptorpb.DescriptorProto{ + Name: proto.String("root"), + Field: []*descriptorpb.FieldDescriptorProto{ + { + Name: proto.String("json_required"), + Number: proto.Int32(1), + Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), + Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), + }, + { + Name: proto.String("json_optional"), + Number: proto.Int32(2), + Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), + TypeName: proto.String(".google.protobuf.StringValue"), + Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), + }, + }, + }, + }, { // exercise construct of a submessage description: "nested", @@ -1236,6 +1295,13 @@ func TestNormalizeDescriptor(t *testing.T) { Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), }, + { + Name: proto.String("json_type"), + JsonName: proto.String("jsonType"), + Number: proto.Int32(4), + Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), + Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), + }, }, NestedType: []*descriptorpb.DescriptorProto{ { diff --git a/bigquery/storage/managedwriter/adapt/schemaconversion.go b/bigquery/storage/managedwriter/adapt/schemaconversion.go index 7cbfa8aa3b58..3e88386169cf 100644 --- a/bigquery/storage/managedwriter/adapt/schemaconversion.go +++ b/bigquery/storage/managedwriter/adapt/schemaconversion.go @@ -36,6 +36,7 @@ var fieldTypeMap = map[bigquery.FieldType]storagepb.TableFieldSchema_Type{ bigquery.BigNumericFieldType: storagepb.TableFieldSchema_BIGNUMERIC, bigquery.GeographyFieldType: storagepb.TableFieldSchema_GEOGRAPHY, bigquery.RangeFieldType: storagepb.TableFieldSchema_RANGE, + bigquery.JSONFieldType: storagepb.TableFieldSchema_JSON, } func bqFieldToProto(in *bigquery.FieldSchema) (*storagepb.TableFieldSchema, error) { diff --git a/bigquery/storage/managedwriter/adapt/schemaconversion_test.go b/bigquery/storage/managedwriter/adapt/schemaconversion_test.go index 99ecb4a9a170..ab1a91826da3 100644 --- a/bigquery/storage/managedwriter/adapt/schemaconversion_test.go +++ b/bigquery/storage/managedwriter/adapt/schemaconversion_test.go @@ -95,6 +95,21 @@ func TestFieldConversions(t *testing.T) { }, }, }, + { + desc: "json type", + bq: &bigquery.FieldSchema{ + Name: "name", + Type: bigquery.JSONFieldType, + Description: "description", + Required: true, + }, + proto: &storagepb.TableFieldSchema{ + Name: "name", + Type: storagepb.TableFieldSchema_JSON, + Description: "description", + Mode: storagepb.TableFieldSchema_REQUIRED, + }, + }, { desc: "range type", bq: &bigquery.FieldSchema{ @@ -200,6 +215,17 @@ func TestSchemaConversion(t *testing.T) { }, }, }, + { + description: "json type", + bqSchema: bigquery.Schema{ + {Name: "json", Type: bigquery.JSONFieldType}, + }, + storageSchema: &storagepb.TableSchema{ + Fields: []*storagepb.TableFieldSchema{ + {Name: "json", Type: storagepb.TableFieldSchema_JSON, Mode: storagepb.TableFieldSchema_NULLABLE}, + }, + }, + }, { description: "range types", bqSchema: bigquery.Schema{ diff --git a/bigquery/storage/managedwriter/integration_test.go b/bigquery/storage/managedwriter/integration_test.go index 4a7f2470a6ad..199f662cadf5 100644 --- a/bigquery/storage/managedwriter/integration_test.go +++ b/bigquery/storage/managedwriter/integration_test.go @@ -229,6 +229,10 @@ func TestIntegration_ManagedWriter(t *testing.T) { t.Parallel() testDefaultStreamDynamicJSON(ctx, t, mwClient, bqClient, dataset) }) + t.Run("DefaultStreamJSONData", func(t *testing.T) { + t.Parallel() + testDefaultStreamJSONData(ctx, t, mwClient, bqClient, dataset) + }) t.Run("CommittedStream", func(t *testing.T) { t.Parallel() testCommittedStream(ctx, t, mwClient, bqClient, dataset) @@ -455,6 +459,63 @@ func testDefaultStreamDynamicJSON(ctx context.Context, t *testing.T, mwClient *C withDistinctValues("public", int64(2))) } +func testDefaultStreamJSONData(ctx context.Context, t *testing.T, mwClient *Client, bqClient *bigquery.Client, dataset *bigquery.Dataset) { + testTable := dataset.Table(tableIDs.New()) + if err := testTable.Create(ctx, &bigquery.TableMetadata{Schema: testdata.ComplexTypeSchema}); err != nil { + t.Fatalf("failed to create test table %s: %v", testTable.FullyQualifiedName(), err) + } + + md, descriptorProto := setupDynamicDescriptors(t, testdata.ComplexTypeSchema) + + ms, err := mwClient.NewManagedStream(ctx, + WithDestinationTable(TableParentFromParts(testTable.ProjectID, testTable.DatasetID, testTable.TableID)), + WithType(DefaultStream), + WithSchemaDescriptor(descriptorProto), + ) + if err != nil { + t.Fatalf("NewManagedStream: %v", err) + } + validateTableConstraints(ctx, t, bqClient, testTable, "before send", + withExactRowCount(0)) + + sampleJSONData := [][]byte{ + []byte(`{"json_type":"{\"foo\": \"bar\"}"}`), + []byte(`{"json_type":"{\"key\": \"value\"}"}`), + []byte(`{"json_type":"\"a string\""}`), + } + + var result *AppendResult + for k, v := range sampleJSONData { + message := dynamicpb.NewMessage(md) + + // First, json->proto message + err = protojson.Unmarshal(v, message) + if err != nil { + t.Fatalf("failed to Unmarshal json message for row %d: %v", k, err) + } + // Then, proto message -> bytes. + b, err := proto.Marshal(message) + if err != nil { + t.Fatalf("failed to marshal proto bytes for row %d: %v", k, err) + } + result, err = ms.AppendRows(ctx, [][]byte{b}) + if err != nil { + t.Errorf("single-row append %d failed: %v", k, err) + } + } + + // Wait for the result to indicate ready, then validate. + o, err := result.GetResult(ctx) + if err != nil { + t.Errorf("result error for last send: %v", err) + } + if o != NoStreamOffset { + t.Errorf("offset mismatch, got %d want %d", o, NoStreamOffset) + } + validateTableConstraints(ctx, t, bqClient, testTable, "after send", + withExactRowCount(int64(len(sampleJSONData)))) +} + func testBufferedStream(ctx context.Context, t *testing.T, mwClient *Client, bqClient *bigquery.Client, dataset *bigquery.Dataset) { testTable := dataset.Table(tableIDs.New()) if err := testTable.Create(ctx, &bigquery.TableMetadata{Schema: testdata.SimpleMessageSchema}); err != nil { @@ -1389,6 +1450,7 @@ func TestIntegration_ProtoNormalization(t *testing.T) { t.Run("ComplexType", func(t *testing.T) { t.Parallel() schema := testdata.ComplexTypeSchema + jsonData := "{\"foo\": \"bar\"}" mesg := &testdata.ComplexType{ NestedRepeatedType: []*testdata.NestedType{ { @@ -1404,6 +1466,7 @@ func TestIntegration_ProtoNormalization(t *testing.T) { RangeType: &testdata.RangeTypeTimestamp{ End: proto.Int64(time.Now().UnixNano()), }, + JsonType: &jsonData, } b, err := proto.Marshal(mesg) if err != nil { diff --git a/bigquery/storage/managedwriter/testdata/schemas.go b/bigquery/storage/managedwriter/testdata/schemas.go index 2d76bdf6a181..cd26e15014ad 100644 --- a/bigquery/storage/managedwriter/testdata/schemas.go +++ b/bigquery/storage/managedwriter/testdata/schemas.go @@ -99,6 +99,10 @@ var ( Type: bigquery.TimestampFieldType, }, }, + { + Name: "json_type", + Type: bigquery.JSONFieldType, + }, } // We currently follow proto2 rules here, hence the well known types getting treated as records. diff --git a/bigquery/storage/managedwriter/testdata/testing.pb.go b/bigquery/storage/managedwriter/testdata/testing.pb.go index d9a580431e88..ea57f7df689a 100644 --- a/bigquery/storage/managedwriter/testdata/testing.pb.go +++ b/bigquery/storage/managedwriter/testdata/testing.pb.go @@ -440,6 +440,7 @@ type ComplexType struct { NestedRepeatedType []*NestedType `protobuf:"bytes,1,rep,name=nested_repeated_type,json=nestedRepeatedType" json:"nested_repeated_type,omitempty"` InnerType *InnerType `protobuf:"bytes,2,opt,name=inner_type,json=innerType" json:"inner_type,omitempty"` RangeType *RangeTypeTimestamp `protobuf:"bytes,3,opt,name=range_type,json=rangeType" json:"range_type,omitempty"` + JsonType *string `protobuf:"bytes,4,opt,name=json_type,json=jsonType" json:"json_type,omitempty"` } func (x *ComplexType) Reset() { @@ -495,6 +496,13 @@ func (x *ComplexType) GetRangeType() *RangeTypeTimestamp { return nil } +func (x *ComplexType) GetJsonType() string { + if x != nil && x.JsonType != nil { + return *x.JsonType + } + return "" +} + type ContainsRecursive struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -643,6 +651,7 @@ type WithOneOf struct { Int32Value *int32 `protobuf:"varint,1,opt,name=int32_value,json=int32Value" json:"int32_value,omitempty"` // Types that are assignable to OneofValue: + // // *WithOneOf_StringValue // *WithOneOf_DoubleValue OneofValue isWithOneOf_OneofValue `protobuf_oneof:"oneof_value"` @@ -952,7 +961,7 @@ var file_testing_proto_rawDesc = []byte{ 0x52, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x22, 0xc6, 0x01, 0x0a, 0x0b, 0x43, + 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x22, 0xe3, 0x01, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x78, 0x54, 0x79, 0x70, 0x65, 0x12, 0x46, 0x0a, 0x14, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, @@ -965,61 +974,63 @@ var file_testing_proto_rawDesc = []byte{ 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x22, 0x42, 0x0a, 0x11, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x52, - 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x12, 0x2d, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, - 0x74, 0x61, 0x2e, 0x52, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65, - 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x22, 0x42, 0x0a, 0x0d, 0x52, 0x65, 0x63, 0x75, 0x72, - 0x73, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x31, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, - 0x74, 0x61, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x63, 0x75, 0x72, - 0x73, 0x69, 0x76, 0x65, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x22, 0x52, 0x0a, 0x17, 0x52, - 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65, 0x54, 0x6f, 0x70, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x37, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, - 0x2e, 0x52, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65, 0x54, 0x6f, - 0x70, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x22, - 0x85, 0x01, 0x0a, 0x09, 0x57, 0x69, 0x74, 0x68, 0x4f, 0x6e, 0x65, 0x4f, 0x66, 0x12, 0x1f, 0x0a, - 0x0b, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, - 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x0b, 0x64, 0x6f, 0x75, - 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x0d, 0x0a, 0x0b, 0x6f, 0x6e, 0x65, 0x6f, - 0x66, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xe4, 0x01, 0x0a, 0x0d, 0x44, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, - 0x63, 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x72, 0x63, 0x6f, - 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x74, 0x72, 0x63, 0x6f, 0x6c, 0x5f, 0x77, 0x69, 0x74, 0x68, - 0x64, 0x65, 0x66, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x74, 0x72, 0x63, 0x6f, - 0x6c, 0x57, 0x69, 0x74, 0x68, 0x64, 0x65, 0x66, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x6e, 0x74, 0x63, - 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x69, 0x6e, 0x74, 0x63, 0x6f, 0x6c, - 0x12, 0x25, 0x0a, 0x0e, 0x69, 0x6e, 0x74, 0x63, 0x6f, 0x6c, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64, - 0x65, 0x66, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x69, 0x6e, 0x74, 0x63, 0x6f, 0x6c, - 0x57, 0x69, 0x74, 0x68, 0x64, 0x65, 0x66, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x74, 0x68, 0x65, 0x72, - 0x73, 0x74, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x74, 0x68, 0x65, 0x72, - 0x73, 0x74, 0x72, 0x12, 0x29, 0x0a, 0x10, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x73, 0x74, 0x72, 0x5f, - 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6f, - 0x74, 0x68, 0x65, 0x72, 0x73, 0x74, 0x72, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x22, 0xaa, - 0x01, 0x0a, 0x1a, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, - 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, - 0x06, 0x73, 0x74, 0x72, 0x63, 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, - 0x74, 0x72, 0x63, 0x6f, 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x74, 0x72, 0x63, 0x6f, 0x6c, 0x5f, - 0x77, 0x69, 0x74, 0x68, 0x64, 0x65, 0x66, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, - 0x74, 0x72, 0x63, 0x6f, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x64, 0x65, 0x66, 0x12, 0x16, 0x0a, 0x06, - 0x69, 0x6e, 0x74, 0x63, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x69, 0x6e, - 0x74, 0x63, 0x6f, 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x69, 0x6e, 0x74, 0x63, 0x6f, 0x6c, 0x5f, 0x77, - 0x69, 0x74, 0x68, 0x64, 0x65, 0x66, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x69, 0x6e, - 0x74, 0x63, 0x6f, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x64, 0x65, 0x66, 0x2a, 0x28, 0x0a, 0x08, 0x54, - 0x65, 0x73, 0x74, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x0d, 0x0a, 0x09, 0x54, 0x65, 0x73, 0x74, 0x45, - 0x6e, 0x75, 0x6d, 0x30, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x54, 0x65, 0x73, 0x74, 0x45, 0x6e, - 0x75, 0x6d, 0x31, 0x10, 0x01, 0x42, 0x3d, 0x5a, 0x3b, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x69, 0x67, - 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x64, 0x77, 0x72, 0x69, 0x74, 0x65, 0x72, 0x2f, 0x74, 0x65, 0x73, 0x74, - 0x64, 0x61, 0x74, 0x61, + 0x79, 0x70, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6a, 0x73, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, + 0x22, 0x42, 0x0a, 0x11, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x63, 0x75, + 0x72, 0x73, 0x69, 0x76, 0x65, 0x12, 0x2d, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, + 0x52, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x66, + 0x69, 0x65, 0x6c, 0x64, 0x22, 0x42, 0x0a, 0x0d, 0x52, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, + 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x31, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, + 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, + 0x65, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x22, 0x52, 0x0a, 0x17, 0x52, 0x65, 0x63, 0x75, + 0x72, 0x73, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65, 0x54, 0x6f, 0x70, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x12, 0x37, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, + 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65, 0x54, 0x6f, 0x70, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x22, 0x85, 0x01, 0x0a, + 0x09, 0x57, 0x69, 0x74, 0x68, 0x4f, 0x6e, 0x65, 0x4f, 0x66, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, + 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x0a, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x73, + 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x12, 0x23, 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x0d, 0x0a, 0x0b, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x22, 0xe4, 0x01, 0x0a, 0x0d, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x63, 0x6f, 0x6c, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x72, 0x63, 0x6f, 0x6c, 0x12, 0x25, + 0x0a, 0x0e, 0x73, 0x74, 0x72, 0x63, 0x6f, 0x6c, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x65, 0x66, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x74, 0x72, 0x63, 0x6f, 0x6c, 0x57, 0x69, + 0x74, 0x68, 0x64, 0x65, 0x66, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x6e, 0x74, 0x63, 0x6f, 0x6c, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x69, 0x6e, 0x74, 0x63, 0x6f, 0x6c, 0x12, 0x25, 0x0a, + 0x0e, 0x69, 0x6e, 0x74, 0x63, 0x6f, 0x6c, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x65, 0x66, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x69, 0x6e, 0x74, 0x63, 0x6f, 0x6c, 0x57, 0x69, 0x74, + 0x68, 0x64, 0x65, 0x66, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x73, 0x74, 0x72, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x73, 0x74, 0x72, + 0x12, 0x29, 0x0a, 0x10, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x73, 0x74, 0x72, 0x5f, 0x64, 0x65, 0x66, + 0x61, 0x75, 0x6c, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6f, 0x74, 0x68, 0x65, + 0x72, 0x73, 0x74, 0x72, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x22, 0xaa, 0x01, 0x0a, 0x1a, + 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x50, 0x61, 0x72, + 0x74, 0x69, 0x61, 0x6c, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, + 0x72, 0x63, 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x72, 0x63, + 0x6f, 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x74, 0x72, 0x63, 0x6f, 0x6c, 0x5f, 0x77, 0x69, 0x74, + 0x68, 0x64, 0x65, 0x66, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x74, 0x72, 0x63, + 0x6f, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x64, 0x65, 0x66, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x6e, 0x74, + 0x63, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x69, 0x6e, 0x74, 0x63, 0x6f, + 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x69, 0x6e, 0x74, 0x63, 0x6f, 0x6c, 0x5f, 0x77, 0x69, 0x74, 0x68, + 0x64, 0x65, 0x66, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x69, 0x6e, 0x74, 0x63, 0x6f, + 0x6c, 0x57, 0x69, 0x74, 0x68, 0x64, 0x65, 0x66, 0x2a, 0x28, 0x0a, 0x08, 0x54, 0x65, 0x73, 0x74, + 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x0d, 0x0a, 0x09, 0x54, 0x65, 0x73, 0x74, 0x45, 0x6e, 0x75, 0x6d, + 0x30, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x54, 0x65, 0x73, 0x74, 0x45, 0x6e, 0x75, 0x6d, 0x31, + 0x10, 0x01, 0x42, 0x3d, 0x5a, 0x3b, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x69, 0x67, 0x71, 0x75, 0x65, + 0x72, 0x79, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x64, 0x77, 0x72, 0x69, 0x74, 0x65, 0x72, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, + 0x61, } var ( diff --git a/bigquery/storage/managedwriter/testdata/testing.proto b/bigquery/storage/managedwriter/testdata/testing.proto index 6012e9bc0e63..a317e1acb7bd 100644 --- a/bigquery/storage/managedwriter/testdata/testing.proto +++ b/bigquery/storage/managedwriter/testdata/testing.proto @@ -60,6 +60,7 @@ message ComplexType { repeated NestedType nested_repeated_type = 1; optional InnerType inner_type = 2; optional RangeTypeTimestamp range_type = 3; + optional string json_type = 4; } message ContainsRecursive {