Skip to content

Commit 32bf2c7

Browse files
authored
ignore tables on export (aws-solutions-library-samples#1310)
1 parent 7f5014e commit 32bf2c7

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

cid/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def export(ctx, **kwargs):
167167
(definition|template) A method (definition=pull json definition of Analysis OR template=create QuickSight Template)
168168
--export-known-datasets
169169
(no|yes) If 'yes' the export will include DataSets that are already in resources file. Default = no
170+
--export-tables (no|yes). If 'yes' the export will include Tables. Default: no = only Views
170171
--category TEXT The dashboards category. Default = Custom
171172
--output A filename (.yaml) If provided an existing file it will be analyzed for default values and overridden
172173
"""

cid/export.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ def export_analysis(qs, athena, glue):
144144

145145
cid_print(f' Found DataSet <BOLD>{dataset_name}<END>.')
146146
if dataset_name in athena._resources.get('datasets'):
147-
resources_datasets.append(dataset_name)
148-
if not get_parameters().get('export-known-datasets'):
147+
resources_datasets.append(dataset_name) # used later in dependencies
148+
if not get_parameters().get('export-known-datasets') == 'yes':
149149
cid_print(f' DataSet <BOLD>{dataset_name}<END> is in resources. Skipping.')
150-
continue
150+
continue # prevent export dataset
151151

152152
dataset_data = {
153153
"DataSetId": dataset.raw['DataSetId'],
@@ -284,7 +284,13 @@ def export_analysis(qs, athena, glue):
284284
if key in cur_tables or cur_helper.table_is_cur(name=key):
285285
logger.debug(f'Skipping {key} views - it is a CUR')
286286
continue
287+
if key in ['account_map']:
288+
cid_print(f'{key} is a special data. Processed separately. Skipping.')
289+
continue
287290
if isinstance(view_data.get('data'), str):
291+
if 'CREATE EXTERNAL TABLE' in view_data.get('data') and not get_parameters().get('export-tables') == 'yes':
292+
cid_print(f'{key} is a Glue table. Skipping. To export table definitions use `--export-tables yes`')
293+
continue
288294
#check if there is dependency on crawler
289295
crawler_names = re.findall(r"UPDATED_BY_CRAWLER\W+?'(.+?)''", view_data.get('data'))
290296
if crawler_names:

0 commit comments

Comments
 (0)