Skip to content

Commit 9451a90

Browse files
authored
Added File Arrival trigger to databricks_job resource (#2142)
1 parent 9671881 commit 9451a90

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

docs/resources/job.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ The following arguments are required:
107107

108108
* `pause_status` - (Optional) Indicate whether this continuous job is paused or not. Either `PAUSED` or `UNPAUSED`. When the `pause_status` field is omitted in the block, the server will default to using `UNPAUSED` as a value for `pause_status`.
109109

110+
### trigger Configuration Block
111+
112+
* `pause_status` - (Optional) Indicate whether this trigger is paused or not. Either `PAUSED` or `UNPAUSED`. When the `pause_status` field is omitted in the block, the server will default to using `UNPAUSED` as a value for `pause_status`.
113+
* `file_arrival` - (Required) configuration block to define a trigger for [File Arrival events](https://learn.microsoft.com/en-us/azure/databricks/workflows/jobs/file-arrival-triggers) consisting of following attributes:
114+
* `url` - (Required) string with URL under the Unity Catalog external location that will be monitored for new files. Please note that have a trailing slash character (`/`).
115+
* `min_time_between_trigger_seconds` - (Optional) If set, the trigger starts a run only after the specified amount of time passed since the last time the trigger fired. The minimum allowed value is 60 seconds.
116+
* `wait_after_last_change_seconds` - (Optional) If set, the trigger starts a run only after no file activity has occurred for the specified amount of time. This makes it possible to wait for a batch of incoming files to arrive before triggering a run. The minimum allowed value is 60 seconds.
117+
110118
### git_source Configuration Block
111119

112120
This block is used to specify Git repository information & branch/tag/commit that will be used to pull source code from to execute a job. Supported options are:

jobs/resource_job.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,17 @@ type ContinuousConf struct {
188188
type Queue struct {
189189
}
190190

191+
type FileArrival struct {
192+
URL string `json:"url"`
193+
MinTimeBetweenTriggersSeconds int32 `json:"min_time_between_trigger_seconds,omitempty"`
194+
WaitAfterLastChangeSeconds int32 `json:"wait_after_last_change_seconds,omitempty"`
195+
}
196+
197+
type Trigger struct {
198+
FileArrival *FileArrival `json:"file_arrival"`
199+
PauseStatus string `json:"pause_status,omitempty" tf:"computed"`
200+
}
201+
191202
// JobSettings contains the information for configuring a job on databricks
192203
type JobSettings struct {
193204
Name string `json:"name,omitempty" tf:"default:Untitled"`
@@ -221,6 +232,7 @@ type JobSettings struct {
221232

222233
Schedule *CronSchedule `json:"schedule,omitempty"`
223234
Continuous *ContinuousConf `json:"continuous,omitempty"`
235+
Trigger *Trigger `json:"trigger,omitempty"`
224236
MaxConcurrentRuns int32 `json:"max_concurrent_runs,omitempty"`
225237
EmailNotifications *EmailNotifications `json:"email_notifications,omitempty" tf:"suppress_diff"`
226238
WebhookNotifications *WebhookNotifications `json:"webhook_notifications,omitempty" tf:"suppress_diff"`
@@ -582,8 +594,9 @@ var jobSchema = common.StructToSchema(JobSettings{},
582594
Default: false,
583595
Type: schema.TypeBool,
584596
}
585-
s["schedule"].ConflictsWith = []string{"continuous"}
586-
s["continuous"].ConflictsWith = []string{"schedule"}
597+
s["schedule"].ConflictsWith = []string{"continuous", "trigger"}
598+
s["continuous"].ConflictsWith = []string{"schedule", "trigger"}
599+
s["trigger"].ConflictsWith = []string{"schedule", "continuous"}
587600
return s
588601
})
589602

0 commit comments

Comments
 (0)