-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
bigquery: how to create a BQ schema #5833
Comments
Not sure I understand the question. Take a look at If you're trying to mapping unexported fields, this likely needs custom code. |
|
Oh, I think I understand now. The "schema file" used by CLI is just the underlying API's representation of the schema. We have support via If you're asking about how to create a table with the library and InferSchema, take a look at the examples:
If you mean using this in other tools, could you elaborate more about the workflow you're trying to build? It seems odd to use the library for all the schema detection and then use the CLI for the actual resource creation, but I may just not be understanding. |
right, thanks. I actually just use the CLI. I ended up coding it as follows (which works):
but it would make more sense for your repo to have this, rather than me keeping up with possible changes to the schema. |
This PR does two things: It enhances SchemaFromJSON to work directly with the underlying TableFieldSchema messages from the discovery API definition, and adds a FormatJSONFields method to Schema to export the same format consumed by SchemaFromJSON. With this, we're able clear up the existing internal duplicate logic for this special case, and we manage to address two different feature requests at the same time. Fixes: googleapis#5833 Fixes: googleapis#5867
* feat(bigquery): enhance SchemaFromJSON This PR does two things: It enhances SchemaFromJSON to work directly with the underlying TableFieldSchema messages from the discovery API definition, and adds a FormatJSONFields method to Schema to export the same format consumed by SchemaFromJSON. With this, we're able clear up the existing internal duplicate logic for this special case, and we manage to address two different feature requests at the same time. Fixes: #5833 Fixes: #5867 Co-authored-by: Steffany Brown <30247553+steffnay@users.noreply.github.com>
Hi
I've been trying to create a BQ schema to use with the
bq
from a Go structure:and use it as input to the bq command to create/update tables:
The only way I found to create this schema is to generate it myself. The schema needed seems to be the non-exported structure defined in
google-cloud-go/bigquery/schema.go
Line 544 in 5a2ed6b
I was wondering if I missed something and it's already feasible to generate the schema, or whether this is a missing feature which would be nice to have.
Can you advise?
The text was updated successfully, but these errors were encountered: