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
3 changes: 3 additions & 0 deletions .changelog/45336.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_glue_catalog_table: Added new fields available in the Glue API for ViewDefinition.
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/gamelift v1.48.4
github.com/aws/aws-sdk-go-v2/service/glacier v1.31.14
github.com/aws/aws-sdk-go-v2/service/globalaccelerator v1.35.7
github.com/aws/aws-sdk-go-v2/service/glue v1.134.1
github.com/aws/aws-sdk-go-v2/service/glue v1.135.0
github.com/aws/aws-sdk-go-v2/service/grafana v1.32.7
github.com/aws/aws-sdk-go-v2/service/greengrass v1.32.14
github.com/aws/aws-sdk-go-v2/service/groundstation v1.39.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ github.com/aws/aws-sdk-go-v2/service/glacier v1.31.14 h1:Cx3HCHS8jPUp0hyO0oY/95x
github.com/aws/aws-sdk-go-v2/service/glacier v1.31.14/go.mod h1:JAN67uxabv+RUAJc8eri9awt0AxZQDAiqLkqsN8NEGo=
github.com/aws/aws-sdk-go-v2/service/globalaccelerator v1.35.7 h1:cZOCclunBQnCN5/vwEtYgVfSvlrzOSO7h10CP2HZNFU=
github.com/aws/aws-sdk-go-v2/service/globalaccelerator v1.35.7/go.mod h1:q6V0mPl64Zt6BSgnurs0XKRHT3v6JxMiyw9dAxUfJBM=
github.com/aws/aws-sdk-go-v2/service/glue v1.134.1 h1:tmPNUUD0614ee3Hfn/5N2p0UElJuzYo6qr9H8LYDwp4=
github.com/aws/aws-sdk-go-v2/service/glue v1.134.1/go.mod h1:2yxIwUNUUoAcN7xlsrkAH4zcT79XFY6lcjc1V8i1ATg=
github.com/aws/aws-sdk-go-v2/service/glue v1.135.0 h1:eIJmjEBRzPtB7zSS9ZIVlFWKYGk0EW9jMHqJ76JlpsQ=
github.com/aws/aws-sdk-go-v2/service/glue v1.135.0/go.mod h1:2yxIwUNUUoAcN7xlsrkAH4zcT79XFY6lcjc1V8i1ATg=
github.com/aws/aws-sdk-go-v2/service/grafana v1.32.7 h1:iGbPcSuQlx+N8YGu/wv4C4ExDyTI5yF4pFn78Ma7u9U=
github.com/aws/aws-sdk-go-v2/service/grafana v1.32.7/go.mod h1:n4lKemL6oAceu5oaWqZey4Cz4nSBut3ZK3dVC0SzovQ=
github.com/aws/aws-sdk-go-v2/service/greengrass v1.32.14 h1:9sZssrJvVKefhbeCaE5/W186sxzD8BO+eUIKuMZmV0o=
Expand Down
146 changes: 146 additions & 0 deletions internal/service/glue/catalog_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,90 @@ func resourceCatalogTable() *schema.Resource {
},
},
},
"view_definition": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"representations": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"dialect": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"REDSHIFT",
"ATHENA",
"SPARK",
}, false),
},
"dialect_version": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringLenBetween(1, 255),
},
"validation_connection": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringLenBetween(1, 255),
},
"view_original_text": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringLenBetween(0, 409600),
},
"view_expanded_text": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringLenBetween(0, 409600),
},
},
},
},
"is_protected": {
Type: schema.TypeBool,
Optional: true,
},
"definer": {
Type: schema.TypeString,
Optional: true,
},
"sub_objects": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"sub_object_version_ids": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeInt},
},
"view_version_id": {
Type: schema.TypeInt,
Optional: true,
},
"view_version_token": {
Type: schema.TypeString,
Optional: true,
},
"last_refresh_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"FULL",
"INCREMENTAL",
}, false),
},
"refresh_seconds": {
Type: schema.TypeInt,
Optional: true,
},
},
},
},
},
}
}
Expand Down Expand Up @@ -659,6 +743,10 @@ func expandTableInput(d *schema.ResourceData) *awstypes.TableInput {
tableInput.TargetTable = expandTableTargetTable(v.([]any)[0].(map[string]any))
}

if v, ok := d.GetOk("view_definition"); ok {
tableInput.ViewDefinition = expandViewDefinition(v.([]any))
}

return tableInput
}

Expand Down Expand Up @@ -1172,3 +1260,61 @@ func flattenNonManagedParameters(table *awstypes.Table) map[string]string {
}
return allParameters
}

func expandViewDefinition(l []any) *awstypes.ViewDefinitionInput {
if len(l) == 0 || l[0] == nil {
return nil
}

s := l[0].(map[string]any)
viewDefinition := &awstypes.ViewDefinitionInput{}

if v, ok := s["definer"]; ok && v != nil && v != "" {
viewDefinition.Definer = aws.String(v.(string))
}

if v, ok := s["is_protected"]; ok && v != nil && v != "" {
viewDefinition.IsProtected = aws.Bool(v.(bool))
}

if v, ok := s["representations"]; ok && v != nil {
viewDefinition.Representations = expandViewRepresentationInput(v.([]any))
}

if v, ok := s["sub_objects"]; ok && v != nil {
viewDefinition.SubObjects = flex.ExpandStringValueList(v.([]any))
}

return viewDefinition
}

func expandViewRepresentationInput(l []any) []awstypes.ViewRepresentationInput {
if len(l) == 0 || l[0] == nil {
return nil
}

s := l[0].(map[string]any)
viewRepresentationInput := awstypes.ViewRepresentationInput{}

if v, ok := s["dialect"]; ok && v != nil && v != "" {
viewRepresentationInput.Dialect = awstypes.ViewDialect(v.(string))
}

if v, ok := s["dialect_version"]; ok && v != nil && v != "" {
viewRepresentationInput.DialectVersion = aws.String(v.(string))
}

if v, ok := s["validation_connection"]; ok && v != nil && v != "" {
viewRepresentationInput.ValidationConnection = aws.String(v.(string))
}

if v, ok := s["view_expanded_text"]; ok && v != nil && v != "" {
viewRepresentationInput.ViewExpandedText = aws.String(v.(string))
}

if v, ok := s["view_original_text"]; ok && v != nil && v != "" {
viewRepresentationInput.ViewOriginalText = aws.String(v.(string))
}

return []awstypes.ViewRepresentationInput{viewRepresentationInput}
}
Loading