Repository navigation
Add environments and trigger named parameters to Databricks operators - #72505
Conversation
Serverless task dependencies and event-driven triggers are how Databricks jobs are written today, but reaching either from Airflow meant hand-building the raw payload in ``json`` — the two fields were the only mainstream top-level ones without a named parameter, so the operator signature no longer showed what a job can be given.
|
@eladkal could you take a look when you have a moment, or point it at whoever is better placed? It adds Drafted-by: Claude Code (Opus 5); reviewed by @moomindani before posting |
|
@eladkal could you take a look at this one? It is the only one left from the 09-06 batch — the other three merged on 09-09. It adds the Drafted-by: Claude Code (Opus 5); reviewed by @moomindani before posting |
api/2.2/jobs/createandapi/2.2/jobs/runs/submitboth take a top-levelenvironmentsfield, andcreatealso takestrigger. Neither had a named parameter on the operators, so a job that uses serverless task dependencies or an event-driven trigger had to be hand-written intojson— and the operator signature, which the docs describe as having "exactly one named parameter for each top level parameter", no longer showed that those fields exist at all.DatabricksCreateJobsOperator: addsenvironmentsandtriggerDatabricksSubmitRunOperator: addsenvironments(runs/submithas notrigger; a trigger is job-level)Both are in
template_fields, so a rendered value can be built from the Dag context — e.g. afile_arrivalURL or a pinned dependency version per run — and both follow the existing merge rule, overriding the same key injson.This is reach the payload already had, so the change is discoverability and typing rather than new capability. I checked that first:
normalise_json_contentstringifies ints, and the API acceptstrigger.periodic.intervalas either an int or a string and returns it as an int, sojson=was never actually blocked here.Verified against a live workspace, through the operators and the real hook, reading the result back with the CLI rather than the code under test:
jobs/createwithenvironments+trigger— accepted, andjobs/getreturns both byte for byte, includingspec.environment_versionand the int-valuedmin_time_between_triggers_seconds/periodic.interval. Checked withtrigger.file_arrivalandtrigger.periodic.runs/submitwithenvironments— accepted. Submitting the same task withoutenvironmentsis rejected withJob environment 'serverless_default' used by task probe is not defined in field 'environments', which is what shows the field is genuinely consumed by the API and not quietly dropped.file_arrival.urlmust end in/and must resolve to a UC volume — a raws3://URL that overlaps an existing volume or table is refused — so the unit-test fixtures use a/Volumes/...URL.All six new unit tests fail without the change. Removing only the two
template_fieldsentries, keeping the named parameters, fails exactly the two templating tests and leaves the four merge tests green, so the tests separate the two halves of the change. The provider's unit suite is 929 passed / 12 skipped, and mypy is clean on the changed file.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5) following the guidelines