KEMBAR78
BigQuery StorageWrite: JsonToProtoMessage numeric error · Issue #1516 · googleapis/java-bigquerystorage · GitHub
Skip to content

BigQuery StorageWrite: JsonToProtoMessage numeric error #1516

@caseyduquettesc

Description

@caseyduquettesc

Environment details

  1. BigQuery StorageWrite
  2. OS type and version: MacOS 11.6.3
  3. Java version: 11
  4. version(s): 2.8.4

Steps to reproduce

  1. Create a bigquery table with only one field of type NUMERIC and with name "d"
  2. Use JsonStreamWriter with this JSON Array [{"d":1}]
  3. run

Stack trace

java.lang.IllegalArgumentException: JSONObject does not have a bytes field at root.d.
	at com.google.cloud.bigquery.storage.v1.JsonToProtoMessage.fillField(JsonToProtoMessage.java:351)
	at com.google.cloud.bigquery.storage.v1.JsonToProtoMessage.convertJsonToProtoMessageImpl(JsonToProtoMessage.java:176)
	at com.google.cloud.bigquery.storage.v1.JsonToProtoMessage.convertJsonToProtoMessage(JsonToProtoMessage.java:115)
	at com.google.cloud.bigquery.storage.v1.JsonStreamWriter.append(JsonStreamWriter.java:140)
	at com.google.cloud.bigquery.storage.v1.JsonStreamWriter.append(JsonStreamWriter.java:99)
	at persistence.BigqueryStreamingClient.streamJsonArray(BigqueryStreamingClient.java:80)

External references such as API reference guides

  • ?

Any additional information below

It seems if you try to write an int/long to a NUMERIC field, it fails because the proto converter requires a bytes object for NUMERIC's. Looking at

it looks like only Strings or ByteStrings are converted to bytes. The end result is not being able to write numeric java types to the NUMERIC BQ column.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: bigquerystorageIssues related to the googleapis/java-bigquerystorage API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions