Skip to content

fix: convert workflow job spec to SDK dataclasses before jobs.create() (#1338)#1364

Merged
sd-db merged 8 commits intodatabricks:mainfrom
aarushisingh04:fix/workflow-job-dict-as-dict-error
Apr 14, 2026
Merged

fix: convert workflow job spec to SDK dataclasses before jobs.create() (#1338)#1364
sd-db merged 8 commits intodatabricks:mainfrom
aarushisingh04:fix/workflow-job-dict-as-dict-error

Conversation

@aarushisingh04
Copy link
Copy Markdown
Contributor

resolves #1360

description

WorkflowJobApi.create() passes plain dicts to workspace_client.jobs.create(**converted_job_spec). the databricks sdk's jobs.create() iterates tasks calling v.as_dict() on each (confirmed via JobsAPI.create source inspection). plain dicts have no .as_dict() which caused the 'dict' object has no attribute 'as_dict' error.

  1. the fix uses JobSettings.from_dict() + .as_shallow_dict() to convert the plain dict job spec into proper sdk dataclasses before calling jobs.create().
  2. as_shallow_dict() is the correct choice here : it unpacks top-level fields as kwargs (matching the jobs.create() signature) while keeping nested values as typed Task / NotebookTask / etc. dataclasses that satisfy .as_dict().
  3. this is the same pattern already used by update_job_settings() in the same class.

changes:

  • dbt/adapters/databricks/api_client.py - WorkflowJobApi.create() now deserializes the dict via JobSettings.from_dict() and passes .as_shallow_dict() to the sdk. inline comment documents the sdk internals that make this the correct choice.
  • tests/unit/api_client/test_workflow_job_api.py - tests strengthened to assert isinstance(task, Task), call .as_dict() on each task and verify output (directly proving the original AttributeError cannot recur), and add a new test_create__invalid_job_spec_raises covering the JobSettings.from_dict() error path.

checklist

  • i have run this code in development and it appears to resolve the stated issue
  • this pr includes tests, or tests are not required/relevant for this pr
  • i have updated the CHANGELOG.md and added information about my change to the "dbt-databricks next" section.

Signed-off-by: aarushisingh04 <aarushi07.singh@gmail.com>
Signed-off-by: aarushisingh04 <aarushi07.singh@gmail.com>
@aarushisingh04 aarushisingh04 changed the title fix: convert workflow job spec to SDK dataclasses before jobs.create() fix: convert workflow job spec to SDK dataclasses before jobs.create() (#1338) Mar 26, 2026
@tejassp-db tejassp-db requested a review from jprakash-db as a code owner April 7, 2026 07:15
Comment thread dbt/adapters/databricks/api_client.py Outdated
Comment thread tests/unit/api_client/test_workflow_job_api.py
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 14, 2026

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  dbt/adapters/databricks
  api_client.py
Project Total  

This report was generated by python-coverage-comment-action

sd-db
sd-db previously approved these changes Apr 14, 2026
Copy link
Copy Markdown
Collaborator

@sd-db sd-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, thanks for the PR !

@sd-db sd-db merged commit 5927a32 into databricks:main Apr 14, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dbt python model wokflow_job submission method not working in dbt-databricks v0.11.x

3 participants