[
https://issues.apache.org/jira/browse/BEAM-11047?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17213801#comment-17213801
]
Jonas Grabber commented on BEAM-11047:
--------------------------------------
See: https://github.com/apache/beam/pull/13058#issuecomment-706236204
{quote}The purpose of the convertGenericRecordToTableRow class is to provide
compatibility with BigQuery's legacy JSON TableRow type. I can't find any
documentation here, but my understanding is that -- regrettably -- INTEGER
values are sent as strings in the original JSON, and so this is done here for
compatibility reasons. I don't think we can change this at this point, anyways,
as existing pipelines rely on this behavior.
If you're looking to optimize your storage API pipelines, I would encourage you
to look at consuming the GenericRecords produced by the stream source directly,
rather than converting them to TableRow.{quote}
> BigQuery IO: Avro INTEGER values get converted to String objects
> ----------------------------------------------------------------
>
> Key: BEAM-11047
> URL: https://issues.apache.org/jira/browse/BEAM-11047
> Project: Beam
> Issue Type: Bug
> Components: io-java-gcp
> Affects Versions: 2.22.0, 2.23.0, 2.24.0
> Reporter: Jonas Grabber
> Priority: P2
> Labels: bigquery, java
> Time Spent: 1h
> Remaining Estimate: 0h
>
> For some reason, convertRequiredField used in
> BigQueryAvroUtils.convertGenericRecordToTableRow [casts values with the Avro
> INTEGER type to Long, but then converts them to String objects via
> toString|https://github.com/apache/beam/blob/v2.23.0/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryAvroUtils.java#L326].
> I'm quite unsure where convertGenericRecordToTableRow is used elsewhere, but
> we use it to utilize BigQuery's Storage API reads.
> I'm fairly certain this is not expected behaviour because other types are
> converted properly and due to the cast to Long it's ensured that any values
> will fit into Long objects anyways.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)