Skip to content

Commit

Permalink
Merge pull request #19742 from DrFaust92/r/glue_table_schema_colums
Browse files Browse the repository at this point in the history
r/glue_catalog_table - fix update for `schema_reference`
  • Loading branch information
ewbankkit authored Jun 22, 2021
2 parents 72df092 + 36ddac2 commit 49fd2ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/19742.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_glue_catalog_table: Fix updating `schema_reference` when columns are present.
```
3 changes: 2 additions & 1 deletion aws/resource_aws_glue_catalog_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,8 @@ func expandGlueStorageDescriptor(l []interface{}) *glue.StorageDescriptor {
storageDescriptor.StoredAsSubDirectories = aws.Bool(v.(bool))
}

if v, ok := s["schema_reference"]; ok {
if v, ok := s["schema_reference"]; ok && len(v.([]interface{})) > 0 {
storageDescriptor.Columns = nil
storageDescriptor.SchemaReference = expandGlueTableSchemaReference(v.([]interface{}))
}

Expand Down
11 changes: 11 additions & 0 deletions aws/resource_aws_glue_catalog_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,17 @@ func TestAccAWSGlueCatalogTable_StorageDescriptor_schemaReference(t *testing.T)
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccGlueCatalogTableConfigStorageDescriptorSchemaReferenceArn(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckGlueCatalogTableExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.schema_reference.#", "1"),
resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.schema_reference.0.schema_version_number", "1"),
resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.schema_reference.0.schema_id.#", "1"),
resource.TestCheckResourceAttrPair(resourceName, "storage_descriptor.0.schema_reference.0.schema_id.0.schema_arn", "aws_glue_schema.test", "arn"),
resource.TestCheckResourceAttr(resourceName, "storage_descriptor.0.columns.#", "2"),
),
},
},
})
}
Expand Down

0 comments on commit 49fd2ae

Please sign in to comment.