Skip to content

Commit

Permalink
better col management (#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov-aws authored Apr 25, 2024
1 parent dbeba59 commit 7035434
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cid/helpers/cur.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging

from cid.base import CidBase
from cid.utils import get_parameter, get_parameters
from cid.utils import get_parameter, get_parameters, cid_print
from cid.exceptions import CidCritical

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -135,8 +135,9 @@ def ensure_column(self, column: str, column_type: str=None):
self.athena.query(f'ALTER TABLE {self.table_name} ADD COLUMNS ({column} {column_type})')
except (self.athena.client.exceptions.ClientError, CidCritical) as exc:
raise CidCritical(f'Column {column} is not found in CUR and we were unable to add it. Please check FAQ.') from exc
self._metadata = self.athena.get_table_metadata(self.table_name) # refresh table metadata
logger.critical(f"Column '{column}' was added to CUR ({self.table_name}). Please make sure crawler do not override that columns. Crawler='{crawler_name}'")
# table takes time to update so just adding column to cached data
self._metadata.get('Columns', []).append({'Name': column, 'Type': column_type})
cid_print(f"Column '{column}' was added to CUR ({self.table_name}).")
return

# if table cannot be updated, check if it is ri/sp case - let's hope dashboard views can handle it:
Expand All @@ -145,7 +146,7 @@ def ensure_column(self, column: str, column_type: str=None):
return

# if a required column is not there and not ri/sp -> stop
logger.critical(f"Column '{column}' is not in ({self.table_name}). Cannot continue")
logger.critical(f"Column '{column}' is not in ({self.table_name}). Cannot continue.")


def table_is_cur(self, table: dict=None, name: str=None, return_reason: bool=False) -> bool:
Expand Down

0 comments on commit 7035434

Please sign in to comment.