Skip to content

Commit

Permalink
Merge pull request #37891 from nikhil-goenka/f/aws_glue_catalog_table
Browse files Browse the repository at this point in the history
F/aws glue catalog table
  • Loading branch information
johnsonaj authored Jun 14, 2024
2 parents 23a2c1b + 26da0f4 commit 46b15e9
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changelog/37891.txt
Original file line number Diff line number Diff line change
@@ -0,0 +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`
```
10 changes: 10 additions & 0 deletions internal/service/glue/catalog_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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{}))
}
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions internal/service/glue/catalog_table_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions internal/service/glue/catalog_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -195,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"),
Expand Down Expand Up @@ -255,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"),
Expand Down Expand Up @@ -304,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"),
Expand Down Expand Up @@ -754,6 +758,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"
Expand Down Expand Up @@ -848,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"
Expand Down Expand Up @@ -1468,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"
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/glue_catalog_table.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/glue_catalog_table.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 46b15e9

Please sign in to comment.