Skip to content

Commit 1108029

Browse files
authored
fix cur database selection (#1335)
* fix cur database selection * Add cur-database option to deploy and update commands
1 parent 9608fa8 commit 1108029

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

cid/helpers/cur.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,18 +248,18 @@ def set_cur(self, database: str=None, table: str=None):
248248
def find_cur(self, database: str=None, table: str=None):
249249
"""Choose CUR"""
250250
metadata = None
251-
cur_database = database or get_parameters().get('cur-database') or self.athena.DatabaseName
251+
cur_database = database or get_parameters().get('cur-database')
252252
if not table and get_parameters().get('cur-table-name') and ',' not in str(get_parameters().get('cur-table-name')):
253253
table = get_parameters().get('cur-table-name')
254-
if table: # Table sepcified explicity, so no need to scan. Just need to make sure the table exists
254+
if table: # Table specified explicitly, so no need to scan. Just need to make sure the table exists
255255
try:
256-
metadata = self.athena.get_table_metadata(table, cur_database)
256+
metadata = self.athena.get_table_metadata(table, cur_database or self.athena.DatabaseName)
257257
except self.athena.client.exceptions.MetadataException as exc:
258-
logger.debug(f'Provided cur-table-name "{table}" in database "{cur_database}" is not found. ({exc})')
259-
raise CidCritical(f'Provided cur-table-name "{table}" in database "{cur_database}" is not found. Please make sure the table exists. This could also indicate a LakeFormation permission issue, see our FAQ for help.')
258+
logger.debug(f'Provided cur-table-name "{table}" in database "{cur_database or self.athena.DatabaseName}" is not found. ({exc})')
259+
raise CidCritical(f'Provided cur-table-name "{table}" in database "{cur_database or self.athena.DatabaseName}" is not found. Please make sure the table exists. This could also indicate a LakeFormation permission issue, see our FAQ for help.')
260260
res, message = self.table_is_cur(table=metadata, return_reason=True)
261261
if not res:
262-
raise CidCritical(f'Provided cur-table-name "{table}" in database "{cur_database}" is not cur. {message}')
262+
raise CidCritical(f'Provided cur-table-name "{table}" in database "{cur_database or self.athena.DatabaseName}" is not cur. {message}')
263263
return cur_database, metadata
264264

265265
all_cur_tables = []

cid/test/bats/10-deploy-update-delete/cudos.bats

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ cur_table="${cur_table:-cur1}" # If variable not set or null, use default. FIXME
1313
--dashboard-id cudos-v5 \
1414
--athena-database $database_name\
1515
--account-map-source dummy \
16+
--cur-database $database_name \
1617
--cur-table-name $cur_table \
1718
--athena-workgroup primary\
1819
--quicksight-user $quicksight_user \
@@ -60,6 +61,7 @@ cur_table="${cur_table:-cur1}" # If variable not set or null, use default. FIXME
6061
@test "Update works" {
6162
run cid-cmd -vv --yes update --force --recursive \
6263
--dashboard-id cudos-v5 \
64+
--cur-database $database_name \
6365
--cur-table-name $cur_table \
6466
--athena-database $database_name\
6567
--athena-workgroup primary\
@@ -105,4 +107,4 @@ cur_table="${cur_table:-cur1}" # If variable not set or null, use default. FIXME
105107
--table-name 'summary_view'
106108

107109
[ "$status" -ne 0 ]
108-
}
110+
}

0 commit comments

Comments
 (0)