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

Add "state" and "error_result" field to google_bigquery_job #8357

Closed

Comments

@maqiuyujoyce
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

We'd like to have state and error_result fields in the list of exported attributes of google_bigquery_job so that it's possible to know the job status.

New or Affected Resource(s)

  • google_bigquery_job

Potential Terraform Configuration

# Propose what you think the configuration to take advantage of this feature should look like.
# We may not use it verbatim, but it's helpful in understanding your intent.

References

@kanterov
Copy link

kanterov commented Feb 2, 2021

Hi,

Thanks a lot of helping out and creating this issue. I did this patch today:

diff --git a/mmv1/products/bigquery/api.yaml b/mmv1/products/bigquery/api.yaml
index 73d285224..3a7343419 100644
--- a/mmv1/products/bigquery/api.yaml
+++ b/mmv1/products/bigquery/api.yaml
@@ -978,6 +978,40 @@ objects:
             description: |
               The geographic location of the job. The default value is US.
             default_value: 'US'
+      - !ruby/object:Api::Type::NestedObject
+        name: 'status'
+        output: true
+        description: |
+          The status of this job. Examine this value when polling an asynchronous job to see if the job is complete.
+        properties:
+          - !ruby/object:Api::Type::String
+            name: 'errorResult'
+            output: true
+            description: |
+              Final error result of the job. If present, indicates that the job has completed and was unsuccessful.
+          - !ruby/object:Api::Type::Array
+            name: 'errors'
+            output: true
+            description: |
+              The first errors encountered during the running of the job. The final message
+              includes the number of errors that caused the process to stop. Errors here do
+              not necessarily mean that the job has not completed or was unsuccessful.
+            item_type: !ruby/object:Api::Type::NestedObject
+              properties:
+                - !ruby/object:Api::Type::String
+                  name: 'reason'
+                  description: A short error code that summarizes the error.
+                - !ruby/object:Api::Type::String
+                  name: 'location'
+                  description: Specifies where the error occurred, if present.
+                - !ruby/object:Api::Type::String
+                  name: 'message'
+                  description: A human-readable description of the error.
+          - !ruby/object:Api::Type::String
+            name: 'state'
+            output: true
+            description: |
+              Running state of the job. Valid states include 'PENDING', 'RUNNING', and 'DONE'.
   - !ruby/object:Api::Resource
     name: 'Table'
     kind: 'bigquery#table'

It seems to work, but one thing that surprises me is that status property is printed out as an array of objects, instead of a regular object:

    status     = [
        {
            error_result = ""
            errors       = []
            state        = "DONE"
        },
    ]

I'm wondering if this is the right direction, and anybody can help with that.

@kanterov
Copy link

kanterov commented Feb 2, 2021

Looking into generator code I believe this is because of output: true at:

+      - !ruby/object:Api::Type::NestedObject
+        name: 'status'
+        output: true

kanterov added a commit to kanterov/terraform-provider-google that referenced this issue Feb 2, 2021
@rileykarson
Copy link
Collaborator

@kanterov: Terraform doesn't actually support an object type, and objects are represented as single-element arrays so that's expected! Values are referenced as status.0.error_result instead of status.error_result.

kanterov added a commit to kanterov/magic-modules that referenced this issue Feb 2, 2021
slevenick pushed a commit to GoogleCloudPlatform/magic-modules that referenced this issue Feb 3, 2021
* Add `status` field to `google_bigquery_job`

fixes hashicorp/terraform-provider-google#8357

* fixup! ignore `.status.0.state` in tests
modular-magician added a commit to modular-magician/terraform-provider-google-beta that referenced this issue Feb 3, 2021
* Add `status` field to `google_bigquery_job`

fixes hashicorp/terraform-provider-google#8357

* fixup! ignore `.status.0.state` in tests

Signed-off-by: Modular Magician <magic-modules@google.com>
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Feb 3, 2021
* Add `status` field to `google_bigquery_job`

fixes hashicorp#8357

* fixup! ignore `.status.0.state` in tests

Signed-off-by: Modular Magician <magic-modules@google.com>
modular-magician added a commit to hashicorp/terraform-provider-google-beta that referenced this issue Feb 3, 2021
* Add `status` field to `google_bigquery_job`

fixes hashicorp/terraform-provider-google#8357

* fixup! ignore `.status.0.state` in tests

Signed-off-by: Modular Magician <magic-modules@google.com>
modular-magician added a commit that referenced this issue Feb 3, 2021
* Add `status` field to `google_bigquery_job`

fixes #8357

* fixup! ignore `.status.0.state` in tests

Signed-off-by: Modular Magician <magic-modules@google.com>
@ghost
Copy link

ghost commented Mar 6, 2021

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 as resolved and limited conversation to collaborators Mar 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants