-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into init_on_databricks
- Loading branch information
Showing
10 changed files
with
316 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package phases | ||
|
||
import ( | ||
"testing" | ||
|
||
terraformlib "github.com/databricks/cli/libs/terraform" | ||
tfjson "github.com/hashicorp/terraform-json" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParseTerraformActions(t *testing.T) { | ||
changes := []*tfjson.ResourceChange{ | ||
{ | ||
Type: "databricks_pipeline", | ||
Change: &tfjson.Change{ | ||
Actions: tfjson.Actions{tfjson.ActionCreate}, | ||
}, | ||
Name: "create pipeline", | ||
}, | ||
{ | ||
Type: "databricks_pipeline", | ||
Change: &tfjson.Change{ | ||
Actions: tfjson.Actions{tfjson.ActionDelete}, | ||
}, | ||
Name: "delete pipeline", | ||
}, | ||
{ | ||
Type: "databricks_pipeline", | ||
Change: &tfjson.Change{ | ||
Actions: tfjson.Actions{tfjson.ActionDelete, tfjson.ActionCreate}, | ||
}, | ||
Name: "recreate pipeline", | ||
}, | ||
{ | ||
Type: "databricks_whatever", | ||
Change: &tfjson.Change{ | ||
Actions: tfjson.Actions{tfjson.ActionDelete, tfjson.ActionCreate}, | ||
}, | ||
Name: "recreate whatever", | ||
}, | ||
} | ||
|
||
res := parseTerraformActions(changes, func(typ string, actions tfjson.Actions) bool { | ||
if typ != "databricks_pipeline" { | ||
return false | ||
} | ||
|
||
if actions.Delete() || actions.Replace() { | ||
return true | ||
} | ||
|
||
return false | ||
}) | ||
|
||
assert.Equal(t, []terraformlib.Action{ | ||
{ | ||
Action: terraformlib.ActionTypeDelete, | ||
ResourceType: "databricks_pipeline", | ||
ResourceName: "delete pipeline", | ||
}, | ||
{ | ||
Action: terraformlib.ActionTypeRecreate, | ||
ResourceType: "databricks_pipeline", | ||
ResourceName: "recreate pipeline", | ||
}, | ||
}, res) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
bundle/tests/variables/complex_multiple_files/databricks.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
bundle: | ||
name: complex-variables-multiple-files | ||
|
||
resources: | ||
jobs: | ||
my_job: | ||
job_clusters: | ||
- job_cluster_key: key | ||
new_cluster: ${var.cluster} | ||
|
||
variables: | ||
cluster: | ||
type: complex | ||
description: "A cluster definition" | ||
|
||
include: | ||
- ./variables/*.yml |
11 changes: 11 additions & 0 deletions
11
bundle/tests/variables/complex_multiple_files/variables/clusters.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
targets: | ||
default: | ||
dev: | ||
variables: | ||
cluster: | ||
spark_version: "14.2.x-scala2.11" | ||
node_type_id: "Standard_DS3_v2" | ||
num_workers: 4 | ||
spark_conf: | ||
spark.speculation: false | ||
spark.databricks.delta.retentionDurationCheck.enabled: false |
8 changes: 8 additions & 0 deletions
8
internal/bundle/bundles/recreate_pipeline/databricks_template_schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"properties": { | ||
"unique_id": { | ||
"type": "string", | ||
"description": "Unique ID for the schema and pipeline names" | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
internal/bundle/bundles/recreate_pipeline/template/databricks.yml.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
bundle: | ||
name: "bundle-playground" | ||
|
||
variables: | ||
catalog: | ||
description: The catalog the DLT pipeline should use. | ||
default: main | ||
|
||
|
||
resources: | ||
pipelines: | ||
foo: | ||
name: test-pipeline-{{.unique_id}} | ||
libraries: | ||
- notebook: | ||
path: ./nb.sql | ||
development: true | ||
catalog: ${var.catalog} | ||
|
||
include: | ||
- "*.yml" | ||
|
||
targets: | ||
development: | ||
default: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- Databricks notebook source | ||
select 1 |
Oops, something went wrong.