-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Raise/warn on incomplete columns in normalize (#1504)
* Raise/warn on incomplete columns in normalize Raise on not-nullable columns to catch e.g. misspelled merge/primary key key * Update error msg * Test for null values * Lint * Delete now invalid tests * Fix common test
- Loading branch information
Showing
8 changed files
with
113 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from dlt.common.schema import Schema | ||
from dlt.common.schema.utils import find_incomplete_columns | ||
from dlt.common.schema.exceptions import UnboundColumnException | ||
from dlt.common import logger | ||
|
||
def verify_normalized_schema(schema: Schema) -> None: | ||
"""Verify the schema is valid for next stage after normalization. | ||
1. Log warning if any incomplete nullable columns are in any data tables | ||
2. Raise `UnboundColumnException` on incomplete non-nullable columns (e.g. missing merge/primary key) | ||
""" | ||
for table_name, column, nullable in find_incomplete_columns(schema.data_tables(seen_data_only=True)): | ||
exc = UnboundColumnException(schema.name, table_name, column) | ||
if nullable: | ||
logger.warning(str(exc)) | ||
else: | ||
raise exc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters