fix: resolved issue with run_as_role not being applied on databricks_sql_query resource#2940
Conversation
…sql_query resource Co-authored-by: Matthias De Vriendt <mdevriendt@korfinancial.com>
| Query string `json:"query"` | ||
| // Deprecated: Use databricks_job resource to schedule a Query | ||
| Schedule *QuerySchedule `json:"schedule"` | ||
| RunAsRole string `json:"run_as_role,omitempty"` |
There was a problem hiding this comment.
If the API fills run_as_role with default owner, then it makes sense to add suppress_diff, like this: https://github.com/databricks/terraform-provider-databricks/blob/master/sql/resource_sql_dashboard.go#L19
There was a problem hiding this comment.
Hi Alex, can you explain what the suppress_diff exactly does? I've read the documentation in the Contributor docs, but it's not quite clear to me yet.
There was a problem hiding this comment.
It's suppressing the diff from a default value to an empty string. It's needed because if you declare the resource without run_as_role, then API will fill it with default owner, but when you run apply next time, because run_as_role is empty in the query, then it will be detected as drift, and will try to reset it back.
There was a problem hiding this comment.
Ah, makes sense. However, suppress_diff is already defined on the QueryEntity's RunAsState property. Isn't the Query api object you're referencing here used to represent the Databricks API objects, so unrelated to the Terraform state, and therefore requiring no suppress_diff config here?
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #2940 +/- ##
==========================================
- Coverage 83.68% 83.68% -0.01%
==========================================
Files 153 153
Lines 13612 13610 -2
==========================================
- Hits 11391 11389 -2
Misses 1593 1593
Partials 628 628
|
alexott
left a comment
There was a problem hiding this comment.
thank you for contribution!
| Query string `json:"query"` | ||
| // Deprecated: Use databricks_job resource to schedule a Query | ||
| Schedule *QuerySchedule `json:"schedule"` | ||
| RunAsRole string `json:"run_as_role,omitempty"` |
Fix for: #2939
Changes
The
run_as_roleproperty wasn't being applied correctly on a databricks_sql_query resource, as documented in #2939. This PR tries to solve this issue by aligning the TF code with the Databricks Query API, so that run_as_role is only specified and queried from the top-level object, and not from theoptionsblock anymore.Tests
Specifically, the
sql/resource_sql_query_test.gowas updated and run to verify this fix. A proper integration test run is still required to validate the fix.make testrun locallydocs/folderinternal/acceptance