Skip to content

Commit 58da0d5

Browse files
Deprecate schedule block in databricks_sql_query resource (#2078)
* [REDASH-4424] Add deprecation note to databricks_sql_query terraform resource docs * add Deprecated: note * Set Deprecated flag to true in the Query's StructToSchema block. * Update test
1 parent 244de7a commit 58da0d5

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

docs/resources/sql_query.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ resource "databricks_sql_query" "q1" {
2929
parent = "folders/${databricks_directory.shared_dir.object_id}"
3030
run_as_role = "viewer"
3131
32-
schedule {
33-
continuous {
34-
interval_seconds = 5 * 60
35-
}
36-
}
37-
3832
parameter {
3933
name = "p1"
4034
title = "Title for p1"
@@ -106,6 +100,8 @@ $ terraform import databricks_sql_query.this <query-id>
106100

107101
In case you see `Error: cannot create sql query: Internal Server Error` during `terraform apply`; double check that you are using the correct [`data_source_id`](sql_endpoint.md)
108102

103+
Operations on `databricks_sql_query` schedules are ⛔️ deprecated. You can create, update or delete a schedule for SQLA and other Databricks resources using the [databricks_job](job.md#sql_task-configuration-block) resource.
104+
109105
## Related Resources
110106

111107
The following resources are often used in the same context:
@@ -115,3 +111,4 @@ The following resources are often used in the same context:
115111
* [databricks_sql_endpoint](sql_endpoint.md) to manage Databricks SQL [Endpoints](https://docs.databricks.com/sql/admin/sql-endpoints.html).
116112
* [databricks_sql_global_config](sql_global_config.md) to configure the security policy, [databricks_instance_profile](instance_profile.md), and [data access properties](https://docs.databricks.com/sql/admin/data-access-configuration.html) for all [databricks_sql_endpoint](sql_endpoint.md) of workspace.
117113
* [databricks_sql_permissions](sql_permissions.md) to manage data object access control lists in Databricks workspaces for things like tables, views, databases, and [more](https://docs.databricks.com/security/access-control/table-acls/object-privileges.html).
114+
* [databricks_job](job.md#sql_task-configuration-block) to schedule Databricks SQL queries (as well as dashboards and alerts) using Databricks Jobs.

sql/api/query.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type Query struct {
1212
Name string `json:"name"`
1313
Description string `json:"description"`
1414
Query string `json:"query"`
15+
// Deprecated: Use databricks_job resource to schedule a Query
1516
Schedule *QuerySchedule `json:"schedule"`
1617
Options *QueryOptions `json:"options,omitempty"`
1718
Tags []string `json:"tags,omitempty"`
@@ -20,6 +21,7 @@ type Query struct {
2021
}
2122

2223
// QuerySchedule ...
24+
// Deprecated: Use databricks_job resource to schedule a Query
2325
type QuerySchedule struct {
2426
// Interval in seconds.
2527
//

sql/resource_sql_query.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type QueryEntity struct {
2020
Name string `json:"name"`
2121
Description string `json:"description,omitempty"`
2222
Query string `json:"query"`
23+
// Deprecated: Use databricks_job resource to schedule a Query
2324
Schedule *QuerySchedule `json:"schedule,omitempty"`
2425
Tags []string `json:"tags,omitempty"`
2526
Parameter []QueryParameter `json:"parameter,omitempty"`
@@ -28,26 +29,30 @@ type QueryEntity struct {
2829
}
2930

3031
// QuerySchedule ...
32+
// Deprecated: Use databricks_job resource to schedule a Query
3133
type QuerySchedule struct {
3234
Continuous *QueryScheduleContinuous `json:"continuous,omitempty"`
3335
Daily *QueryScheduleDaily `json:"daily,omitempty"`
3436
Weekly *QueryScheduleWeekly `json:"weekly,omitempty"`
3537
}
3638

3739
// QueryScheduleContinuous ...
40+
// Deprecated: Use databricks_job resource to schedule a Query
3841
type QueryScheduleContinuous struct {
3942
IntervalSeconds int `json:"interval_seconds"`
4043
UntilDate string `json:"until_date,omitempty"`
4144
}
4245

4346
// QueryScheduleDaily ...
47+
// Deprecated: Use databricks_job resource to schedule a Query
4448
type QueryScheduleDaily struct {
4549
IntervalDays int `json:"interval_days"`
4650
TimeOfDay string `json:"time_of_day"`
4751
UntilDate string `json:"until_date,omitempty"`
4852
}
4953

5054
// QueryScheduleWeekly ...
55+
// Deprecated: Use databricks_job resource to schedule a Query
5156
type QueryScheduleWeekly struct {
5257
IntervalWeeks int `json:"interval_weeks"`
5358
DayOfWeek string `json:"day_of_week"`
@@ -508,6 +513,7 @@ func ResourceSqlQuery() *schema.Resource {
508513
s := common.StructToSchema(
509514
QueryEntity{},
510515
func(m map[string]*schema.Schema) map[string]*schema.Schema {
516+
m["schedule"].Deprecated = "Operations on `databricks_sql_query` schedules are deprecated. Please use `databricks_job` resource to schedule a `sql_task`."
511517
schedule := m["schedule"].Elem.(*schema.Resource)
512518

513519
// Make different query schedule types mutually exclusive.

sql/resource_sql_query_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func TestQueryCreateWithMultipleSchedules(t *testing.T) {
9090
}
9191
}
9292
`,
93-
}.ExpectError(t, "invalid config supplied. [schedule.#.continuous] Conflicting configuration arguments. [schedule.#.daily] Conflicting configuration arguments")
93+
}.ExpectError(t, "invalid config supplied. [schedule.#.continuous] Conflicting configuration arguments. [schedule.#.daily] Conflicting configuration arguments. [schedule] Argument is deprecated")
9494
}
9595

9696
func TestQueryCreateWithContinuousSchedule(t *testing.T) {

0 commit comments

Comments
 (0)