Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d7fb717
Reorganize template structure
lennartkats-db Sep 27, 2025
b558a96
Support templates with a different template_dir
lennartkats-db Sep 27, 2025
9292994
Reorganize template
lennartkats-db Sep 27, 2025
1eed475
Fix readers
lennartkats-db Sep 27, 2025
f0a6ca1
Update templates
lennartkats-db Sep 27, 2025
bf6827f
Refine template
lennartkats-db Sep 28, 2025
e1cf153
Remove tests for now
lennartkats-db Sep 29, 2025
7bb5a1e
Add changelog
lennartkats-db Sep 29, 2025
705b7cc
Minor tweaks
lennartkats-db Sep 29, 2025
1f17170
Refine comment
lennartkats-db Sep 29, 2025
3045982
Merge branch 'main' into add-default-template
lennartkats-db Sep 30, 2025
039843d
Merge remote-tracking branch 'origin/main' into add-default-template
lennartkats-db Sep 30, 2025
25bd303
Fix root_path
lennartkats-db Sep 30, 2025
3b2f7c1
Merge remote-tracking branch 'origin' into add-default-template
lennartkats-db Sep 30, 2025
e36bd95
Merge remote-tracking branch 'origin/add-default-template' into add-d…
lennartkats-db Sep 30, 2025
df857eb
Merge branch 'main' into add-default-template
lennartkats-db Oct 1, 2025
f71487f
Document limitation
lennartkats-db Oct 3, 2025
c62740a
Consistency tweaks
lennartkats-db Oct 5, 2025
a37d66f
Update
lennartkats-db Oct 6, 2025
4661002
Change environment_version back to 2 in default template
lennartkats-db Oct 7, 2025
b16d984
Merge main into add-default-template
lennartkats-db Oct 7, 2025
109f0fd
[DECO-25663] Add template_dir setting for bundle templates
lennartkats-db Oct 7, 2025
5a842cb
Reorganize template structure
lennartkats-db Sep 27, 2025
b6dd22d
Support templates with a different template_dir
lennartkats-db Sep 27, 2025
80cbe1f
Reorganize template
lennartkats-db Sep 27, 2025
b7f0717
Fix readers
lennartkats-db Sep 27, 2025
6b72963
Update templates
lennartkats-db Sep 27, 2025
90b5dd4
Refine template
lennartkats-db Sep 28, 2025
3717102
Remove tests for now
lennartkats-db Sep 29, 2025
c1f7ce9
Add changelog
lennartkats-db Sep 29, 2025
8470eda
Minor tweaks
lennartkats-db Sep 29, 2025
a275e8a
Refine comment
lennartkats-db Sep 29, 2025
8131fc1
Fix root_path
lennartkats-db Sep 30, 2025
bf9d641
Document limitation
lennartkats-db Oct 3, 2025
0eb01fc
Consistency tweaks
lennartkats-db Oct 5, 2025
ceb1fb2
Update
lennartkats-db Oct 6, 2025
48e58bd
Change environment_version back to 2 in default template
lennartkats-db Oct 7, 2025
80ee7ca
[DECO-25663] Add template_dir setting for bundle templates
lennartkats-db Oct 7, 2025
6b61ad1
Merge remote-tracking branch 'origin/main' into add-default-template
lennartkats-db Oct 13, 2025
9a13f5e
Merge remote-tracking branch 'origin/main' into add-default-template
lennartkats-db Oct 13, 2025
5d261bc
Fix NEXT_CHANGELOG.md
lennartkats-db Oct 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
### Dependency updates

### Bundles
* Updated the internal lakeflow-pipelines template to use an "src" layout ([#3671](https://github.com/databricks/cli/pull/3671)).
* Added support for a "template_dir" option in the databricks_template_schema.json format. ([#3671](https://github.com/databricks/cli/pull/3671)).

### API Changes
* Added `databricks account account-groups-v2` command group.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[project]
name = "my_lakeflow_pipelines"
version = "0.0.1"
authors = [{ name = "[USERNAME]" }]
requires-python = ">=3.10,<=3.13"
dependencies = [
# Any dependencies for jobs and pipelines in this project can be added here
# See also https://docs.databricks.com/dev-tools/bundles/library-dependencies
]

[dependency-groups]
dev = [
"pytest",
"databricks-dlt",
"databricks-connect>=15.4,<15.5",
]

[project.scripts]
main = "my_lakeflow_pipelines.main:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.black]
line-length = 125
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The main pipeline for my_lakeflow_pipelines

resources:
pipelines:
lakeflow_pipelines_etl:
name: lakeflow_pipelines_etl
## Catalog is required for serverless compute
catalog: ${var.catalog}
schema: ${var.schema}
serverless: true
root_path: "."

libraries:
- glob:
include: ../src/lakeflow_pipelines_etl/transformations/**

environment:
dependencies:
# We include every dependency defined by pyproject.toml by defining an editable environment
# that points to the folder where pyproject.toml is deployed.
- --editable ${workspace.file_path}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# The job that triggers lakeflow_pipelines_etl.
# A sample job for my_lakeflow_pipelines.

resources:
jobs:
lakeflow_pipelines_job:
name: lakeflow_pipelines_job
sample_job:
name: sample_job

trigger:
# Run this job every day, exactly one day from the last run; see https://docs.databricks.com/api/workspace/jobs/create#trigger
Expand All @@ -15,7 +15,18 @@ resources:
# on_failure:
# - your_email@example.com

parameters:
- name: catalog
default: ${var.catalog}
- name: schema
default: ${var.schema}

tasks:
- task_key: refresh_pipeline
pipeline_task:
pipeline_id: ${resources.pipelines.lakeflow_pipelines_etl.id}

environments:
- environment_key: default
spec:
client: "2"
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import argparse
from databricks.sdk.runtime import spark
from my_lakeflow_pipelines import taxis


def main():
# Process command-line arguments
parser = argparse.ArgumentParser(description="Databricks job with catalog and schema parameters")
parser.add_argument("--catalog", required=True)
parser.add_argument("--schema", required=True)
args = parser.parse_args()

# Set the default catalog and schema
spark.sql(f"USE CATALOG {args.catalog}")
spark.sql(f"USE SCHEMA {args.schema}")

# Example: just find all taxis from a sample catalog
taxis.find_all_taxis().show(5)


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[project]
name = "my_lakeflow_pipelines"
version = "0.0.1"
authors = [{ name = "[USERNAME]" }]
requires-python = ">=3.10,<=3.13"
dependencies = [
# Any dependencies for jobs and pipelines in this project can be added here
# See also https://docs.databricks.com/dev-tools/bundles/library-dependencies
]

[dependency-groups]
dev = [
"pytest",
"databricks-dlt",
"databricks-connect>=15.4,<15.5",
]

[project.scripts]
main = "my_lakeflow_pipelines.main:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.black]
line-length = 125

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The main pipeline for my_lakeflow_pipelines

resources:
pipelines:
lakeflow_pipelines_etl:
name: lakeflow_pipelines_etl
## Catalog is required for serverless compute
catalog: ${var.catalog}
schema: ${var.schema}
serverless: true
root_path: "."

libraries:
- glob:
include: ../src/lakeflow_pipelines_etl/transformations/**

environment:
dependencies:
# We include every dependency defined by pyproject.toml by defining an editable environment
# that points to the folder where pyproject.toml is deployed.
- --editable ${workspace.file_path}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# The job that triggers lakeflow_pipelines_etl.
# A sample job for my_lakeflow_pipelines.

resources:
jobs:
lakeflow_pipelines_job:
name: lakeflow_pipelines_job
sample_job:
name: sample_job

trigger:
# Run this job every day, exactly one day from the last run; see https://docs.databricks.com/api/workspace/jobs/create#trigger
Expand All @@ -15,7 +15,18 @@ resources:
# on_failure:
# - your_email@example.com

parameters:
- name: catalog
default: ${var.catalog}
- name: schema
default: ${var.schema}

tasks:
- task_key: refresh_pipeline
pipeline_task:
pipeline_id: ${resources.pipelines.lakeflow_pipelines_etl.id}

environments:
- environment_key: default
spec:
client: "2"
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import argparse
from databricks.sdk.runtime import spark
from my_lakeflow_pipelines import taxis


def main():
# Process command-line arguments
parser = argparse.ArgumentParser(description="Databricks job with catalog and schema parameters")
parser.add_argument("--catalog", required=True)
parser.add_argument("--schema", required=True)
args = parser.parse_args()

# Set the default catalog and schema
spark.sql(f"USE CATALOG {args.catalog}")
spark.sql(f"USE SCHEMA {args.schema}")

# Example: just find all taxis from a sample catalog
taxis.find_all_taxis().show(5)


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from databricks.sdk.runtime import spark
from pyspark.sql import DataFrame


def find_all_taxis() -> DataFrame:
"""Find all taxi data."""
return spark.read.table("samples.nyctaxi.trips")
6 changes: 6 additions & 0 deletions libs/jsonschema/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ type Extension struct {
// compatible with the current CLI version.
Version *int `json:"version,omitempty"`

// TemplateDir specifies the directory containing the template files to use.
// If not specified, the template files are expected to be in the same directory
// as the schema file. This allows schema files to reference template files
// from a different directory (e.g., "../default").
TemplateDir string `json:"template_dir,omitempty"`

// Preview indicates launch stage (e.g. PREVIEW).
//
// This field indicates whether the associated field is part of a private preview feature.
Expand Down
2 changes: 1 addition & 1 deletion libs/template/builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestBuiltin(t *testing.T) {
// Verify the filesystems work for each template
_, err = fs.Stat(templates["dbt-sql"].FS, `template/{{.project_name}}/dbt_project.yml.tmpl`)
assert.NoError(t, err)
_, err = fs.Stat(templates["default-python"].FS, `template/{{.project_name}}/tests/main_test.py.tmpl`)
_, err = fs.Stat(templates["default"].FS, `template/{{.project_name}}/tests/sample_taxis_test.py.tmpl`)
assert.NoError(t, err)
_, err = fs.Stat(templates["default-sql"].FS, `template/{{.project_name}}/src/orders_daily.sql.tmpl`)
assert.NoError(t, err)
Expand Down
4 changes: 4 additions & 0 deletions libs/template/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func newConfig(ctx context.Context, templateFS fs.FS, schemaPath string) (*confi
if err != nil {
return nil, err
}
return newConfigFromSchema(ctx, schema)
}

func newConfigFromSchema(ctx context.Context, schema *jsonschema.Schema) (*config, error) {
if err := validateSchema(schema); err != nil {
return nil, err
}
Expand Down
Loading
Loading