Skip to content
11 changes: 4 additions & 7 deletions experimental/aitools/cmd/init_template/empty.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/experimental/aitools/lib/middlewares"
"github.com/databricks/cli/libs/template"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -62,16 +61,14 @@ After initialization:
return fmt.Errorf("--language must be 'python', 'sql', or 'other', got '%s'", language)
}

// Default to workspace default catalog if not specified
if catalog == "" {
catalog = middlewares.GetDefaultCatalog(ctx)
}

configMap := map[string]any{
"project_name": name,
"personal_schemas": "yes",
"language_choice": language,
"default_catalog": catalog,
}

if catalog != "" {
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.

why not the other way around? ie updating default catalog like this does not look quite right, maybe need explicit setting --default-catalogue instead?

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.

This provides us parity with the standard template. The current version in main sets an empty value as the catalog instead, which causes an immediate error when trying to deploy. There needs to be some value.

configMap["default_catalog"] = catalog
}

return MaterializeTemplate(ctx, TemplateConfig{
Expand Down
10 changes: 3 additions & 7 deletions experimental/aitools/cmd/init_template/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"

"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/experimental/aitools/lib/middlewares"
"github.com/databricks/cli/libs/template"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -50,19 +49,16 @@ After initialization:
return errors.New("--name is required. Example: init-template job --name my_job")
}

// Default to workspace default catalog if not specified
if catalog == "" {
catalog = middlewares.GetDefaultCatalog(ctx)
}

configMap := map[string]any{
"project_name": name,
"include_job": "yes",
"include_pipeline": "no",
"include_python": "yes",
"serverless": "yes",
"personal_schemas": "yes",
"default_catalog": catalog,
}
if catalog != "" {
configMap["default_catalog"] = catalog
}

return MaterializeTemplate(ctx, TemplateConfig{
Expand Down
11 changes: 4 additions & 7 deletions experimental/aitools/cmd/init_template/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/experimental/aitools/lib/middlewares"
"github.com/databricks/cli/libs/template"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -59,16 +58,14 @@ After initialization:
return fmt.Errorf("--language must be 'python' or 'sql', got '%s'", language)
}

// Default to workspace default catalog if not specified
if catalog == "" {
catalog = middlewares.GetDefaultCatalog(ctx)
}

configMap := map[string]any{
"project_name": name,
"personal_schemas": "yes",
"language": language,
"default_catalog": catalog,
}

if catalog != "" {
configMap["default_catalog"] = catalog
}

return MaterializeTemplate(ctx, TemplateConfig{
Expand Down