Skip to content

Commit 94ee120

Browse files
committed
Add serverless support to dbt-sql template
This mirrors the approach in default-python.
1 parent be89cdb commit 94ee120

File tree

5 files changed

+42
-14
lines changed

5 files changed

+42
-14
lines changed

acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/resources/my_dbt_sql.job.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ resources:
1515

1616
tasks:
1717
- task_key: dbt
18+
environment_key: default
1819
dbt_task:
1920
project_directory: ../
2021
# The default schema, catalog, etc. are defined in ../dbt_profiles/profiles.yml
@@ -25,17 +26,12 @@ resources:
2526
- 'dbt seed --target=${bundle.target} --vars "{ dev_schema: ${workspace.current_user.short_name} }"'
2627
- 'dbt run --target=${bundle.target} --vars "{ dev_schema: ${workspace.current_user.short_name} }"'
2728

28-
libraries:
29-
- pypi:
30-
package: dbt-databricks>=1.8.0,<2.0.0
29+
environments:
30+
- environment_key: default
3131

32-
new_cluster:
33-
spark_version: 15.4.x-scala2.12
34-
node_type_id: [NODE_TYPE_ID]
35-
data_security_mode: SINGLE_USER
36-
num_workers: 0
37-
spark_conf:
38-
spark.master: "local[*, 4]"
39-
spark.databricks.cluster.profile: singleNode
40-
custom_tags:
41-
ResourceClass: SingleNode
32+
# Full documentation of this spec can be found at:
33+
# https://docs.databricks.com/api/workspace/jobs/create#environments-spec
34+
spec:
35+
environment_version: "2"
36+
dependencies:
37+
- dbt-databricks>=1.8.0,<2.0.0

acceptance/bundle/templates/telemetry/dbt-sql/out.requests.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"uploadTime": [UNIX_TIME_MILLIS],
2929
"items": [],
3030
"protoLogs": [
31-
"{\"frontend_log_event_id\":\"[UUID]\",\"entry\":{\"databricks_cli_log\":{\"execution_context\":{\"cmd_exec_id\":\"[CMD-EXEC-ID]\",\"version\":\"[DEV_VERSION]\",\"command\":\"bundle_init\",\"operating_system\":\"[OS]\",\"execution_time_ms\":\"SMALL_INT\",\"exit_code\":0},\"bundle_init_event\":{\"bundle_uuid\":\"[BUNDLE-UUID]\",\"template_name\":\"dbt-sql\",\"template_enum_args\":[{\"key\":\"personal_schemas\",\"value\":\"yes, use a schema based on the current user name during development\"}]}}}}"
31+
"{\"frontend_log_event_id\":\"[UUID]\",\"entry\":{\"databricks_cli_log\":{\"execution_context\":{\"cmd_exec_id\":\"[CMD-EXEC-ID]\",\"version\":\"[DEV_VERSION]\",\"command\":\"bundle_init\",\"operating_system\":\"[OS]\",\"execution_time_ms\":\"SMALL_INT\",\"exit_code\":0},\"bundle_init_event\":{\"bundle_uuid\":\"[BUNDLE-UUID]\",\"template_name\":\"dbt-sql\",\"template_enum_args\":[{\"key\":\"personal_schemas\",\"value\":\"yes, use a schema based on the current user name during development\"},{\"key\":\"serverless\",\"value\":\"yes\"}]}}}}"
3232
]
3333
}
3434
}

acceptance/bundle/templates/telemetry/dbt-sql/output.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Refer to the README.md file for full "getting started" guide and production setu
2929
{
3030
"key": "personal_schemas",
3131
"value": "yes, use a schema based on the current user name during development"
32+
},
33+
{
34+
"key": "serverless",
35+
"value": "yes"
3236
}
3337
]
3438
}

libs/template/templates/dbt-sql/databricks_template_schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@
4747
"pattern_match_failure_message": "Invalid schema name.",
4848
"description": "\nPlease provide an initial schema during development.\ndefault_schema",
4949
"order": 5
50+
},
51+
"serverless": {
52+
"type": "string",
53+
"default": "yes",
54+
"enum": ["yes", "no"],
55+
"description": "Use serverless compute",
56+
"order": 6
5057
}
5158
},
5259
"success_message": "\n📊 Your new project has been created in the '{{.project_name}}' directory!\nIf you already have dbt installed, just type 'cd {{.project_name}}; dbt init' to get started.\nRefer to the README.md file for full \"getting started\" guide and production setup instructions.\n"

libs/template/templates/dbt-sql/template/{{.project_name}}/resources/{{.project_name}}.job.yml.tmpl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{{$with_serverless := (eq .serverless "yes") -}}
2+
13
resources:
24
jobs:
35
{{.project_name}}_job:
@@ -15,6 +17,9 @@ resources:
1517

1618
tasks:
1719
- task_key: dbt
20+
{{- if $with_serverless }}
21+
environment_key: default
22+
{{- end }}
1823
dbt_task:
1924
project_directory: ../
2025
# The default schema, catalog, etc. are defined in ../dbt_profiles/profiles.yml
@@ -32,6 +37,8 @@ resources:
3237
- 'dbt run --target=${bundle.target}'
3338
{{- end}}
3439

40+
{{- if not $with_serverless }}
41+
3542
libraries:
3643
- pypi:
3744
package: dbt-databricks>=1.8.0,<2.0.0
@@ -46,3 +53,17 @@ resources:
4653
spark.databricks.cluster.profile: singleNode
4754
custom_tags:
4855
ResourceClass: SingleNode
56+
{{- end }}
57+
58+
{{- if $with_serverless }}
59+
60+
environments:
61+
- environment_key: default
62+
63+
# Full documentation of this spec can be found at:
64+
# https://docs.databricks.com/api/workspace/jobs/create#environments-spec
65+
spec:
66+
environment_version: "2"
67+
dependencies:
68+
- dbt-databricks>=1.8.0,<2.0.0
69+
{{- end }}

0 commit comments

Comments
 (0)