Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Notable Changes

### CLI
* `experimental open` now opens every DABs resource type that has a workspace URL, picking up `catalogs`, `schemas`, `volumes`, `database_instances`, `database_catalogs`, `synced_database_tables`, `postgres_catalogs`, `postgres_synced_tables`, `quality_monitors`, `vector_search_endpoints`, and `vector_search_indexes` ([#5346](https://github.com/databricks/cli/pull/5346)).

### Bundles
* The error reported when a direct-only resource (catalogs, external locations, vector search endpoints) is used with the terraform engine now also suggests setting `bundle.engine: direct` in `databricks.yml`, in addition to the `DATABRICKS_BUNDLE_ENGINE` environment variable ([#5295](https://github.com/databricks/cli/pull/5295)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Resources:
Postgres synced tables:
my_table:
Name: ${resources.postgres_catalogs.my_catalog.catalog_id}.public.trips_synced
URL: [DATABRICKS_URL]/explore/data/$%7Bresources/postgres_catalogs/my_catalog.catalog_id%7D.public.trips_synced
URL: (not deployed)
Schemas:
pipeline_storage:
Name: pipeline_storage_[UNIQUE_NAME]
Expand Down
13 changes: 12 additions & 1 deletion acceptance/experimental/open/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,35 @@

=== unknown resource type
>>> [CLI] experimental open --url unknown 123
Error: unknown resource type "unknown", must be one of: alerts, apps, clusters, dashboards, experiments, jobs, model_serving_endpoints, models, notebooks, pipelines, queries, registered_models, warehouses
Error: unknown resource type "unknown", must be one of: alerts, apps, catalogs, clusters, dashboards, database_catalogs, database_instances, experiments, jobs, model_serving_endpoints, models, notebooks, pipelines, postgres_catalogs, postgres_synced_tables, quality_monitors, queries, registered_models, schemas, synced_database_tables, vector_search_endpoints, vector_search_indexes, volumes, warehouses

Exit code: 1

=== test auto-completion handler
>>> [CLI] __complete experimental open ,
alerts
apps
catalogs
clusters
dashboards
database_catalogs
database_instances
experiments
jobs
model_serving_endpoints
models
notebooks
pipelines
postgres_catalogs
postgres_synced_tables
quality_monitors
queries
registered_models
schemas
synced_database_tables
vector_search_endpoints
vector_search_indexes
volumes
warehouses
:4
Completion ended with directive: ShellCompDirectiveNoFileComp
5 changes: 2 additions & 3 deletions bundle/config/resources/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package resources
import (
"context"
"net/url"
"strings"

"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/apierr"
"github.com/databricks/databricks-sdk-go/marshal"
"github.com/databricks/databricks-sdk-go/service/catalog"

"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/workspaceurls"
)

type Catalog struct {
Expand Down Expand Up @@ -48,8 +48,7 @@ func (c *Catalog) InitializeURL(baseURL url.URL) {
if c.ID == "" {
return
}
baseURL.Path = "explore/data/" + strings.ReplaceAll(c.ID, ".", "/")
c.URL = baseURL.String()
c.URL = workspaceurls.ResourceURL(baseURL, "catalogs", c.ID)
}

func (c *Catalog) GetURL() string {
Expand Down
4 changes: 2 additions & 2 deletions bundle/config/resources/database_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/url"

"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/workspaceurls"

"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/service/database"
Expand Down Expand Up @@ -45,6 +46,5 @@ func (d *DatabaseCatalog) InitializeURL(baseURL url.URL) {
if d.Name == "" {
return
}
baseURL.Path = "explore/data/" + d.Name
d.URL = baseURL.String()
d.URL = workspaceurls.ResourceURL(baseURL, "database_catalogs", d.Name)
}
4 changes: 2 additions & 2 deletions bundle/config/resources/database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/url"

"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/workspaceurls"

"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/service/database"
Expand Down Expand Up @@ -50,6 +51,5 @@ func (d *DatabaseInstance) InitializeURL(baseURL url.URL) {
if d.Name == "" {
return
}
baseURL.Path = "compute/database-instances/" + d.Name
d.URL = baseURL.String()
d.URL = workspaceurls.ResourceURL(baseURL, "database_instances", d.Name)
}
4 changes: 2 additions & 2 deletions bundle/config/resources/postgres_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/url"

"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/workspaceurls"
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/marshal"
"github.com/databricks/databricks-sdk-go/service/postgres"
Expand Down Expand Up @@ -61,6 +62,5 @@ func (c *PostgresCatalog) InitializeURL(baseURL url.URL) {
if c.CatalogId == "" {
return
}
baseURL.Path = "explore/data/" + c.CatalogId
c.URL = baseURL.String()
c.URL = workspaceurls.ResourceURL(baseURL, "postgres_catalogs", c.CatalogId)
}
16 changes: 7 additions & 9 deletions bundle/config/resources/postgres_synced_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/workspaceurls"
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/marshal"
"github.com/databricks/databricks-sdk-go/service/postgres"
Expand Down Expand Up @@ -68,15 +69,12 @@ func (s *PostgresSyncedTable) GetURL() string {
}

func (s *PostgresSyncedTable) InitializeURL(baseURL url.URL) {
// UC explore expects /{catalog}/{schema}/{table}, not a single dotted segment.
catalog, rest, ok := strings.Cut(s.GetName(), ".")
if !ok {
// UC explore expects /{catalog}/{schema}/{table}, so 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
}
schema, table, ok := strings.Cut(rest, ".")
if !ok {
return
}
baseURL.Path = "explore/data/" + catalog + "/" + schema + "/" + table
s.URL = baseURL.String()
s.URL = workspaceurls.ResourceURL(baseURL, "postgres_synced_tables", name)
}
5 changes: 2 additions & 3 deletions bundle/config/resources/quality_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package resources
import (
"context"
"net/url"
"strings"

"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/workspaceurls"
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/marshal"
"github.com/databricks/databricks-sdk-go/service/catalog"
Expand Down Expand Up @@ -54,8 +54,7 @@ func (s *QualityMonitor) InitializeURL(baseURL url.URL) {
if s.TableName == "" {
return
}
baseURL.Path = "explore/data/" + strings.ReplaceAll(s.TableName, ".", "/")
s.URL = baseURL.String()
s.URL = workspaceurls.ResourceURL(baseURL, "quality_monitors", s.TableName)
}

func (s *QualityMonitor) GetName() string {
Expand Down
5 changes: 2 additions & 3 deletions bundle/config/resources/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package resources
import (
"context"
"net/url"
"strings"

"github.com/databricks/databricks-sdk-go/apierr"

"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/workspaceurls"

"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/marshal"
Expand Down Expand Up @@ -50,8 +50,7 @@ func (s *Schema) InitializeURL(baseURL url.URL) {
if s.ID == "" {
return
}
baseURL.Path = "explore/data/" + strings.ReplaceAll(s.ID, ".", "/")
s.URL = baseURL.String()
s.URL = workspaceurls.ResourceURL(baseURL, "schemas", s.ID)
}

func (s *Schema) GetURL() string {
Expand Down
4 changes: 2 additions & 2 deletions bundle/config/resources/synced_database_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/url"

"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/workspaceurls"

"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/service/database"
Expand Down Expand Up @@ -45,6 +46,5 @@ func (s *SyncedDatabaseTable) InitializeURL(baseURL url.URL) {
if s.Name == "" {
return
}
baseURL.Path = "explore/data/" + s.Name
s.URL = baseURL.String()
s.URL = workspaceurls.ResourceURL(baseURL, "synced_database_tables", s.Name)
}
4 changes: 2 additions & 2 deletions bundle/config/resources/vector_search_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/url"

"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/workspaceurls"
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/apierr"
"github.com/databricks/databricks-sdk-go/marshal"
Expand Down Expand Up @@ -51,8 +52,7 @@ func (e *VectorSearchEndpoint) InitializeURL(baseURL url.URL) {
if e.Name == "" {
return
}
baseURL.Path = "compute/vector-search/" + e.Name
e.URL = baseURL.String()
e.URL = workspaceurls.ResourceURL(baseURL, "vector_search_endpoints", e.Name)
}

func (e *VectorSearchEndpoint) GetName() string {
Expand Down
17 changes: 6 additions & 11 deletions bundle/config/resources/vector_search_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/workspaceurls"
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/apierr"
"github.com/databricks/databricks-sdk-go/marshal"
Expand Down Expand Up @@ -51,19 +52,13 @@ func (e *VectorSearchIndex) ResourceDescription() ResourceDescription {
}

func (e *VectorSearchIndex) InitializeURL(baseURL url.URL) {
if e.Name == "" {
// UC explore expects /{catalog}/{schema}/{name}, so bail if the name isn't
// a fully resolved three-part identifier; an unresolved ${...} reference
// would otherwise produce a misleading URL.
if strings.Count(e.Name, ".") != 2 {
return
}
catalog, rest, ok := strings.Cut(e.Name, ".")
if !ok {
return
}
schema, name, ok := strings.Cut(rest, ".")
if !ok {
return
}
baseURL.Path = "explore/data/" + catalog + "/" + schema + "/" + name
e.URL = baseURL.String()
e.URL = workspaceurls.ResourceURL(baseURL, "vector_search_indexes", e.Name)
}

func (e *VectorSearchIndex) GetName() string {
Expand Down
5 changes: 2 additions & 3 deletions bundle/config/resources/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package resources
import (
"context"
"net/url"
"strings"

"github.com/databricks/databricks-sdk-go/apierr"

"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/workspaceurls"
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/marshal"
"github.com/databricks/databricks-sdk-go/service/catalog"
Expand Down Expand Up @@ -59,8 +59,7 @@ func (v *Volume) InitializeURL(baseURL url.URL) {
if v.ID == "" {
return
}
baseURL.Path = "explore/data/volumes/" + strings.ReplaceAll(v.ID, ".", "/")
v.URL = baseURL.String()
v.URL = workspaceurls.ResourceURL(baseURL, "volumes", v.ID)
}

func (v *Volume) GetURL() string {
Expand Down
11 changes: 11 additions & 0 deletions bundle/config/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,26 @@ func TestBundleResourcePluralNamesResolveInWorkspaceURLs(t *testing.T) {
withURLs := []string{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a) It seems easier to include missing ones?

b) Should there be missing ones? I see these are missing, is that intentional?

Copy link
Copy Markdown
Contributor

@andrewnester andrewnester May 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

external_locations and secret_scopes are intentional, these are not workspace resources with its own URL. I believe postgres ones too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that almost all are here, I like the idea of inverting it into an opt-out for missing ones. Will do as follow-up and address postgres_* as part of upcoming work

"alerts",
"apps",
"catalogs",
"clusters",
"dashboards",
"database_catalogs",
"database_instances",
"experiments",
"jobs",
"models",
"model_serving_endpoints",
"pipelines",
"postgres_catalogs",
"postgres_synced_tables",
"quality_monitors",
"registered_models",
"schemas",
"sql_warehouses",
"synced_database_tables",
"vector_search_endpoints",
"vector_search_indexes",
"volumes",
}

supported := SupportedResources()
Expand Down
44 changes: 28 additions & 16 deletions cmd/experimental/workspace_open_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestBuildWorkspaceURLFragmentBasedResources(t *testing.T) {
func TestBuildWorkspaceURLUnknownResourceType(t *testing.T) {
_, err := workspaceurls.BuildResourceURL("https://myworkspace.databricks.com", "unknown", "123", 0)
assert.ErrorContains(t, err, "unknown resource type \"unknown\"")
assert.ErrorContains(t, err, "alerts, apps, clusters, dashboards, experiments, jobs, model_serving_endpoints, models, notebooks, pipelines, queries, registered_models, warehouses")
assert.ErrorContains(t, err, "alerts, apps, catalogs, clusters, dashboards, database_catalogs, database_instances, experiments, jobs, model_serving_endpoints, models, notebooks, pipelines, postgres_catalogs, postgres_synced_tables, quality_monitors, queries, registered_models, schemas, synced_database_tables, vector_search_endpoints, vector_search_indexes, volumes, warehouses")
}

func TestBuildWorkspaceURLHostWithTrailingSlash(t *testing.T) {
Expand Down Expand Up @@ -106,20 +106,32 @@ func TestWorkspaceOpenCommandCompletion(t *testing.T) {

completions, directive := cmd.ValidArgsFunction(cmd, []string{}, "")
assert.Equal(t, cobra.ShellCompDirectiveNoFileComp, directive)
assert.Contains(t, completions, "alerts")
assert.Contains(t, completions, "apps")
assert.Contains(t, completions, "clusters")
assert.Contains(t, completions, "dashboards")
assert.Contains(t, completions, "experiments")
assert.Contains(t, completions, "jobs")
assert.Contains(t, completions, "models")
assert.Contains(t, completions, "model_serving_endpoints")
assert.Contains(t, completions, "notebooks")
assert.Contains(t, completions, "pipelines")
assert.Contains(t, completions, "queries")
assert.Contains(t, completions, "registered_models")
assert.Contains(t, completions, "warehouses")
assert.Len(t, completions, 13)
assert.Equal(t, []string{
"alerts",
"apps",
"catalogs",
"clusters",
"dashboards",
"database_catalogs",
"database_instances",
"experiments",
"jobs",
"model_serving_endpoints",
"models",
"notebooks",
"pipelines",
"postgres_catalogs",
"postgres_synced_tables",
"quality_monitors",
"queries",
"registered_models",
"schemas",
"synced_database_tables",
"vector_search_endpoints",
"vector_search_indexes",
"volumes",
"warehouses",
}, completions)
}

func TestWorkspaceOpenCommandCompletionSecondArg(t *testing.T) {
Expand All @@ -133,7 +145,7 @@ func TestWorkspaceOpenCommandCompletionSecondArg(t *testing.T) {
func TestWorkspaceOpenCommandHelpText(t *testing.T) {
cmd := newWorkspaceOpenCommand()

assert.Contains(t, cmd.Long, "Supported resource types: alerts, apps, clusters, dashboards, experiments, jobs, model_serving_endpoints, models, notebooks, pipelines, queries, registered_models, warehouses.")
assert.Contains(t, cmd.Long, "Supported resource types: alerts, apps, catalogs, clusters, dashboards, database_catalogs, database_instances, experiments, jobs, model_serving_endpoints, models, notebooks, pipelines, postgres_catalogs, postgres_synced_tables, quality_monitors, queries, registered_models, schemas, synced_database_tables, vector_search_endpoints, vector_search_indexes, volumes, warehouses.")
assert.Contains(t, cmd.Long, "databricks experimental open jobs 123456789")
assert.Contains(t, cmd.Long, "databricks experimental open notebooks /Users/user@example.com/my-notebook")
assert.Contains(t, cmd.Long, "databricks experimental open registered_models catalog.schema.my_model")
Expand Down
Loading
Loading