Skip to content

Commit

Permalink
Error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-artie committed Jun 13, 2024
1 parent 218b9ea commit 4e717c8
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions clients/bigquery/storagewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
)

func schemaToMessageDescriptor(schema bigquery.Schema) (*protoreflect.MessageDescriptor, error) {
storageSchema, err := adapt.BQSchemaToStorageTableSchema(schema)
if err != nil {
return nil, fmt.Errorf("failed to adapt BigQuery schema to protocol buffer schema: %w", err)
}
descriptor, err := adapt.StorageSchemaToProto2Descriptor(storageSchema, "root")
if err != nil {
return nil, fmt.Errorf("failed to build protocol buffer descriptor: %w", err)
}
messageDescriptor, ok := descriptor.(protoreflect.MessageDescriptor)
if !ok {
return nil, fmt.Errorf("adapted descriptor is not a message descriptor")
}
return &messageDescriptor, nil
}

func columnToFieldSchema(column columns.Column) (*bigquery.FieldSchema, error) {
var fieldType bigquery.FieldType
var repeated bool
Expand Down Expand Up @@ -83,7 +67,20 @@ func columnsToMessageDescriptor(cols []columns.Column) (*protoreflect.MessageDes
}
fields[i] = field
}
return schemaToMessageDescriptor(fields)

storageSchema, err := adapt.BQSchemaToStorageTableSchema(fields)
if err != nil {
return nil, fmt.Errorf("failed to adapt BigQuery schema to storage table schema: %w", err)
}
descriptor, err := adapt.StorageSchemaToProto2Descriptor(storageSchema, "root")
if err != nil {
return nil, fmt.Errorf("failed to build proto descriptor: %w", err)
}
messageDescriptor, ok := descriptor.(protoreflect.MessageDescriptor)
if !ok {
return nil, fmt.Errorf("proto descriptor is not a message descriptor")
}
return &messageDescriptor, nil
}

// From https://cloud.google.com/java/docs/reference/google-cloud-bigquerystorage/latest/com.google.cloud.bigquery.storage.v1.CivilTimeEncoder
Expand Down

0 comments on commit 4e717c8

Please sign in to comment.