-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Allow defining a bigquery_table schema directly #910
Comments
Hey @dasch, the reason behind this is that BigQuery schemas can have arbitrary depth (i.e. a schema can contain another schema: https://godoc.org/google.golang.org/api/bigquery/v2#TableFieldSchema), which isn't something that HCL supports. See hashicorp/terraform#13743 for the original discussion about this. Defining another language to support just this use case isn't really a sustainable option when JSON works perfectly well, so I'm going to go ahead and close this but thanks @dasch for the suggestion and feel free to comment if there's something I've missed :) |
Do we need to support all schemas if there's still a JSON fallback option? It would be a much better UX if there was at least support for schemas that can be represented in HCL... |
Are you saying that BigQuery schemas can be represented in HCL? HCL doesn't parse arbitrary text, it has to be part of a specific schema that we specify in the resource definition. Since this field is self-referential (a TableFieldSchema contains a list of other TableFieldSchemas), there's no way to represent it in the resource definition. If you have a workaround I'd be happy to hear it though! |
If the HCL version simply disallows nested schemas it wouldn't be a problem, right? As long as there's a JSON fallback you'd be able to cover most use cases with a nice DSL instead of forcing everyone to use JSON. |
If you have a proposal for a "nice DSL" I'd be happy to hear it- it's not really in our best interest to have to come up with a new language along with a parser/compiler for it in order to support one resource for people that don't wish to use JSON. One thing we could do is have a schema field that allows you to define a flat list of |
My preference would be for something like this: resource "google_bigquery_table" "sales" {
dataset_id = "${google_bigquery_dataset.default.dataset_id}"
table_id = "sales"
field {
name = "product_id"
type = "INT64"
mode = "REQUIRED"
description = "The id of the product that was sold."
}
field {
name = "qty"
type = "INT64"
}
} |
Note that I'm not suggesting a new language that needs to be parsed, just HCL support for defining simple, non-nested fields. |
I think my concern would be that allowing for inline definitions of the simple case inevitably will lead to bug reports where people want to define nested schemas in HCL. |
Sure, that's probably inevitable – but my guess would be that most TF resources are less powerful than tooling specific to the provider. It's not reasonable to expect TF to be able to handle every single nuance, and since there's a fallback that offers the functionality I think it's fine. I think TF is all about a unified, great user experience. Currently, my |
Any update on this? |
Hi @dasch, are you looking for feedback on your idea or on #1113? In that PR I see a bunch of checkboxes, only a few of which were checked. Were you planning on putting the rest of the checkboxes into that PR, or following up with a separate one? I think we just didn't realize you were waiting on us for something. |
@danawillow I was unsure whether the PR would be accepted, so I paused work. |
In theory, I suppose you could make this a data source, and use a |
Fix InstancePTR test
FYI for those looking to solve this today, there is a way to define it mostly in HCL:
|
b/262200574 |
I've looked into this issue and it seems like @dasch wanted to add support for a new field
According to me, this issue has two probable solutions:
In my opinion, we should go with the |
Closing this issue due to the presence of a clean workaround with |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Currently, one must write BigQuery table schemas as JSON, typically in a separate file that's loaded with
file()
. This is a rather odd user experience, as the rest of the table and most other resources in Terraform are defined using HCL.I'd like to suggest that some DSL be added to the resource that allows defining the schema of the table. I'm not terribly opinionated about how that DSL should look, as long as I don't have to write JSON.
Affected Resource(s)
The text was updated successfully, but these errors were encountered: