Skip to content

Commit

Permalink
fix(ingest/redshift): avoid asserts in redshift schemas
Browse files Browse the repository at this point in the history
The `assert rows` lines would fail if rows=0.
  • Loading branch information
hsheth2 committed Aug 21, 2024
1 parent 4e35016 commit ee06c04
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,23 +313,19 @@ def get_table_stats(enriched_tables, field_names, schema, table):
size_in_bytes: Optional[int] = None
rows_count: Optional[int] = None
if schema in enriched_tables and table_name in enriched_tables[schema]:
if enriched_tables[schema][table_name].last_accessed is not None:
# Mypy seems to be not clever enough to understand the above check
last_accessed = enriched_tables[schema][table_name].last_accessed
assert last_accessed
if (
last_accessed := enriched_tables[schema][table_name].last_accessed
) is not None:
last_altered = last_accessed.replace(tzinfo=timezone.utc)
elif creation_time:
last_altered = creation_time

if enriched_tables[schema][table_name].size is not None:
# Mypy seems to be not clever enough to understand the above check
size = enriched_tables[schema][table_name].size
if size:
size_in_bytes = size * 1024 * 1024
if (size := enriched_tables[schema][table_name].size) is not None:
size_in_bytes = size * 1024 * 1024

if enriched_tables[schema][table_name].estimated_visible_rows is not None:
rows = enriched_tables[schema][table_name].estimated_visible_rows
assert rows
if (
rows := enriched_tables[schema][table_name].estimated_visible_rows
) is not None:
rows_count = int(rows)
else:
# The object was not found in the enriched data.
Expand Down

0 comments on commit ee06c04

Please sign in to comment.