From dc900f613b821377aec225378edcb34c110744da Mon Sep 17 00:00:00 2001 From: Ilya Kuznetsov Date: Wed, 17 Jun 2026 18:39:19 +0000 Subject: [PATCH] Use deployed name for synced database tables in bundle summary Co-authored-by: Isaac --- NEXT_CHANGELOG.md | 1 + .../basic/out.summary.txt | 4 +- .../synced_database_tables/basic/output.txt | 2 +- .../synced_database_tables/basic/test.toml | 1 - .../config/resources/synced_database_table.go | 16 ++++++- .../resources/synced_database_table_test.go | 43 +++++++++++++++++++ 6 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 bundle/config/resources/synced_database_table_test.go diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index d292188f0f7..6221b79fd11 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -7,6 +7,7 @@ ### CLI ### Bundles +* `bundle summary` now reports the deployed name and URL for `synced_database_tables` (loaded from state) instead of the raw `${resources...}` reference when the configured name embeds another resource's name, matching the existing behavior of `postgres_synced_tables` ([#5639](https://github.com/databricks/cli/pull/5639)). * `bundle run` now prints the modern job run URL (`/jobs//runs/`) so that non-admin users permitted to view the run are taken to the run instead of the workspace homepage. * Fix missing field descriptions in the bundle JSON schema for fields whose upstream API docs arrived after the field was first annotated (e.g. `vector_search_endpoints.*.target_qps`); stale placeholder markers no longer hide them ([#5588](https://github.com/databricks/cli/pull/5588)). diff --git a/acceptance/bundle/resources/synced_database_tables/basic/out.summary.txt b/acceptance/bundle/resources/synced_database_tables/basic/out.summary.txt index 6fb9b6bd515..7ca51e5392b 100644 --- a/acceptance/bundle/resources/synced_database_tables/basic/out.summary.txt +++ b/acceptance/bundle/resources/synced_database_tables/basic/out.summary.txt @@ -14,5 +14,5 @@ Resources: URL: [DATABRICKS_URL]/compute/database-instances/test-db-synced-table-[UNIQUE_NAME] Synced database tables: my_synced_table: - Name: ${resources.database_catalogs.my_catalog.name}.${resources.database_catalogs.my_catalog.database_name}.my_synced_table - URL: [DATABRICKS_URL]/explore/data/$%7Bresources.database_catalogs.my_catalog.name%7D.$%7Bresources.database_catalogs.my_catalog.database_name%7D.my_synced_table + Name: my_catalog_[UNIQUE_NAME].my_database.my_synced_table + URL: [DATABRICKS_URL]/explore/data/my_catalog_[UNIQUE_NAME].my_database.my_synced_table diff --git a/acceptance/bundle/resources/synced_database_tables/basic/output.txt b/acceptance/bundle/resources/synced_database_tables/basic/output.txt index b1fac3c7678..4fec2ee6018 100644 --- a/acceptance/bundle/resources/synced_database_tables/basic/output.txt +++ b/acceptance/bundle/resources/synced_database_tables/basic/output.txt @@ -21,7 +21,7 @@ Resources: Synced database tables: my_synced_table: Name: ${resources.database_catalogs.my_catalog.name}.${resources.database_catalogs.my_catalog.database_name}.my_synced_table - URL: [DATABRICKS_URL]/explore/data/$%7Bresources.database_catalogs.my_catalog.name%7D.$%7Bresources.database_catalogs.my_catalog.database_name%7D.my_synced_table + URL: (not deployed) >>> [CLI] bundle validate Name: deploy-lakebase-synced-table-[UNIQUE_NAME] diff --git a/acceptance/bundle/resources/synced_database_tables/basic/test.toml b/acceptance/bundle/resources/synced_database_tables/basic/test.toml index e93f7b08093..155fb5c75b4 100644 --- a/acceptance/bundle/resources/synced_database_tables/basic/test.toml +++ b/acceptance/bundle/resources/synced_database_tables/basic/test.toml @@ -1,6 +1,5 @@ Local = true Cloud = true -Badness = "post deployment, bundle summary should print actual name that is fully resolved" RecordRequests = false diff --git a/bundle/config/resources/synced_database_table.go b/bundle/config/resources/synced_database_table.go index 76ddf3ac95d..b4fee7fab83 100644 --- a/bundle/config/resources/synced_database_table.go +++ b/bundle/config/resources/synced_database_table.go @@ -3,6 +3,7 @@ package resources import ( "context" "net/url" + "strings" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" @@ -35,6 +36,14 @@ func (s *SyncedDatabaseTable) ResourceDescription() ResourceDescription { } func (s *SyncedDatabaseTable) GetName() string { + // A synced table's id is its three-part name (catalog.schema.table), so the + // id IS the name. Prefer the post-deploy id so bundle summary renders the + // resolved name even when the configured name still has unresolved + // cross-resource references like ${resources.X.Y.Z}. Mirrors + // PostgresSyncedTable.GetName. + if s.ID != "" { + return s.ID + } return s.Name } @@ -43,8 +52,11 @@ func (s *SyncedDatabaseTable) GetURL() string { } func (s *SyncedDatabaseTable) InitializeURL(baseURL url.URL) { - if s.Name == "" { + // Bail if the name isn't a fully resolved three-part identifier; an + // unresolved ${...} reference would otherwise produce a misleading URL. + name := s.GetName() + if strings.Count(name, ".") != 2 { return } - s.URL = workspaceurls.ResourceURL(baseURL, "synced_database_tables", s.Name) + s.URL = workspaceurls.ResourceURL(baseURL, "synced_database_tables", name) } diff --git a/bundle/config/resources/synced_database_table_test.go b/bundle/config/resources/synced_database_table_test.go new file mode 100644 index 00000000000..ab84713bf91 --- /dev/null +++ b/bundle/config/resources/synced_database_table_test.go @@ -0,0 +1,43 @@ +package resources + +import ( + "net/url" + "testing" + + "github.com/databricks/databricks-sdk-go/service/database" + "github.com/stretchr/testify/assert" +) + +func TestSyncedDatabaseTableGetName(t *testing.T) { + s := &SyncedDatabaseTable{ + SyncedDatabaseTable: database.SyncedDatabaseTable{ + Name: "${resources.database_catalogs.cat.name}.public.t", + }, + } + + // Before deploy the configured name (with its unresolved reference) is used. + assert.Equal(t, "${resources.database_catalogs.cat.name}.public.t", s.GetName()) + + // After deploy the resolved name is loaded into the id and preferred. + s.ID = "my_catalog.public.t" + assert.Equal(t, "my_catalog.public.t", s.GetName()) +} + +func TestSyncedDatabaseTableInitializeURL(t *testing.T) { + baseURL := url.URL{Scheme: "https", Host: "example.com"} + + s := &SyncedDatabaseTable{ + SyncedDatabaseTable: database.SyncedDatabaseTable{ + Name: "${resources.database_catalogs.cat.name}.public.t", + }, + } + + // An unresolved reference is not a three-part name, so no URL is produced. + s.InitializeURL(baseURL) + assert.Empty(t, s.URL) + + // The resolved three-part id yields a URL. + s.ID = "my_catalog.public.t" + s.InitializeURL(baseURL) + assert.Contains(t, s.URL, "my_catalog.public.t") +}