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

google_bigquery_table cannot create a table with num_hash partition start range of 0 #6525

Closed
amerenda opened this issue Jun 3, 2020 · 4 comments · Fixed by GoogleCloudPlatform/magic-modules#3617, #6562 or hashicorp/terraform-provider-google-beta#2153
Assignees
Labels

Comments

@amerenda
Copy link

amerenda commented Jun 3, 2020

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 an 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 an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v0.12.24

Affected Resource(s)

  • google_bigquery_table

Terraform Configuration Files

resource "google_bigquery_table" "table" {
  project       = var.project_id
  dataset_id    = google_bigquery_dataset.datataset.dataset_id
  table_id      = "table"
  friendly_name = "table"
  provider      = google-beta
  schema = file(
"${path.module}/schemas/${google_bigquery_dataset.dataset.dataset_id}/table_schema.json")

  range_partitioning {
    field = "num_hash"
    range {
      start    = 0
      end      = 500
      interval = 1
    }
  }

  lifecycle {
    prevent_destroy = true
    ignore_changes = [
      schema,
    ]
  }
}

Debug Output

https://gist.github.com/amerenda/26cbb92d0727d38188872284f80a9c81

Panic Output

N/A

Expected Behavior

terraform should create a partitioned bigquery table in the provided dataset. The field should be num_hash, and the start should be 0.

Actual Behavior

Error: googleapi: Error 400: Invalid value for Long:  is not the correct type, invalid

  on ../../modules/moove-road-iq/bigquery.tf line 393, in resource "google_bigquery_table" "active_segments":
 393: resource "google_bigquery_table" "active_segments" {

This error is not present, and the apply is successful if the range start is set to 1.

Steps to Reproduce

  1. terraform apply

Important Factoids

If the table is created manually with a range start of 0, this works as expected.

Workaround

  1. Create the table manually
  2. Create the table in terraform
  3. Import the table into terraform
  4. add range_partitioning to ignore_changes
@ghost ghost added the bug label Jun 3, 2020
@edwardmedia edwardmedia self-assigned this Jun 3, 2020
@edwardmedia
Copy link
Contributor

edwardmedia commented Jun 3, 2020

@amerenda can you share your table_schema.json? Below is from your log. Did you provide startwhich is required? It might be helpful if you can provide full debug log as well. Thank you

2020-06-03T16:41:54.915-0400 [DEBUG] plugin.terraform-provider-google-beta_v3.24.0_x5:  "rangePartitioning": {
2020-06-03T16:41:54.915-0400 [DEBUG] plugin.terraform-provider-google-beta_v3.24.0_x5:   "field": "num_hash",
2020-06-03T16:41:54.915-0400 [DEBUG] plugin.terraform-provider-google-beta_v3.24.0_x5:   "range": {
2020-06-03T16:41:54.915-0400 [DEBUG] plugin.terraform-provider-google-beta_v3.24.0_x5:    "end": "500",
2020-06-03T16:41:54.915-0400 [DEBUG] plugin.terraform-provider-google-beta_v3.24.0_x5:    "interval": "1"
2020-06-03T16:41:54.915-0400 [DEBUG] plugin.terraform-provider-google-beta_v3.24.0_x5:   }

@edwardmedia
Copy link
Contributor

@amerenda is this still an issue with you?

@edwardmedia
Copy link
Contributor

edwardmedia commented Jun 9, 2020

The start field appears to be dropped in the request payload if ts value is set to 0. It is a required field

      ~ range_partitioning {
            field = "permalink"
          ~ range {
                end      = 500
                interval = 1
              ~ start    = 1 -> 0
            }
        }
 "rangePartitioning": {
   "field": "permalink",
   "range": {
   "end": "500",
    "interval": "1"
   }
  },

@ghost
Copy link

ghost commented Jul 11, 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 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Jul 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.