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

Support range partitioning for BigQuery tables #5239

Closed
tristan957 opened this issue Dec 19, 2019 · 13 comments
Closed

Support range partitioning for BigQuery tables #5239

tristan957 opened this issue Dec 19, 2019 · 13 comments
Assignees
Labels

Comments

@tristan957
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

Right now the google_bigquery_table resource only supports time partitioning. Google's BigQuery documentation supports a notion of range partitioning (https://cloud.google.com/bigquery/docs/creating-integer-range-partitions). Right now it is impossible to model range partitioned tables in Terraform.

New or Affected Resource(s)

  • google_bigquery_table

Potential Terraform Configuration

resource "google_bigquery_table" "weather-locations" {
  dataset_id    = google_bigquery_dataset.twc
  table_id      = "weather_locations"
  friendly_name = "Weather Loactions"
  schema        = file("${path.module}/schemas/twc/weather_locations.json")
  range_partitioning {
    type                     = "INTEGER"
    field                    = "num_hash"
    start = 0
    end = 100
    interval = 10
  }
}

References

@ghost ghost added the enhancement label Dec 19, 2019
@tristan957
Copy link
Author

Is there anything more required, other than editing this file (https://github.com/GoogleCloudPlatform/magic-modules/blob/master/third_party/terraform/resources/resource_bigquery_table.go.erb) and adding documentation somewhere?

@emilymye
Copy link
Contributor

@sid0911
Copy link

sid0911 commented Mar 5, 2020

Team, range_partitioning is not working for me. Could you please help to resolve this issue ?

Error: Unsupported block type

on bigqtable.tf line 51, in resource "google_bigquery_table" "bq_tables_rgpt":
51: range_partitioning {

Blocks of type "range_partitioning" are not expected here.

@tristan957
Copy link
Author

I already answered you yesterday. Are you using the beta provider?

@sid0911
Copy link

sid0911 commented Mar 6, 2020

Thanks for your response tristan957.
Yes, I am using beta provider

@tristan957
Copy link
Author

Post your whole resource definition

@sid0911
Copy link

sid0911 commented Mar 8, 2020

Here is my resource definition:

resource "google_bigquery_table" "bq_tables_rgpt" {
project = var.project_id
dataset_id = google_bigquery_dataset.tera_gcp_dtset1.dataset_id
table_id = "btd_ebim_fal_product_agg_mnth"
friendly_name = "Weather Loactions"
schema = file("${path.module}/files/createTableSqls/rangept/btd_ebim_fal_product_agg_mnth.json")
range_partitioning {
type = "INTEGER"
field = "year_month"
range {
start = 200001
end = 209912
interval = 1
}
}
depends_on = [google_bigquery_dataset.tera_gcp_dtset1]
}

@tristan957
Copy link
Author

post where you instantiate your provider

@sid0911
Copy link

sid0911 commented Mar 9, 2020

provider "google" {
version = "~> 3.11"
credentials = file("creds/round-pilot-267411-bd02bbe634d8.json")
project = "round-pilot-267411"
region = "us-central1"
}

provider "google-beta" {
version = "~> 3.11"
credentials = file("creds/round-pilot-267411-bd02bbe634d8.json")
}

terraform {
backend "gcs" {}
}

@tristan957
Copy link
Author

you have to specify your beta provider in your resource otherwise you will use the non-beta provider. Reminder that GitHub is not a support forum.

@sid0911
Copy link

sid0911 commented Mar 9, 2020

Thank you so much, Tristan. Appreciate your help!

@tristan957
Copy link
Author

no problem. Good luck with your work.

@ghost
Copy link

ghost commented Apr 5, 2020

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.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 5, 2020
@github-actions github-actions bot added service/bigquery forward/review In review; remove label to forward labels Jan 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants