Skip to content

Commit 56cae98

Browse files
Merge remote-tracking branch 'origin/main' into uv-db-connect
2 parents d0f6537 + 6a90341 commit 56cae98

File tree

188 files changed

+3984
-990
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+3984
-990
lines changed

.cursorrules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

.github/custom-instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../AGENTS.md

.release_metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"timestamp": "2025-08-21 08:07:23+0000"
2+
"timestamp": "2025-08-27 11:34:20+0000"
33
}

AGENTS.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
Below are some general AI assistant coding rules.
2+
3+
# General
4+
5+
When moving code from one place to another, please don't unnecessarily change
6+
the code or omit parts.
7+
8+
# Style and comments
9+
10+
Please make sure code that you author is consistent with the codebase
11+
and concise.
12+
13+
The code should be self-documenting based on the code and function names.
14+
15+
Functions should be documented with a doc comment as follows:
16+
17+
// SomeFunc does something.
18+
func SomeFunc() {
19+
...
20+
}
21+
22+
Note how the comment starts with the name of the function and is followed by a period.
23+
24+
Avoid redundant and verbose comments. Use terse comments and only add comments if it complements, not repeats the code.
25+
26+
Focus on making implementation as small and elegant as possible. Avoid unnecessary loops and allocations. If you see an opportunity of making things simpler by dropping or relaxing some requirements, ask user about the trade-off.
27+
28+
Use modern idiomatic Golang features (version 1.24+). Specifically:
29+
- Use for-range for integer iteration where possible. Instead of for i:=0; i < X; i++ {} you must write for i := range X{}.
30+
- Use builtin min() and max() where possible (works on any type and any number of values).
31+
- Do not capture the for-range variable, since go 1.22 a new copy of the variable is created for each loop iteration.
32+
33+
# Commands
34+
35+
Use "git rm" to remove and "git mv" to rename files instead of directly modifying files on FS.
36+
37+
Do not run “go test ./..." in the root folder as that will start long running integration tests. To test the whole project run "go build && make lint test" in root directory. However, prefer running tests for specific packages instead.
38+
39+
If asked to rebase, always prefix each git command with appropriate settings so that it never launches interactive editor.
40+
GIT_EDITOR=true GIT_SEQUENCE_EDITOR=true VISUAL=true GIT_PAGER=cat git fetch origin main &&
41+
GIT_EDITOR=true GIT_SEQUENCE_EDITOR=true VISUAL=true GIT_PAGER=cat git rebase origin/main
42+
43+
# Python
44+
45+
When writing Python scripts, we bias for conciseness. We think of Python in this code base as scripts.
46+
- use Python 3.11
47+
- Do not catch exceptions to make nicer messages, only catch if you can add critical information
48+
- use pathlib.Path in almost all cases over os.path unless it makes code longer
49+
- Do not add redundant comments.
50+
- Try to keep your code small and the number of abstractions low.
51+
- After done, format you code with "ruff format -n <path>"
52+
- Use "#!/usr/bin/env python3" shebang.
53+
54+
# Tests
55+
56+
Each file like process_target_mode_test.go should have a corresponding test file
57+
like process_target_mode_test.go. If you add new functionality to a file,
58+
the test file should be extended to cover the new functionality.
59+
60+
Tests should look like the following:
61+
62+
package mutator_test
63+
64+
func TestApplySomeChangeReturnsDiagnostics(t *testing.T) {
65+
...
66+
}
67+
68+
func TestApplySomeChangeFixesThings(t *testing.T) {
69+
ctx := context.Background()
70+
b, err := ...some operation...
71+
require.NoError(t, err)
72+
...
73+
assert.Equal(t, ...)
74+
}
75+
76+
Notice that:
77+
- Tests are often in the same package but suffixed wit _test.
78+
- The test names are prefixed with Test and are named after the function or module they are testing.
79+
- 'require' and 'require.NoError' are used to check for things that would cause the rest of the test case to fail.
80+
- 'assert' is used to check for expected values where the rest of the test is not expected to fail.
81+
82+
When writing tests, please don't include an explanation in each
83+
test case in your responses. I am just interested in the tests.
84+
85+
# databricks_template_schema.json
86+
87+
A databricks_template_schema.json file is used to configure bundle templates.
88+
89+
Below is a good reference template:
90+
91+
{
92+
"welcome_message": "\nWelcome to the dbt template for Databricks Asset Bundles!\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_host: {{workspace_host}}",
93+
"properties": {
94+
"project_name": {
95+
"type": "string",
96+
"pattern": "^[A-Za-z_][A-Za-z0-9-_]+$",
97+
"pattern_match_failure_message": "Name must consist of letters, numbers, dashes, and underscores.",
98+
"default": "dbt_project",
99+
"description": "\nPlease provide a unique name for this project.\nproject_name",
100+
"order": 1
101+
},
102+
"http_path": {
103+
"type": "string",
104+
"pattern": "^/sql/.\\../warehouses/[a-z0-9]+$",
105+
"pattern_match_failure_message": "Path must be of the form /sql/1.0/warehouses/<warehouse id>",
106+
"description": "\nPlease provide the HTTP Path of the SQL warehouse you would like to use with dbt during development.\nYou can find this path by clicking on \"Connection details\" for your SQL warehouse.\nhttp_path [example: /sql/1.0/warehouses/abcdef1234567890]",
107+
"order": 2
108+
},
109+
"default_catalog": {
110+
"type": "string",
111+
"default": "{{default_catalog}}",
112+
"pattern": "^\\w*$",
113+
"pattern_match_failure_message": "Invalid catalog name.",
114+
"description": "\nPlease provide an initial catalog{{if eq (default_catalog) \"\"}} (leave blank when not using Unity Catalog){{end}}.\ndefault_catalog",
115+
"order": 3
116+
},
117+
"personal_schemas": {
118+
"type": "string",
119+
"description": "\nWould you like to use a personal schema for each user working on this project? (e.g., 'catalog.{{short_name}}')\npersonal_schemas",
120+
"enum": [
121+
"yes, use a schema based on the current user name during development",
122+
"no, use a shared schema during development"
123+
],
124+
"order": 4
125+
},
126+
"shared_schema": {
127+
"skip_prompt_if": {
128+
"properties": {
129+
"personal_schemas": {
130+
"const": "yes, use a schema based on the current user name during development"
131+
}
132+
}
133+
},
134+
"type": "string",
135+
"default": "default",
136+
"pattern": "^\\w+$",
137+
"pattern_match_failure_message": "Invalid schema name.",
138+
"description": "\nPlease provide an initial schema during development.\ndefault_schema",
139+
"order": 5
140+
}
141+
},
142+
"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"
143+
}
144+
145+
Notice that:
146+
- The welcome message has the template name.
147+
- By convention, property messages include the property name after a newline, e.g. default_catalog above has a description that says "\nPlease provide an initial catalog [...].\ndefault_catalog",
148+
- Each property defines a variable that is used for the template.
149+
- Each property has a unique 'order' value that increments by 1 with each property.
150+
- Enums use 'type: "string' and have an 'enum' field with a list of possible values.
151+
- Helpers such as {{default_catalog}} and {{short_name}} can be used within property descriptors.
152+
- Properties can be referenced in messages and descriptions using {{.property_name}}. {{.project_name}} is an example.
153+
154+
# Logging and output to the terminal
155+
156+
Use the following for logging:
157+
158+
```
159+
import "github.com/databricks/cli/libs/log"
160+
161+
log.Infof(ctx, "...")
162+
log.Debugf(ctx, "...")
163+
log.Warnf(ctx, "...")
164+
log.Errorf(ctx, "...")
165+
```
166+
167+
Note that the 'ctx' variable here is something that should be passed in as
168+
an argument by the caller. We should not use context.Background() like we do in tests.
169+
170+
Use cmdio.LogString to print to stdout:
171+
172+
```
173+
import "github.com/databricks/cli/libs/cmdio"
174+
175+
cmdio.LogString(ctx, "...")
176+
```

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Version changelog
22

3+
## Release v0.266.0
4+
5+
### Notable Changes
6+
* Breaking change: DABs now return an error when paths are incorrectly defined relative to the job or
7+
pipeline definition location instead of the configuration file location. Previously, the CLI would show a
8+
warning and fallback to resolving the path relative to the resource location. Users must update their bundle
9+
configurations to define all relative paths relative to the configuration file where the path is specified.
10+
See more details here: ([#3225](https://github.com/databricks/cli/pull/3225))
11+
* Add support volumes in Python support ([#3383])(https://github.com/databricks/cli/pull/3383))
12+
13+
### Bundles
14+
* [Breaking Change] Remove deprecated path fallback mechanism for jobs and pipelines ([#3225](https://github.com/databricks/cli/pull/3225))
15+
* Add support for Lakebase synced database tables in DABs ([#3467](https://github.com/databricks/cli/pull/3467))
16+
* Rename Delta Live Tables to Lakeflow Declarative Pipelines in the default-python template ([#3476](https://github.com/databricks/cli/pull/3476)).
17+
* Fixed bundle init not working on Standard tier ([#3496](https://github.com/databricks/cli/pull/3496))
18+
19+
320
## Release v0.265.0
421

522
### CLI

CLAUDE.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is the Databricks CLI, a command-line interface for interacting with Databricks workspaces and managing Databricks Assets Bundles (DABs). The project is written in Go and follows a modular architecture.
8+
9+
## Development Commands
10+
11+
### Building and Testing
12+
- `make build` - Build the CLI binary
13+
- `make test` - Run unit tests for all packages
14+
- `go test ./acceptance -run TestAccept/bundle/<path>/<to>/<folder> -tail -test.v` - run a single acceptance test
15+
- `make integration` - Run integration tests (requires environment variables)
16+
- `make cover` - Generate test coverage reports
17+
18+
### Code Quality
19+
- `make lint` - Run linter on changed files only (uses lintdiff.py)
20+
- `make lintfull` - Run full linter with fixes (golangci-lint)
21+
- `make ws` - Run whitespace linter
22+
- `make fmt` - Format code (Go, Python, YAML)
23+
- `make checks` - Run quick checks (tidy, whitespace, links)
24+
25+
### Specialized Commands
26+
- `make schema` - Generate bundle JSON schema
27+
- `make docs` - Generate bundle documentation
28+
- `make generate` - Generate CLI code from OpenAPI spec (requires universe repo)
29+
30+
## Architecture
31+
32+
### Core Components
33+
34+
**cmd/** - CLI command structure using Cobra framework
35+
- `cmd/cmd.go` - Main command setup and subcommand registration
36+
- `cmd/bundle/` - Bundle-related commands (deploy, validate, etc.)
37+
- `cmd/workspace/` - Workspace API commands (auto-generated)
38+
- `cmd/account/` - Account-level API commands (auto-generated)
39+
40+
**bundle/** - Core bundle functionality for Databricks Asset Bundles
41+
- `bundle/bundle.go` - Main Bundle struct and lifecycle management
42+
- `bundle/config/` - Configuration loading, validation, and schema
43+
- `bundle/deploy/` - Deployment logic (Terraform and direct modes)
44+
- `bundle/mutator/` - Configuration transformation pipeline
45+
- `bundle/phases/` - High-level deployment phases
46+
47+
**libs/** - Shared libraries and utilities
48+
- `libs/dyn/` - Dynamic configuration value manipulation
49+
- `libs/filer/` - File system abstraction (local, DBFS, workspace)
50+
- `libs/auth/` - Databricks authentication handling
51+
- `libs/sync/` - File synchronization between local and remote
52+
53+
### Key Concepts
54+
55+
**Bundles**: Configuration-driven deployments of Databricks resources (jobs, pipelines, etc.). The bundle system uses a mutator pattern where each transformation is a separate, testable component.
56+
57+
**Mutators**: Transform bundle configuration through a pipeline. Located in `bundle/config/mutator/` and `bundle/mutator/`. Each mutator implements the `Mutator` interface.
58+
59+
**Direct vs Terraform Deployment**: The CLI supports two deployment modes controlled by `DATABRICKS_CLI_DEPLOYMENT` environment variable:
60+
- `terraform` (default) - Uses Terraform for resource management
61+
- `direct` - Direct API calls without Terraform
62+
63+
## Testing
64+
65+
### Test Types
66+
- **Unit tests**: Standard Go tests alongside source files
67+
- **Integration tests**: `integration/` directory, requires live Databricks workspace
68+
- **Acceptance tests**: `acceptance/` directory, uses mock HTTP server
69+
70+
### Acceptance Tests
71+
- Located in `acceptance/` with nested directory structure
72+
- Each test directory contains `databricks.yml`, `script`, and `output.txt`
73+
- Run with `go test ./acceptance -run TestAccept/bundle/<path>/<to>/<folder> -tail -test.v`
74+
- Use `-update` flag to regenerate expected output files
75+
- When you see the test fails because it has an old output, just run it one more time with an `-update` flag instead of changing the `output.txt` directly
76+
77+
## Code Patterns
78+
79+
### Configuration
80+
- Bundle config uses `dyn.Value` for dynamic typing
81+
- Config loading supports includes, variable interpolation, and target overrides
82+
- Schema generation is automated from Go struct tags
83+
84+
## Development Tips
85+
86+
- Run `make checks fmt lint` before committing
87+
- Use `make test-update` to regenerate acceptance test outputs after changes
88+
- The CLI binary supports both `databricks` and `pipelines` command modes based on executable name
89+
- Resource definitions in `bundle/config/resources/` are auto-generated from OpenAPI specs

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ acc-showcover:
8181
build: tidy
8282
go build
8383

84+
# builds the binary in a VM environment (such as Parallels Desktop) where your files are mirrored from the host os
85+
build-vm: tidy
86+
go build -buildvcs=false
87+
8488
snapshot:
8589
go build -o .databricks/databricks
8690

NEXT_CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# NEXT CHANGELOG
22

3-
## Release v0.266.0
3+
## Release v0.267.0
44

55
### Notable Changes
6-
* Add support volumes in Python support ([#3383])(https://github.com/databricks/cli/pull/3383))
76

87
### CLI
8+
* Add rule files for coding agents working on the CLI code base ([#3245](https://github.com/databricks/cli/pull/3245))
99

1010
### Dependency updates
1111

acceptance/acceptance_test.go

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@ import (
3737
)
3838

3939
var (
40-
KeepTmp bool
41-
NoRepl bool
42-
VerboseTest bool = os.Getenv("VERBOSE_TEST") != ""
43-
Tail bool
44-
Forcerun bool
45-
LogRequests bool
46-
LogConfig bool
47-
SkipLocal bool
48-
UseVersion string
40+
KeepTmp bool
41+
NoRepl bool
42+
VerboseTest bool = os.Getenv("VERBOSE_TEST") != ""
43+
Tail bool
44+
Forcerun bool
45+
LogRequests bool
46+
LogConfig bool
47+
SkipLocal bool
48+
UseVersion string
49+
WorkspaceTmpDir bool
4950
)
5051

5152
// In order to debug CLI running under acceptance test, search for TestInprocessMode and update
@@ -67,6 +68,10 @@ func init() {
6768
flag.BoolVar(&LogConfig, "logconfig", false, "Log merged for each test case")
6869
flag.BoolVar(&SkipLocal, "skiplocal", false, "Skip tests that are enabled to run on Local")
6970
flag.StringVar(&UseVersion, "useversion", "", "Download previously released version of CLI and use it to run the tests")
71+
72+
// DABs in the workspace runs on the workspace file system. This flags does the same for acceptance tests
73+
// to simulate an identical environment.
74+
flag.BoolVar(&WorkspaceTmpDir, "workspace-tmp-dir", false, "Run tests on the workspace file system (For DBR testing).")
7075
}
7176

7277
const (
@@ -486,6 +491,15 @@ func runTest(t *testing.T,
486491
tmpDir, err = os.MkdirTemp(tempDirBase, "")
487492
require.NoError(t, err)
488493
t.Logf("Created directory: %s", tmpDir)
494+
} else if WorkspaceTmpDir {
495+
// If the test is being run on DBR, auth is already configured
496+
// by the dbr_runner notebook by reading a token from the notebook context and
497+
// setting DATABRICKS_TOKEN and DATABRICKS_HOST environment variables.
498+
_, _, tmpDir = workspaceTmpDir(t.Context(), t)
499+
500+
// Run DBR tests on the workspace file system to mimic usage from
501+
// DABs in the workspace.
502+
t.Logf("Running DBR tests on %s", tmpDir)
489503
} else {
490504
tmpDir = t.TempDir()
491505
}
@@ -552,7 +566,6 @@ func runTest(t *testing.T,
552566
// populate CLOUD_ENV_BASE
553567
envBase := getCloudEnvBase(cloudEnv)
554568
cmd.Env = append(cmd.Env, "CLOUD_ENV_BASE="+envBase)
555-
repls.Set(envBase, "[CLOUD_ENV_BASE]")
556569

557570
// Must be added PrepareReplacementsUser, otherwise conflicts with [USERNAME]
558571
testdiff.PrepareReplacementsUUID(t, &repls)
@@ -1163,7 +1176,7 @@ func getCloudEnvBase(cloudEnv string) string {
11631176
case "gcp", "gcp-ucws":
11641177
return "gcp"
11651178
case "":
1166-
return ""
1179+
return "aws"
11671180
default:
11681181
return "unknown-cloudEnv-" + cloudEnv
11691182
}

0 commit comments

Comments
 (0)