Skip to content
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

What is the relationship between the Protobuf models in bigquery.storage.v1 and JSON models in bigquery.model ?. #2831

Open
damnMeddlingKid opened this issue Jul 14, 2023 · 2 comments
Assignees
Labels
api: bigquery Issues related to the googleapis/java-bigquery API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@damnMeddlingKid
Copy link

damnMeddlingKid commented Jul 14, 2023

Im currently using the JSON models for TableFieldSchema from com.google.api.services.bigquery.model , this has an equivalaent model in com.google.cloud.bigquery.storage.v1 derived from Protobuf. What is the relationship between these two ?.

  1. Can i convert to and from these models somehow ?, the protobuf has a well typed interface that is nice to work with but some utility functions expect the JSON model
  2. Can i rely on these two models to be in sync with each other ?.

For example i'd like to import constants from the proto version and use it to build the json model.

import com.google.api.services.bigquery.model.{TableFieldSchema => JSONTableFieldSchema} //alias import
import com.google.cloud.bigquery.storage.v1.{TableFieldSchema => ProtoTableFieldSchema} //alias import

new JSONTableFIeldSchema().setType(ProtoTableFieldSchema.Type.STRING.name()) 

instead of

new JSONTableFIeldSchema().setType("STRING") 
@damnMeddlingKid damnMeddlingKid changed the title What is the relationship between the Protobuf and JSON models in bigquery.model ?. What is the relationship between the Protobuf models in bigquery.storage.v1 and JSON models in bigquery.model ?. Jul 14, 2023
@damnMeddlingKid
Copy link
Author

damnMeddlingKid commented Jul 20, 2023

It looks like there is code to go from the json model to proto https://github.com/apache/beam/blob/2c59a748b91a0988e0b8e332f18bd9db072c3e95/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/TableRowToStorageApiProto.java#L768

I don't know if the reverse exists. The mapping of type definitions is not public so there isn't something that can be easily imported.

@blakeli0 blakeli0 transferred this issue from googleapis/google-api-java-client-services Jul 28, 2023
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/java-bigquery API. label Jul 28, 2023
@blakeli0
Copy link
Contributor

@Neenu1995 Transferring this issue to BigQuery since it's BigQuery specific.

@obada-ab obada-ab added type: question Request for information or clarification. Not an issue. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jul 31, 2023
@Neenu1995 Neenu1995 assigned PhongChuong and unassigned Neenu1995 May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/java-bigquery API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

5 participants