Skip to content
Draft
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
13 changes: 13 additions & 0 deletions mmv1/products/dataplex/Datascan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ examples:
datascan_name: 'dataprofile-full'
test_env_vars:
project_name: 'PROJECT_NAME'
exclude_test: true
- name: 'dataplex_datascan_full_profile_test'
primary_resource_id: 'full_profile_test'
vars:
dataset_name: 'dataplex_dataset'
datascan_name: 'dataprofile-full-test'
test_env_vars:
project_name: 'PROJECT_NAME'
exclude_docs: true
- name: 'dataplex_datascan_basic_quality'
primary_resource_id: 'basic_quality'
vars:
Expand Down Expand Up @@ -573,6 +582,10 @@ properties:
For instance, if 'x' is of nested field type, listing 'x' is supported but 'x.y.z' is not supported. Here 'y' and 'y.z' are nested fields of 'x'.
item_type:
type: String
- name: 'catalogPublishingEnabled'
type: Boolean
description: |
If set, the latest DataScan job result will be published to Dataplex Catalog.
- name: 'dataDiscoverySpec'
type: NestedObject
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ resource "google_dataplex_datascan" "{{$.PrimaryResourceId}}" {
results_table = "//bigquery.googleapis.com/projects/{{index $.TestEnvVars "project_name"}}/datasets/{{index $.Vars "dataset_name"}}/tables/profile_export"
}
}
catalog_publishing_enabled = true
}

project = "{{index $.TestEnvVars "project_name"}}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
resource "google_bigquery_dataset" "tf_test_dataset" {
dataset_id = "tf_test_dataset_id_%{random_suffix}"
default_table_expiration_ms = 3600000
}

resource "google_bigquery_table" "tf_test_table" {
dataset_id = google_bigquery_dataset.tf_test_dataset.dataset_id
table_id = "tf_test_table_id_%{random_suffix}"
deletion_protection = false
schema = <<EOF
[
{
"name": "word",
"type": "STRING",
"mode": "REQUIRED"
},
{
"name": "word_count",
"type": "INTEGER",
"mode": "REQUIRED"
},
{
"name": "corpus",
"type": "STRING",
"mode": "REQUIRED"
},
{
"name": "corpus_date",
"type": "INTEGER",
"mode": "REQUIRED"
}
]
EOF
}

resource "google_dataplex_datascan" "{{$.PrimaryResourceId}}" {
location = "us-central1"
display_name = "Full Datascan Quality Publishing"
data_scan_id = "{{index $.Vars "datascan_name"}}"
description = "Example resource - Full Datascan Quality with Publishing enabled"
labels = {
author = "billing"
}

data {
resource = "//bigquery.googleapis.com/projects/{{index $.TestEnvVars "project_name"}}/datasets/${google_bigquery_dataset.tf_test_dataset.dataset_id}/tables/${google_bigquery_table.tf_test_table.table_id}"
}

execution_spec {
trigger {
schedule {
cron = "TZ=America/New_York 1 1 * * *"
}
}
}

data_profile_spec {
sampling_percent = 80
row_filter = "word_count > 10"
include_fields {
field_names = ["word_count"]
}
exclude_fields {
field_names = ["property_type"]
}
post_scan_actions {
bigquery_export {
results_table = "//bigquery.googleapis.com/projects/{{index $.TestEnvVars "project_name"}}/datasets/{{index $.Vars "dataset_name"}}/tables/profile_export"
}
}
catalog_publishing_enabled = true
}

project = "{{index $.TestEnvVars "project_name"}}"

depends_on = [
google_bigquery_dataset.tf_test_dataset
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,210 @@ resource "google_dataplex_datascan" "full_quality" {
}
`, context)
}

func TestAccDataplexDatascan_dataplexDatascanFullProfile_update(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"project_name": envvar.GetTestProjectFromEnv(),
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckDataplexDatascanDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDataplexDatascan_dataplexDatascanFullProfile_full(context),
},
{
ResourceName: "google_dataplex_datascan.full_profile",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"data_scan_id", "labels", "location", "terraform_labels"},
},
{
Config: testAccDataplexDatascan_dataplexDatascanFullProfile_update(context),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction("google_dataplex_datascan.full_profile", plancheck.ResourceActionUpdate),
},
},
},
{
ResourceName: "google_dataplex_datascan.full_profile",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"data_scan_id", "labels", "location", "terraform_labels"},
},
},
})
}

func testAccDataplexDatascan_dataplexDatascanFullProfile_full(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_bigquery_dataset" "tf_test_dataset" {
dataset_id = "tf_test_dataset_id_%{random_suffix}"
default_table_expiration_ms = 3600000
}

resource "google_bigquery_table" "tf_test_table" {
dataset_id = google_bigquery_dataset.tf_test_dataset.dataset_id
table_id = "tf_test_table_id_%{random_suffix}"
deletion_protection = false
schema = <<EOF
[
{
"name": "word",
"type": "STRING",
"mode": "REQUIRED"
},
{
"name": "word_count",
"type": "INTEGER",
"mode": "REQUIRED"
},
{
"name": "corpus",
"type": "STRING",
"mode": "REQUIRED"
},
{
"name": "corpus_date",
"type": "INTEGER",
"mode": "REQUIRED"
}
]
EOF
}

resource "google_dataplex_datascan" "full_profile_test" {
location = "us-central1"
display_name = "Full Datascan Quality Publishing"
data_scan_id = "tf-test-dataprofile-full-test%{random_suffix}"
description = "Example resource - Full Datascan Quality with Publishing enabled"
labels = {
author = "billing"
}

data {
resource = "//bigquery.googleapis.com/projects/%{project_name}/datasets/${google_bigquery_dataset.tf_test_dataset.dataset_id}/tables/${google_bigquery_table.tf_test_table.table_id}"
}

execution_spec {
trigger {
schedule {
cron = "TZ=America/New_York 1 1 * * *"
}
}
}

data_profile_spec {
sampling_percent = 80
row_filter = "word_count > 10"
include_fields {
field_names = ["word_count"]
}
exclude_fields {
field_names = ["property_type"]
}
post_scan_actions {
bigquery_export {
results_table = "//bigquery.googleapis.com/projects/%{project_name}/datasets/tf_test_dataplex_dataset%{random_suffix}/tables/profile_export"
}
}
}

project = "%{project_name}"

depends_on = [
google_bigquery_dataset.tf_test_dataset
]
}
`, context)
}

func testAccDataplexDatascan_dataplexDatascanFullProfile_update(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_bigquery_dataset" "tf_test_dataset" {
dataset_id = "tf_test_dataset_id_%{random_suffix}"
default_table_expiration_ms = 3600000
}

resource "google_bigquery_table" "tf_test_table" {
dataset_id = google_bigquery_dataset.tf_test_dataset.dataset_id
table_id = "tf_test_table_id_%{random_suffix}"
deletion_protection = false
schema = <<EOF
[
{
"name": "word",
"type": "STRING",
"mode": "REQUIRED"
},
{
"name": "word_count",
"type": "INTEGER",
"mode": "REQUIRED"
},
{
"name": "corpus",
"type": "STRING",
"mode": "REQUIRED"
},
{
"name": "corpus_date",
"type": "INTEGER",
"mode": "REQUIRED"
}
]
EOF
}

resource "google_dataplex_datascan" "full_profile_test" {
location = "us-central1"
display_name = "Full Datascan Quality Publishing"
data_scan_id = "tf-test-dataprofile-full-test%{random_suffix}"
description = "Example resource - Full Datascan Quality with Publishing enabled"
labels = {
author = "billing"
}

data {
resource = "//bigquery.googleapis.com/projects/%{project_name}/datasets/${google_bigquery_dataset.tf_test_dataset.dataset_id}/tables/${google_bigquery_table.tf_test_table.table_id}"
}

execution_spec {
trigger {
schedule {
cron = "TZ=America/New_York 1 1 * * *"
}
}
}

data_profile_spec {
sampling_percent = 80
row_filter = "word_count > 10"
include_fields {
field_names = ["word_count"]
}
exclude_fields {
field_names = ["property_type"]
}
post_scan_actions {
bigquery_export {
results_table = "//bigquery.googleapis.com/projects/%{project_name}/datasets/tf_test_dataplex_dataset%{random_suffix}/tables/profile_export"
}
}
catalog_publishing_enabled = true
}

project = "%{project_name}"

depends_on = [
google_bigquery_dataset.tf_test_dataset
]
}
`, context)
}
Loading