Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bundle/config/mutator/resourcemutator/apply_presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
// Quality monitors presets: Schedule
if t.TriggerPauseStatus == config.Paused {
for _, q := range r.QualityMonitors {
if q == nil {
continue
}
// Remove all schedules from monitors, since they don't support pausing/unpausing.
// Quality monitors might support the "pause" property in the future, so at the
// CLI level we do respect that property if it is set to "unpaused."
Expand Down
40 changes: 40 additions & 0 deletions bundle/config/mutator/resourcemutator/apply_presets_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package resourcemutator

import (
"testing"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/bundle/config/resources"
"github.com/databricks/databricks-sdk-go/service/catalog"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestApplyPresetsSkipsNilQualityMonitors(t *testing.T) {
b := &bundle.Bundle{
Config: config.Root{
Presets: config.Presets{
TriggerPauseStatus: config.Paused,
},
Resources: config.Resources{
QualityMonitors: map[string]*resources.QualityMonitor{
// Python-generated configs can contain null resource entries that
// bypass AllResourcesHaveValues, so ApplyPresets must skip them.
"nil_monitor": nil,
"monitor": {
TableName: "monitor",
CreateMonitor: catalog.CreateMonitor{
OutputSchemaName: "catalog.schema",
Schedule: &catalog.MonitorCronSchedule{},
},
},
},
},
},
}

diags := bundle.Apply(t.Context(), b, ApplyPresets())
require.NoError(t, diags.Error())
assert.Nil(t, b.Config.Resources.QualityMonitors["monitor"].Schedule)
}
Loading