The problem had to do with the Date and Timestamp fields. The problem was 
solved by converting them to int64.

On Saturday, June 10, 2023 at 10:56:36 PM UTC-5 Tony Piazza wrote:

> My current task requires me to use the BigQuery Storage Write API. I have 
> created a .proto file and was able to use protoc to generate a Python 
> message class. I am seeing this exception when creating an instance of that 
> class:
>
> *TypeError: Message must be initialized with a dict: 
> combocurve.Measurement*
>
> *File "/google/api_core/grpc_helpers.py", line 162, in 
> error_remapped_callable*
>
> Here is my .proto file:
>
> syntax = "proto2";
>
> package combocurve;
>
> import "google/protobuf/timestamp.proto";
> import "google/type/date.proto";
>
> message Measurement {
> required string device_id = 1;
> required google.type.Date last_service_date = 2;
> optional double temperature = 3;
> optional double pressure = 4;
> optional google.protobuf.Timestamp created_at = 5;
> }
>
> Here is the code that is raising the exception:
>
> measurement = Measurement(
> device_id='ABC123',
> last_service_date=date_pb2.Date(
> year=last_service_date.year, 
> month=last_service_date.month, 
> day=last_service_date.day),
> temperature=10.0,
> pressure=20.0,
> created_at=int(created_at.timestamp() * 1e6)
> )
>
> Please let me know if you have any ideas as to what is causing this 
> exception.
>
> Thanks in advance for your help!
>
> -Tony
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/b97189ab-2211-4281-8e9f-84e75a97cb2bn%40googlegroups.com.

Reply via email to