@@ -98,7 +98,9 @@ def _generate_permissions(
98
98
99
99
100
100
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 ]],
102
104
) -> List [Dict [str , Dict [str , Any ]]]:
103
105
trans : List [Dict [str , Dict [str , Any ]]] = []
104
106
if rename_columns is not None :
@@ -107,6 +109,9 @@ def _generate_transformations(
107
109
if cast_columns_types is not None :
108
110
for k , v in cast_columns_types .items ():
109
111
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 }})
110
115
return trans
111
116
112
117
@@ -204,6 +209,7 @@ def create_athena_dataset(
204
209
logical_table_alias : str = "LogicalTable" ,
205
210
rename_columns : Optional [Dict [str , str ]] = None ,
206
211
cast_columns_types : Optional [Dict [str , str ]] = None ,
212
+ tag_columns : Optional [Dict [str , str ]] = None ,
207
213
tags : Optional [Dict [str , str ]] = None ,
208
214
account_id : Optional [str ] = None ,
209
215
boto3_session : Optional [boto3 .Session ] = None ,
@@ -245,7 +251,7 @@ def create_athena_dataset(
245
251
'SPICE'|'DIRECT_QUERY'
246
252
tags : Dict[str, str], optional
247
253
Key/Value collection to put on the Cluster.
248
- e.g. {"foo": "boo", "bar": "xoo"})
254
+ e.g. {"foo": "boo", "bar": "xoo"}
249
255
allowed_to_use : optional
250
256
List of usernames that will be allowed to see and use the data source.
251
257
e.g. ["john", "Mary"]
@@ -259,6 +265,11 @@ def create_athena_dataset(
259
265
cast_columns_types : Dict[str, str], optional
260
266
Dictionary to map column casts. e.g. {"col_name": "STRING", "col_name2": "DECIMAL"}
261
267
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'
262
273
account_id : str, optional
263
274
If None, the account ID will be inferred from your boto3 session.
264
275
boto3_session : boto3.Session(), optional
@@ -335,7 +346,7 @@ def create_athena_dataset(
335
346
"LogicalTableMap" : {table_uuid : {"Alias" : logical_table_alias , "Source" : {"PhysicalTableId" : table_uuid }}},
336
347
}
337
348
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
339
350
)
340
351
if trans :
341
352
args ["LogicalTableMap" ][table_uuid ]["DataTransforms" ] = trans
0 commit comments