address comments

This commit is contained in:
Shreyas Goenka 2025-01-07 15:33:29 +05:30
parent f7d926e428
commit fc8b5e7576
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
2 changed files with 12 additions and 8 deletions

View File

@ -9,7 +9,7 @@ import (
"github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/diag"
) )
type resolveSchemeDependency struct{} type captureSchemaDependency struct{}
// If a user defines a UC schema in the bundle, they can refer to it in DLT pipelines // If a user defines a UC schema in the bundle, they can refer to it in DLT pipelines
// or UC Volumes using the `${resources.schemas.<schema_key>.name}` syntax. Using this // or UC Volumes using the `${resources.schemas.<schema_key>.name}` syntax. Using this
@ -19,20 +19,20 @@ type resolveSchemeDependency struct{}
// This mutator translates any implicit schema references in DLT pipelines or UC Volumes // This mutator translates any implicit schema references in DLT pipelines or UC Volumes
// to the explicit syntax. // to the explicit syntax.
func ResolveSchemaDependency() bundle.Mutator { func ResolveSchemaDependency() bundle.Mutator {
return &resolveSchemeDependency{} return &captureSchemaDependency{}
} }
func (m *resolveSchemeDependency) Name() string { func (m *captureSchemaDependency) Name() string {
return "ResolveSchemaDependency" return "CaptureSchemaDependency"
} }
func findSchema(b *bundle.Bundle, catalogName, name string) (string, *resources.Schema) { func findSchema(b *bundle.Bundle, catalogName, schemaName string) (string, *resources.Schema) {
if catalogName == "" || name == "" { if catalogName == "" || schemaName == "" {
return "", nil return "", nil
} }
for k, s := range b.Config.Resources.Schemas { for k, s := range b.Config.Resources.Schemas {
if s.CatalogName == catalogName && s.Name == name { if s.CreateSchema != nil && s.CatalogName == catalogName && s.Name == schemaName {
return k, s return k, s
} }
} }
@ -69,7 +69,7 @@ func resolvePipeline(p *resources.Pipeline, b *bundle.Bundle) {
} }
} }
func (m *resolveSchemeDependency) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { func (m *captureSchemaDependency) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
for _, p := range b.Config.Resources.Pipelines { for _, p := range b.Config.Resources.Pipelines {
resolvePipeline(p, b) resolvePipeline(p, b)
} }

View File

@ -36,6 +36,10 @@ func TestResolveSchemaDependencyForVolume(t *testing.T) {
Name: "barfoo", Name: "barfoo",
}, },
}, },
"nilschema": {},
"emptyschema": {
CreateSchema: &catalog.CreateSchema{},
},
}, },
Volumes: map[string]*resources.Volume{ Volumes: map[string]*resources.Volume{
"volume1": { "volume1": {