Skip to content

Commit

Permalink
Fix integration test, adjust docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexott committed Oct 18, 2024
1 parent b52402a commit 2603ace
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
12 changes: 8 additions & 4 deletions docs/resources/alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ In addition to all the arguments above, the following attributes are exported:

## Migrating from `databricks_sql_alert` resource

Under the hood, the new resource uses the same data as the `databricks_sql_alert`, but is exposed via a different API. This means that we can migrate existing alerts without recreating them. This operation is done in few steps:
Under the hood, the new resource uses the same data as the `databricks_sql_alert`, but is exposed via a different API. This means that we can migrate existing alerts without recreating them.

-> It's also recommended to migrate to the `databricks_query` resource - see [databricks_query](query.md) for more details.

This operation is done in few steps:

* Record the ID of existing `databricks_sql_alert`, for example, by executing the `terraform state show databricks_sql_alert.alert` command.
* Create the code for the new implementation by performing the following changes:
Expand Down Expand Up @@ -109,7 +113,7 @@ we'll have a new resource defined as:

```hcl
resource "databricks_alert" "alert" {
query_id = databricks_sql_query.this.id
query_id = databricks_query.this.id
display_name = "My Alert"
parent_path = databricks_directory.shared_dir.path
condition {
Expand Down Expand Up @@ -205,6 +209,6 @@ terraform import databricks_alert.this <alert-id>

The following resources are often used in the same context:

* [databricks_sql_query](sql_query.md) to manage Databricks SQL [Queries](https://docs.databricks.com/sql/user/queries/index.html).
* [databricks_sql_endpoint](sql_endpoint.md) to manage Databricks SQL [Endpoints](https://docs.databricks.com/sql/admin/sql-endpoints.html).
* [databricks_query](query.md) to manage [Databricks SQL Queries](https://docs.databricks.com/sql/user/queries/index.html).
* [databricks_sql_endpoint](sql_endpoint.md) to manage [Databricks SQL Endpoints](https://docs.databricks.com/sql/admin/sql-endpoints.html).
* [databricks_directory](directory.md) to manage directories in [Databricks Workpace](https://docs.databricks.com/workspace/workspace-objects.html).
4 changes: 2 additions & 2 deletions docs/resources/job.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ One of the `query`, `dashboard` or `alert` needs to be provided.

* `warehouse_id` - (Required) ID of the (the [databricks_sql_endpoint](sql_endpoint.md)) that will be used to execute the task. Only Serverless & Pro warehouses are supported right now.
* `parameters` - (Optional) (Map) parameters to be used for each run of this task. The SQL alert task does not support custom parameters.
* `query` - (Optional) block consisting of single string field: `query_id` - identifier of the Databricks SQL Query ([databricks_sql_query](sql_query.md)).
* `query` - (Optional) block consisting of single string field: `query_id` - identifier of the Databricks Query ([databricks_query](query.md)).
* `dashboard` - (Optional) block consisting of following fields:
* `dashboard_id` - (Required) (String) identifier of the Databricks SQL Dashboard [databricks_sql_dashboard](sql_dashboard.md).
* `subscriptions` - (Optional) a list of subscription blocks consisting out of one of the required fields: `user_name` for user emails or `destination_id` - for Alert destination's identifier.
* `custom_subject` - (Optional) string specifying a custom subject of email sent.
* `pause_subscriptions` - (Optional) flag that specifies if subscriptions are paused or not.
* `alert` - (Optional) block consisting of following fields:
* `alert_id` - (Required) (String) identifier of the Databricks SQL Alert.
* `alert_id` - (Required) (String) identifier of the Databricks Alert ([databricks_alert](alert.md)).
* `subscriptions` - (Optional) a list of subscription blocks consisting out of one of the required fields: `user_name` for user emails or `destination_id` - for Alert destination's identifier.
* `pause_subscriptions` - (Optional) flag that specifies if subscriptions are paused or not.
* `file` - (Optional) block consisting of single string fields:
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,6 @@ terraform import databricks_query.this <query-id>

The following resources are often used in the same context:

* [databricks_sql_query](sql_query.md) to manage Databricks SQL [Queries](https://docs.databricks.com/sql/user/queries/index.html).
* [databricks_sql_endpoint](sql_endpoint.md) to manage Databricks SQL [Endpoints](https://docs.databricks.com/sql/admin/sql-endpoints.html).
* [databricks_alert](alert.md) to manage [Databricks SQL Alerts](https://docs.databricks.com/en/sql/user/alerts/index.html).
* [databricks_sql_endpoint](sql_endpoint.md) to manage [Databricks SQL Endpoints](https://docs.databricks.com/sql/admin/sql-endpoints.html).
* [databricks_directory](directory.md) to manage directories in [Databricks Workpace](https://docs.databricks.com/workspace/workspace-objects.html).
12 changes: 6 additions & 6 deletions internal/acceptance/permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,20 +841,20 @@ func TestAccPermissions_ServingEndpoint(t *testing.T) {
func TestAccPermissions_Alert(t *testing.T) {
loadDebugEnvIfRunsFromIDE(t, "workspace")
alertTemplate := `
resource "databricks_sql_query" "this" {
name = "{var.STICKY_RANDOM}-query"
query = "SELECT 1 AS p1, 2 as p2"
data_source_id = "{env.TEST_DEFAULT_WAREHOUSE_DATASOURCE_ID}"
resource "databricks_query" "this" {
display_name = "{var.STICKY_RANDOM}-query"
query_text = "SELECT 1 AS p1, 2 as p2"
warehouse_id = "{env.TEST_DEFAULT_WAREHOUSE_ID}"
}
resource "databricks_alert" "this" {
query_id = databricks_sql_query.this.id
query_id = databricks_query.this.id
display_name = "{var.STICKY_RANDOM}-alert"
condition {
op = "GREATER_THAN"
operand {
column {
name = "value"
name = "p1"
}
}
threshold {
Expand Down

0 comments on commit 2603ace

Please sign in to comment.