Skip to content

Commit d852eea

Browse files
authored
Merge branch 'main' into fix-index-extension-dtypes
2 parents 72ad3c1 + b3c5676 commit d852eea

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

awswrangler/quicksight/_create.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ def _generate_permissions(
9898

9999

100100
def _generate_transformations(
101-
rename_columns: Optional[Dict[str, str]], cast_columns_types: Optional[Dict[str, str]]
101+
rename_columns: Optional[Dict[str, str]],
102+
cast_columns_types: Optional[Dict[str, str]],
103+
tag_columns: Optional[Dict[str, str]],
102104
) -> List[Dict[str, Dict[str, Any]]]:
103105
trans: List[Dict[str, Dict[str, Any]]] = []
104106
if rename_columns is not None:
@@ -107,6 +109,9 @@ def _generate_transformations(
107109
if cast_columns_types is not None:
108110
for k, v in cast_columns_types.items():
109111
trans.append({"CastColumnTypeOperation": {"ColumnName": k, "NewColumnType": v.upper()}})
112+
if tag_columns is not None:
113+
for k, v in tag_columns.items():
114+
trans.append({"TagColumnOperation": {"ColumnName": k, "Tags": v}})
110115
return trans
111116

112117

@@ -204,6 +209,7 @@ def create_athena_dataset(
204209
logical_table_alias: str = "LogicalTable",
205210
rename_columns: Optional[Dict[str, str]] = None,
206211
cast_columns_types: Optional[Dict[str, str]] = None,
212+
tag_columns: Optional[Dict[str, str]] = None,
207213
tags: Optional[Dict[str, str]] = None,
208214
account_id: Optional[str] = None,
209215
boto3_session: Optional[boto3.Session] = None,
@@ -245,7 +251,7 @@ def create_athena_dataset(
245251
'SPICE'|'DIRECT_QUERY'
246252
tags : Dict[str, str], optional
247253
Key/Value collection to put on the Cluster.
248-
e.g. {"foo": "boo", "bar": "xoo"})
254+
e.g. {"foo": "boo", "bar": "xoo"}
249255
allowed_to_use : optional
250256
List of usernames that will be allowed to see and use the data source.
251257
e.g. ["john", "Mary"]
@@ -259,6 +265,11 @@ def create_athena_dataset(
259265
cast_columns_types : Dict[str, str], optional
260266
Dictionary to map column casts. e.g. {"col_name": "STRING", "col_name2": "DECIMAL"}
261267
Valid types: 'STRING'|'INTEGER'|'DECIMAL'|'DATETIME'
268+
tag_columns : Dict[str, str], optional
269+
Dictionary to map column tags.
270+
e.g. {"col_name": [{ "ColumnGeographicRole": "CITY" }],
271+
"col_name2": [{ "ColumnDescription": { "Text": "description" }}]}
272+
Valid geospatial roles: 'COUNTRY'|'STATE'|'COUNTY'|'CITY'|'POSTCODE'|'LONGITUDE'|'LATITUDE'
262273
account_id : str, optional
263274
If None, the account ID will be inferred from your boto3 session.
264275
boto3_session : boto3.Session(), optional
@@ -335,7 +346,7 @@ def create_athena_dataset(
335346
"LogicalTableMap": {table_uuid: {"Alias": logical_table_alias, "Source": {"PhysicalTableId": table_uuid}}},
336347
}
337348
trans: List[Dict[str, Dict[str, Any]]] = _generate_transformations(
338-
rename_columns=rename_columns, cast_columns_types=cast_columns_types
349+
rename_columns=rename_columns, cast_columns_types=cast_columns_types, tag_columns=tag_columns
339350
)
340351
if trans:
341352
args["LogicalTableMap"][table_uuid]["DataTransforms"] = trans

tests/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_df(governed=False):
2828
"ddouble": [0.0, None, 1.1],
2929
"decimal": [Decimal((0, (1, 9, 9), -2)), None, Decimal((0, (1, 9, 0), -2))],
3030
"string_object": ["foo", None, "boo"],
31-
"string": ["foo", None, "boo"],
31+
"string": ["Seattle", None, "Washington"],
3232
"date": [dt("2020-01-01"), None, dt("2020-01-02")],
3333
"timestamp": [ts("2020-01-01 00:00:00.0"), None, ts("2020-01-02 00:00:01.0")],
3434
"bool": [True, None, False],

tests/test_quicksight.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def test_quicksight(path, glue_database, glue_table):
3737
allowed_to_manage=[wr.sts.get_current_identity_name()],
3838
rename_columns={"iint16": "new_col"},
3939
cast_columns_types={"new_col": "STRING"},
40+
tag_columns={"string": [{"ColumnGeographicRole": "CITY"}, {"ColumnDescription": {"Text": "some description"}}]},
4041
)
4142
assert wr.quicksight.describe_dataset("test-table")["Name"] == "test-table"
4243

@@ -49,6 +50,7 @@ def test_quicksight(path, glue_database, glue_table):
4950
allowed_to_manage=[wr.sts.get_current_identity_name()],
5051
rename_columns={"iint16": "new_col"},
5152
cast_columns_types={"new_col": "STRING"},
53+
tag_columns={"string": [{"ColumnGeographicRole": "CITY"}, {"ColumnDescription": {"Text": "some description"}}]},
5254
tags={"foo": "boo"},
5355
)
5456

tutorials/018 - QuickSight.ipynb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,9 @@
12421242
" cast_columns_types={\n",
12431243
" \"Count_of_Cases\": \"INTEGER\"\n",
12441244
" },\n",
1245+
" tag_columns={\n",
1246+
" \"combined_key\": [{\"ColumnGeographicRole\": \"COUNTY\"}]\n",
1247+
" },\n",
12451248
" allowed_to_manage=[\"dev\"]\n",
12461249
")"
12471250
]

0 commit comments

Comments
 (0)