Skip to content

testserver: Fix pipelines update to set default for storage #2960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 3, 2025
Merged
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
25 changes: 15 additions & 10 deletions libs/testserver/pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,14 @@ func (s *FakeWorkspace) PipelineCreate(req Request) Response {
r.Spec = &spec

pipelineId := uuid.New().String()
spec.Id = pipelineId
r.PipelineId = pipelineId
r.CreatorUserName = "tester@databricks.com"
r.LastModified = time.Now().UnixMilli()
r.Name = r.Spec.Name
r.RunAsUserName = "tester@databricks.com"
r.State = "IDLE"

// If the pipeline definition does not specify a catalog, it switches to Hive metastore mode
// and if the storage location is not specified, API automatically generates a storage location
// (ref: https://docs.databricks.com/gcp/en/dlt/hive-metastore#specify-a-storage-location)
if spec.Storage == "" && spec.Catalog == "" {
spec.Storage = "dbfs:/pipelines/" + pipelineId
}
setSpecDefaults(&spec, pipelineId)
s.Pipelines[pipelineId] = r

return Response{
Expand All @@ -63,11 +57,21 @@ func (s *FakeWorkspace) PipelineCreate(req Request) Response {
}
}

func setSpecDefaults(spec *pipelines.PipelineSpec, pipelineId string) {
spec.Id = pipelineId
// If the pipeline definition does not specify a catalog, it switches to Hive metastore mode
// and if the storage location is not specified, API automatically generates a storage location
// (ref: https://docs.databricks.com/gcp/en/dlt/hive-metastore#specify-a-storage-location)
if spec.Storage == "" && spec.Catalog == "" {
spec.Storage = "dbfs:/pipelines/" + pipelineId
}
}

func (s *FakeWorkspace) PipelineUpdate(req Request, pipelineId string) Response {
defer s.LockUnlock()()

var request pipelines.PipelineSpec
err := json.Unmarshal(req.Body, &request)
var spec pipelines.PipelineSpec
err := json.Unmarshal(req.Body, &spec)
if err != nil {
return Response{
Body: fmt.Sprintf("internal error: %s", err),
Expand All @@ -82,7 +86,8 @@ func (s *FakeWorkspace) PipelineUpdate(req Request, pipelineId string) Response
}
}

item.Spec = &request
item.Spec = &spec
setSpecDefaults(&spec, pipelineId)
s.Pipelines[pipelineId] = item

return Response{
Expand Down
Loading