Skip to content
Open
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
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
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?

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