New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
".google.protobuf.Timestamp" is not defined #257
Comments
I believe the JAVA version also always expects an INT64: |
@software-dov Does this look familiar to you? Is there a known issue with proto-plus and timestamp fields? |
@tswast Proto plus works normally to create the proto message. The error occurs during append_rows of the bigquery write client. |
Are you using the |
@tswast Proto plus only handles proto3. I don't see another way to create a proto message at runtime. Because I use BigQuery schema and convert to proto message. |
Per https://cloud.google.com/bigquery/docs/write-api#data_type_conversions
Unfortunately the backend does not yet support Well-Known-Types such as Timestamp, even with proto2. :-( |
Here's an example of writing a timestamp from a code sample I'm working on: row = sample_data_pb2.SampleData()
timestamp_value = datetime.datetime(
2021, 8, 12, 16, 11, 22, 987654, tzinfo=datetime.timezone.utc
)
epoch_value = datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc)
delta = timestamp_value - epoch_value
row.timestamp_col = int(delta.total_seconds()) * 1000000 + int(delta.microseconds)
proto_rows.serialized_rows.append(row.SerializeToString() |
Got it, I'm having difficulty using the write API. |
I've been trying to use it for over a month :( |
The backend team built an API optimized for high throughput, and their choices in row serialization format reflect that. Unfortunately it does mean a lot more client-side work. :-( Thank you for trying and sharing your experience. I will use this thread to try and advocate for more friendly options. |
Thanks @tswast. Pronto Plus support may suffice. |
Closing, as this is a limitation of the BigQuery Storage Write API. There's not much we can do in the client to make protobuf Timestamp well-known-types work, unfortunately. |
@alexsanderp I've been having a similar problem. This solution may be a bit outdated, but if I'm having the same issue now I am sure there are others... Having wrestled with this for days, and working through some alternative options this is the best I have come up with:
Hope this helps. |
I'm wondering whether this should be reopened. https://cloud.google.com/bigquery/docs/write-api#data_type_conversions says that supported protocol buffer types for TIMESTAMP are: int64 (preferred), int32, uint32, google.protobuf.Timestamp |
I created a proto message using proto-plus and it has a timestamp type field. The field uses timestamp_pb2.Timestamp.
When calling the append_rows function from bigquery_write_client, the error occurs:
Error:
Example:
I am using timestamp_pb2 as some timestamps may come in INT64 or STRING format.
@tswast Can you help me?
The text was updated successfully, but these errors were encountered: