Skip to content

Commit

Permalink
New Datasource aws_quicksight_data_set (#30422)
Browse files Browse the repository at this point in the history
* New Datasource aws_quicksight_data_set

* Changelog entry

* Fix linter issues

* d/aws_quicksight_data_set: test cleanup

* d/aws_quicksight_data_set: use flex string list flattener

---------

Co-authored-by: Jared Baker <jared.baker@hashicorp.com>
  • Loading branch information
comtef and jar-b authored Apr 4, 2023
1 parent c9ef828 commit b182364
Show file tree
Hide file tree
Showing 6 changed files with 816 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .changelog/30422.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-data-source
aws_quicksight_data_set
```
14 changes: 7 additions & 7 deletions internal/service/quicksight/data_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,11 +870,11 @@ func resourceDataSetRead(ctx context.Context, d *schema.ResourceData, meta inter
return diag.Errorf("error setting field_folders: %s", err)
}

if err := d.Set("logical_table_map", flattenLogicalTableMap(dataSet.LogicalTableMap)); err != nil {
if err := d.Set("logical_table_map", flattenLogicalTableMap(dataSet.LogicalTableMap, logicalTableMapSchema())); err != nil {
return diag.Errorf("error setting logical_table_map: %s", err)
}

if err := d.Set("physical_table_map", flattenPhysicalTableMap(dataSet.PhysicalTableMap)); err != nil {
if err := d.Set("physical_table_map", flattenPhysicalTableMap(dataSet.PhysicalTableMap, physicalTableMapSchema())); err != nil {
return diag.Errorf("error setting physical_table_map: %s", err)
}

Expand Down Expand Up @@ -1928,7 +1928,7 @@ func fieldFoldersHash(v interface{}) int {
return create.StringHashcode(buf.String())
}

func flattenLogicalTableMap(apiObject map[string]*quicksight.LogicalTable) *schema.Set {
func flattenLogicalTableMap(apiObject map[string]*quicksight.LogicalTable, resourceSchema *schema.Resource) *schema.Set {
if len(apiObject) == 0 {
return nil
}
Expand All @@ -1954,7 +1954,7 @@ func flattenLogicalTableMap(apiObject map[string]*quicksight.LogicalTable) *sche
tfList = append(tfList, tfMap)
}

return schema.NewSet(schema.HashResource(logicalTableMapSchema()), tfList)
return schema.NewSet(schema.HashResource(resourceSchema), tfList)
}

func flattenDataTransforms(apiObject []*quicksight.TransformOperation) []interface{} {
Expand Down Expand Up @@ -2076,7 +2076,7 @@ func flattenProjectOperation(apiObject *quicksight.ProjectOperation) []interface

tfMap := map[string]interface{}{}
if apiObject.ProjectedColumns != nil {
tfMap["project_columns"] = aws.StringValueSlice(apiObject.ProjectedColumns)
tfMap["projected_columns"] = flex.FlattenStringList(apiObject.ProjectedColumns)
}

return []interface{}{tfMap}
Expand Down Expand Up @@ -2228,7 +2228,7 @@ func flattenJoinKeyProperties(apiObject *quicksight.JoinKeyProperties) map[strin
return tfMap
}

func flattenPhysicalTableMap(apiObject map[string]*quicksight.PhysicalTable) *schema.Set {
func flattenPhysicalTableMap(apiObject map[string]*quicksight.PhysicalTable, resourceSchema *schema.Resource) *schema.Set {
if len(apiObject) == 0 {
return nil
}
Expand All @@ -2254,7 +2254,7 @@ func flattenPhysicalTableMap(apiObject map[string]*quicksight.PhysicalTable) *sc
tfList = append(tfList, tfMap)
}

return schema.NewSet(schema.HashResource(physicalTableMapSchema()), tfList)
return schema.NewSet(schema.HashResource(resourceSchema), tfList)
}

func flattenCustomSQL(apiObject *quicksight.CustomSql) []interface{} {
Expand Down
Loading

0 comments on commit b182364

Please sign in to comment.