Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Commit

Permalink
Add logging messages and bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Dec 13, 2019
1 parent 8918145 commit 9f381e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ filelock==3.0.12 # via tox
flake8==3.7.9
idna==2.8 # via requests
imagesize==1.1.0 # via sphinx
importlib-metadata==1.2.0 # via pluggy, tox
importlib-metadata==1.3.0 # via pluggy, tox
isort==4.3.21
jinja2==2.10.3 # via sphinx
markupsafe==1.1.1 # via jinja2
Expand Down
2 changes: 1 addition & 1 deletion sqltask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def transform(self) -> None:
"""
Main transformation method where target rows should be generated.
"""
raise NotImplementedError("`transform` method must be implemented")
pass

def validate(self) -> None:
"""
Expand Down
11 changes: 10 additions & 1 deletion sqltask/base/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
if TYPE_CHECKING:
from sqltask.base.engine import EngineContext

logger = logging.getLogger(__name__)


class BaseTableContext:
"""
Expand Down Expand Up @@ -113,23 +115,30 @@ def migrate_schema(self) -> None:

# add columns if not in table
if not col_existing:
logger.info(f"Add column `{column.name}` to table `{table.name}`")
self.engine_context.engine_spec.add_column(self, column)
else:
if engine_spec.supports_column_comments and \
column.comment is not None and \
col_existing["comment"] != column.comment:
# update column comment if different from current comment
logger.info(
f"Update comment on column `{column.name}` in "
f"table `{table.name}`")
engine_spec.update_column_comment(
self, column.name, column.comment)

# remove redundant columns
cols_new = {col.name: col for col in table.columns}
for column_name in cols_existing:
if column_name not in cols_new:
logger.info(
f"Remove redundant column `{column_name}` from "
f"table `{table.name}`")
self.engine_context.engine_spec.drop_column(self, column_name)
else:
# table doesn't exist, create new
logging.debug(f"Create new table `{table.name}`")
logger.debug(f"Create new table `{table.name}`")
metadata.create_all(tables=[table])

def map_all(self, row_source: BaseRowSource) -> None:
Expand Down

0 comments on commit 9f381e1

Please sign in to comment.