From bc86ca4ed0e3e529161e594646492895abf20b14 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sat, 8 Jun 2024 13:21:11 +0100 Subject: [PATCH 1/6] aws_glue_catalog_table --- internal/service/glue/catalog_table.go | 10 ++++++++++ internal/service/glue/catalog_table_test.go | 2 ++ 2 files changed, 12 insertions(+) diff --git a/internal/service/glue/catalog_table.go b/internal/service/glue/catalog_table.go index 1be9d46f923..05ef7e3a0bb 100644 --- a/internal/service/glue/catalog_table.go +++ b/internal/service/glue/catalog_table.go @@ -110,6 +110,11 @@ func ResourceCatalogTable() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "additional_locations": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, "bucket_columns": { Type: schema.TypeList, Optional: true, @@ -698,6 +703,10 @@ func expandStorageDescriptor(l []interface{}) *glue.StorageDescriptor { s := l[0].(map[string]interface{}) storageDescriptor := &glue.StorageDescriptor{} + if v, ok := s["additional_locations"]; ok { + storageDescriptor.AdditionalLocations = flex.ExpandStringList(v.([]interface{})) + } + if v, ok := s["columns"]; ok { storageDescriptor.Columns = expandColumns(v.([]interface{})) } @@ -903,6 +912,7 @@ func flattenStorageDescriptor(s *glue.StorageDescriptor) []map[string]interface{ storageDescriptor := make(map[string]interface{}) + storageDescriptor["additional_locations"] = flex.FlattenStringList(s.AdditionalLocations) storageDescriptor["columns"] = flattenColumns(s.Columns) storageDescriptor[names.AttrLocation] = aws.StringValue(s.Location) storageDescriptor["input_format"] = aws.StringValue(s.InputFormat) diff --git a/internal/service/glue/catalog_table_test.go b/internal/service/glue/catalog_table_test.go index d58dd3e52f2..9cf56d2a04d 100644 --- a/internal/service/glue/catalog_table_test.go +++ b/internal/service/glue/catalog_table_test.go @@ -116,6 +116,7 @@ func TestAccGlueCatalogTable_full(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrDescription, description), resource.TestCheckResourceAttr(resourceName, names.AttrOwner, "my_owner"), resource.TestCheckResourceAttr(resourceName, "retention", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.additional_locations.0", "my_additional_locations"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.name", "my_column_1"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.type", "int"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.comment", "my_column1_comment"), @@ -754,6 +755,7 @@ resource "aws_glue_catalog_table" "test" { view_original_text = "view_original_text_1" storage_descriptor { + additional_locations = ["my_additional_locations"] bucket_columns = ["bucket_column_1"] compressed = false input_format = "SequenceFileInputFormat" From 3aa6e70116c6918fd9fb21c23de26f9cec394c78 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sat, 8 Jun 2024 13:23:14 +0100 Subject: [PATCH 2/6] additional location support --- internal/service/glue/catalog_table_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/service/glue/catalog_table_test.go b/internal/service/glue/catalog_table_test.go index 9cf56d2a04d..99adb7fdc87 100644 --- a/internal/service/glue/catalog_table_test.go +++ b/internal/service/glue/catalog_table_test.go @@ -196,6 +196,7 @@ func TestAccGlueCatalogTable_Update_addValues(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrDescription, description), resource.TestCheckResourceAttr(resourceName, names.AttrOwner, "my_owner"), resource.TestCheckResourceAttr(resourceName, "retention", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.additional_locations.0", "my_additional_locations"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.name", "my_column_1"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.type", "int"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.comment", "my_column1_comment"), @@ -256,6 +257,7 @@ func TestAccGlueCatalogTable_Update_replaceValues(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrDescription, description), resource.TestCheckResourceAttr(resourceName, names.AttrOwner, "my_owner"), resource.TestCheckResourceAttr(resourceName, "retention", acctest.Ct1), + resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.additional_locations.0", "my_additional_locations"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.name", "my_column_1"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.type", "int"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.comment", "my_column1_comment"), @@ -305,6 +307,7 @@ func TestAccGlueCatalogTable_Update_replaceValues(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "A test table from terraform2"), resource.TestCheckResourceAttr(resourceName, names.AttrOwner, "my_owner2"), resource.TestCheckResourceAttr(resourceName, "retention", acctest.Ct2), + resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.additional_locations.0", "my_additional_locations2"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.name", "my_column_12"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.type", "date"), resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.0.comment", "my_column1_comment2"), @@ -850,7 +853,7 @@ resource "aws_glue_catalog_table" "test" { "bucket_column_12", "bucket_column_2", ] - + additional_locations = ["my_additional_locations2"] compressed = true input_format = "TextInputFormat" location = "my_location2" From a05b02f5970fd02efbedce931d809559ebf473dc Mon Sep 17 00:00:00 2001 From: nikhil Date: Sat, 8 Jun 2024 13:43:26 +0100 Subject: [PATCH 3/6] additional location support --- .changelog/37891.txt | 3 +++ website/docs/r/glue_catalog_table.html.markdown | 1 + 2 files changed, 4 insertions(+) create mode 100644 .changelog/37891.txt diff --git a/.changelog/37891.txt b/.changelog/37891.txt new file mode 100644 index 00000000000..ca3a839ba63 --- /dev/null +++ b/.changelog/37891.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_glue_catalog_table: Add `additional_locations` argument in `storage_descriptor` +``` \ No newline at end of file diff --git a/website/docs/r/glue_catalog_table.html.markdown b/website/docs/r/glue_catalog_table.html.markdown index 6773b76b049..b3e69f303d3 100644 --- a/website/docs/r/glue_catalog_table.html.markdown +++ b/website/docs/r/glue_catalog_table.html.markdown @@ -135,6 +135,7 @@ To add an index to an existing table, see the [`glue_partition_index` resource]( ### storage_descriptor +* `additional_locations` - (Optional) list of locations that point to the path where a Delta table is located. * `bucket_columns` - (Optional) List of reducer grouping columns, clustering columns, and bucketing columns in the table. * `columns` - (Optional) Configuration block for columns in the table. See [`columns`](#columns) below. * `compressed` - (Optional) Whether the data in the table is compressed. From e331654b32e5ddcf9af52496fa455c972adc5486 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Fri, 14 Jun 2024 10:24:33 -0500 Subject: [PATCH 4/6] aws_glue_catalog_table: add additional_locations to data source --- internal/service/glue/catalog_table_data_source.go | 5 +++++ website/docs/d/glue_catalog_table.html.markdown | 1 + website/docs/r/glue_catalog_table.html.markdown | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/service/glue/catalog_table_data_source.go b/internal/service/glue/catalog_table_data_source.go index b767e2bf39e..2d8c5accdad 100644 --- a/internal/service/glue/catalog_table_data_source.go +++ b/internal/service/glue/catalog_table_data_source.go @@ -117,6 +117,11 @@ func DataSourceCatalogTable() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "additional_locations": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, "bucket_columns": { Type: schema.TypeList, Computed: true, diff --git a/website/docs/d/glue_catalog_table.html.markdown b/website/docs/d/glue_catalog_table.html.markdown index d318a39870c..efe784b8f8b 100644 --- a/website/docs/d/glue_catalog_table.html.markdown +++ b/website/docs/d/glue_catalog_table.html.markdown @@ -60,6 +60,7 @@ This data source exports the following attributes in addition to the arguments a ### storage_descriptor +* `additional_locations` - List of locations that point to the path where a Delta table is located * `bucket_columns` - List of reducer grouping columns, clustering columns, and bucketing columns in the table. * `columns` - Configuration block for columns in the table. See [`columns`](#columns) below. * `compressed` - Whether the data in the table is compressed. diff --git a/website/docs/r/glue_catalog_table.html.markdown b/website/docs/r/glue_catalog_table.html.markdown index b3e69f303d3..878c6204938 100644 --- a/website/docs/r/glue_catalog_table.html.markdown +++ b/website/docs/r/glue_catalog_table.html.markdown @@ -135,7 +135,7 @@ To add an index to an existing table, see the [`glue_partition_index` resource]( ### storage_descriptor -* `additional_locations` - (Optional) list of locations that point to the path where a Delta table is located. +* `additional_locations` - (Optional) List of locations that point to the path where a Delta table is located. * `bucket_columns` - (Optional) List of reducer grouping columns, clustering columns, and bucketing columns in the table. * `columns` - (Optional) Configuration block for columns in the table. See [`columns`](#columns) below. * `compressed` - (Optional) Whether the data in the table is compressed. From deb343eab962cf68b6214e338a67614548ad6c3a Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Fri, 14 Jun 2024 10:26:09 -0500 Subject: [PATCH 5/6] update CHANGELOG --- .changelog/37891.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.changelog/37891.txt b/.changelog/37891.txt index ca3a839ba63..e6a83321f4e 100644 --- a/.changelog/37891.txt +++ b/.changelog/37891.txt @@ -1,3 +1,7 @@ ```release-note:enhancement resource/aws_glue_catalog_table: Add `additional_locations` argument in `storage_descriptor` +``` + +```release-note:enhancement +data-source/aws_glue_catalog_table: Add `additional_locations` argument in `storage_descriptor` ``` \ No newline at end of file From 26da0f498ed6e1b27332df1bea0f2c832e71675e Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Fri, 14 Jun 2024 10:37:21 -0500 Subject: [PATCH 6/6] aws_glue_catalog_table: update test to use s3 bucket dependency --- internal/service/glue/catalog_table_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/glue/catalog_table_test.go b/internal/service/glue/catalog_table_test.go index 99adb7fdc87..6763e2d4fa9 100644 --- a/internal/service/glue/catalog_table_test.go +++ b/internal/service/glue/catalog_table_test.go @@ -1473,7 +1473,7 @@ resource "aws_glue_catalog_table" "test" { } storage_descriptor { - location = "s3://%[1]s/files/" + location = "s3://${aws_s3_bucket.bucket.bucket}/files/" columns { name = "my_column_1"