Skip to content

Commit

Permalink
[Fix] fix issue cased by setting pause_status in update monitor (#4242)
Browse files Browse the repository at this point in the history
## Changes
<!-- Summary of your changes that are easy to understand -->

## Tests
<!-- 
How is this tested? Please see the checklist below and also describe any
other relevant tests
-->

- [x] `make test` run locally
- [ ] relevant change in `docs/` folder
- [ ] covered with integration tests in `internal/acceptance`
- [ ] relevant acceptance tests are passing
- [ ] using Go SDK

---------

Co-authored-by: Alex Ott <alexott@gmail.com>
  • Loading branch information
xinyijiang-db and alexott authored Nov 19, 2024
1 parent 7afc418 commit c50a20d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
3 changes: 3 additions & 0 deletions catalog/resource_quality_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ func ResourceQualityMonitor() common.Resource {
var update catalog.UpdateMonitor
common.DataToStructPointer(d, monitorSchema, &update)
update.TableName = d.Get("table_name").(string)
if update.Schedule != nil {
update.Schedule.PauseStatus = ""
}
_, err = w.QualityMonitors.Update(ctx, update)
if err != nil {
return err
Expand Down
35 changes: 18 additions & 17 deletions internal/acceptance/quality_monitor_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package acceptance

import (
"fmt"
"os"
"testing"
)
Expand Down Expand Up @@ -64,6 +65,10 @@ func TestUcAccQualityMonitor(t *testing.T) {
model_id_col = "model_id"
problem_type = "PROBLEM_TYPE_REGRESSION"
}
schedule {
quartz_cron_expression = "0 0 12 * * ?"
timezone_id = "PST"
}
}
resource "databricks_sql_table" "myTimeseries" {
Expand All @@ -87,6 +92,10 @@ func TestUcAccQualityMonitor(t *testing.T) {
granularities = ["1 day"]
timestamp_col = "timestamp"
}
schedule {
quartz_cron_expression = "0 0 12 * * ?"
timezone_id = "PST"
}
}
resource "databricks_sql_table" "mySnapshot" {
Expand Down Expand Up @@ -117,8 +126,7 @@ func TestUcAccUpdateQualityMonitor(t *testing.T) {
if os.Getenv("GOOGLE_CREDENTIALS") != "" {
t.Skipf("databricks_quality_monitor resource is not available on GCP")
}
UnityWorkspaceLevel(t, Step{
Template: commonPartQualityMonitoring + `
qmTemplate := `
resource "databricks_quality_monitor" "testMonitorInference" {
table_name = databricks_sql_table.myInferenceTable.id
assets_dir = "/Shared/provider-test/databricks_quality_monitoring/${databricks_sql_table.myInferenceTable.name}"
Expand All @@ -130,22 +138,15 @@ func TestUcAccUpdateQualityMonitor(t *testing.T) {
model_id_col = "model_id"
problem_type = "PROBLEM_TYPE_REGRESSION"
}
schedule {
quartz_cron_expression = "0 0 %s * * ?"
timezone_id = "PST"
}
}
`,
`
UnityWorkspaceLevel(t, Step{
Template: commonPartQualityMonitoring + fmt.Sprintf(qmTemplate, "12"),
}, Step{
Template: commonPartQualityMonitoring + `
resource "databricks_quality_monitor" "testMonitorInference" {
table_name = databricks_sql_table.myInferenceTable.id
assets_dir = "/Shared/provider-test/databricks_quality_monitoring/${databricks_sql_table.myInferenceTable.name}"
output_schema_name = databricks_schema.things.id
inference_log {
granularities = ["1 hour"]
timestamp_col = "timestamp"
prediction_col = "prediction"
model_id_col = "model_id"
problem_type = "PROBLEM_TYPE_REGRESSION"
}
}
`,
Template: commonPartQualityMonitoring + fmt.Sprintf(qmTemplate, "11"),
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ func (r *QualityMonitorResource) Update(ctx context.Context, req resource.Update
if resp.Diagnostics.HasError() {
return
}
if updateMonitorGoSDK.Schedule != nil {
updateMonitorGoSDK.Schedule.PauseStatus = ""
}
monitor, err := w.QualityMonitors.Update(ctx, updateMonitorGoSDK)
if err != nil {
resp.Diagnostics.AddError("failed to update monitor", err.Error())
Expand Down

0 comments on commit c50a20d

Please sign in to comment.