[WIP] Add session mode for dbt-databricks adapter for 1.11.x version #1310
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Execute DBT in session mode (e.g. on a job cluster)
This is a plan created with Claude to implement session mode for
dbt-databricksadapter.It should allow:
dbt-sparkAsset Bundle DBT task
The native
dbt_taskon Databricks does not provide a Spark session. It is also not possible to retrieve it.It is about Databricks to allow retrieving a Spark Session within
dbt_taskin order to keep the Asset Bundle deployment as simple as it is right now.The workaround to still use the session mode is to define the dbt tasks as python scripts or notebooks.
This approach could be added as a template via Databricks Asset Bundles.
In our job example, this looks as below:
With the job cluster selected, it now executes as expected:

dbt depsanddbt seeddbt runwith optional--full-refreshand a passed--select(e.g. state, specific model, or empty for full selection)dbt testExample of dbt cli for run execution
Pros/Cons
Pros:
profiles.ymlandrequirements.txtin the asset bundles repositoryprofiles.ymlneed to be uploaded manually to an available path on e.g. Databricks; changes require to update and reupload the file;Cons:
dbt_taskprovided by Databricks -> could be adjusted by DatabricksDescription
Checklist
CHANGELOG.mdand added information about my change to the "dbt-databricks next" section.