From fc8b5e757640ad9f8183f0630aaa8386b2879fde Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Tue, 7 Jan 2025 15:33:29 +0530 Subject: [PATCH] address comments --- ...ependency.go => capture_schema_dependency.go} | 16 ++++++++-------- ...test.go => capture_schema_dependency_test.go} | 4 ++++ 2 files changed, 12 insertions(+), 8 deletions(-) rename bundle/config/mutator/{resolve_schema_dependency.go => capture_schema_dependency.go} (81%) rename bundle/config/mutator/{resolve_schema_dependency_test.go => capture_schema_dependency_test.go} (98%) diff --git a/bundle/config/mutator/resolve_schema_dependency.go b/bundle/config/mutator/capture_schema_dependency.go similarity index 81% rename from bundle/config/mutator/resolve_schema_dependency.go rename to bundle/config/mutator/capture_schema_dependency.go index e2468b78f..979432185 100644 --- a/bundle/config/mutator/resolve_schema_dependency.go +++ b/bundle/config/mutator/capture_schema_dependency.go @@ -9,7 +9,7 @@ import ( "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 // or UC Volumes using the `${resources.schemas..name}` syntax. Using this @@ -19,20 +19,20 @@ type resolveSchemeDependency struct{} // This mutator translates any implicit schema references in DLT pipelines or UC Volumes // to the explicit syntax. func ResolveSchemaDependency() bundle.Mutator { - return &resolveSchemeDependency{} + return &captureSchemaDependency{} } -func (m *resolveSchemeDependency) Name() string { - return "ResolveSchemaDependency" +func (m *captureSchemaDependency) Name() string { + return "CaptureSchemaDependency" } -func findSchema(b *bundle.Bundle, catalogName, name string) (string, *resources.Schema) { - if catalogName == "" || name == "" { +func findSchema(b *bundle.Bundle, catalogName, schemaName string) (string, *resources.Schema) { + if catalogName == "" || schemaName == "" { return "", nil } 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 } } @@ -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 { resolvePipeline(p, b) } diff --git a/bundle/config/mutator/resolve_schema_dependency_test.go b/bundle/config/mutator/capture_schema_dependency_test.go similarity index 98% rename from bundle/config/mutator/resolve_schema_dependency_test.go rename to bundle/config/mutator/capture_schema_dependency_test.go index feb466983..4ef170405 100644 --- a/bundle/config/mutator/resolve_schema_dependency_test.go +++ b/bundle/config/mutator/capture_schema_dependency_test.go @@ -36,6 +36,10 @@ func TestResolveSchemaDependencyForVolume(t *testing.T) { Name: "barfoo", }, }, + "nilschema": {}, + "emptyschema": { + CreateSchema: &catalog.CreateSchema{}, + }, }, Volumes: map[string]*resources.Volume{ "volume1": {