Skip to content

Commit 7c15eb2

Browse files
Add experimental.skip_name_prefix_for_schema field (#2992)
## Why In the long term, we plan to make this the default behaviour and not apply the prefix on UC schemas and registered models. Meanwhile, this field provides users with a short-term flag to opt-into this behaviour. Resolves: #1779 ## Tests Acceptance test.
1 parent 48fdfb2 commit 7c15eb2

7 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
variables:
2+
skip:
3+
default: false
4+
5+
resources:
6+
schemas:
7+
foo:
8+
name: my_schema
9+
catalog_name: my_catalog
10+
11+
experimental:
12+
skip_name_prefix_for_schema: ${var.skip}
13+
14+
targets:
15+
one:
16+
default: true
17+
mode: development
18+
19+
two:
20+
presets:
21+
name_prefix: "[custom_prefix]"
22+
23+
three:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
=== experimental.skip_name_prefix_for_schema is false
3+
>>> [CLI] bundle validate -o json
4+
"dev_[USERNAME]_my_schema"
5+
6+
>>> [CLI] bundle validate -o json -t two
7+
"custom_prefix_my_schema"
8+
9+
>>> [CLI] bundle validate -o json -t three
10+
"my_schema"
11+
12+
=== experimental.skip_name_prefix_for_schema is true
13+
>>> [CLI] bundle validate -o json -t one
14+
"my_schema"
15+
16+
>>> [CLI] bundle validate -o json -t two
17+
"my_schema"
18+
19+
>>> [CLI] bundle validate -o json -t three
20+
"my_schema"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
title "experimental.skip_name_prefix_for_schema is false"
2+
3+
trace $CLI bundle validate -o json | jq .resources.schemas.foo.name
4+
5+
trace $CLI bundle validate -o json -t two | jq .resources.schemas.foo.name
6+
7+
trace $CLI bundle validate -o json -t three | jq .resources.schemas.foo.name
8+
9+
title "experimental.skip_name_prefix_for_schema is true"
10+
11+
export BUNDLE_VAR_skip=true
12+
13+
trace $CLI bundle validate -o json -t one | jq .resources.schemas.foo.name
14+
15+
trace $CLI bundle validate -o json -t two | jq .resources.schemas.foo.name
16+
17+
trace $CLI bundle validate -o json -t three | jq .resources.schemas.foo.name

bundle/config/experimental.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ type Experimental struct {
3737
// containing build artifacts such as wheels. When set to true, the .internal folder
3838
// and its contents will be preserved after bundle operations complete.
3939
SkipArtifactCleanup bool `json:"skip_artifact_cleanup,omitempty"`
40+
41+
// SkipNamePrefixForSchema skips adding the `presets.name_prefix` prefix
42+
// to UC schemas defined in the bundle. Currently this is a opt-in behavior
43+
// because turning it on by default will cause schema recreates and lose
44+
// customer data.
45+
// Eventually this can be made the default once we have native CRUD in DABs
46+
// at which point we can deprecate or remove this field all together.
47+
SkipNamePrefixForSchema bool `json:"skip_name_prefix_for_schema,omitempty"`
4048
}
4149

4250
type Python struct {

bundle/config/mutator/resourcemutator/apply_presets.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
185185

186186
// Schemas: Prefix
187187
for _, s := range r.Schemas {
188+
if b.Config.Experimental != nil && b.Config.Experimental.SkipNamePrefixForSchema {
189+
break
190+
}
191+
188192
if s == nil {
189193
continue
190194
}

bundle/internal/schema/annotations.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ github.com/databricks/cli/bundle/config.Experimental:
7878
"skip_artifact_cleanup":
7979
"description": |-
8080
Determines whether to skip cleaning up the .internal folder
81+
"skip_name_prefix_for_schema":
82+
"description": |-
83+
Skip adding the prefix that is either set in `presets.name_prefix` or computed when `mode: development`
84+
is set, to the names of UC schemas defined in the bundle.
8185
"use_legacy_run_as":
8286
"description": |-
8387
Whether to use the legacy run_as behavior.

bundle/schema/jsonschema.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)