Skip to content

Commit

Permalink
Use safe_float in UC profiler to avoid outputting INF in MCEs (#923)
Browse files Browse the repository at this point in the history
* Use safe_float in UC profiler to avoid outputting INF in MCEs

* Improve log messages
  • Loading branch information
mars-lan authored Jul 22, 2024
1 parent b42c7a8 commit f5400e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions metaphor/unity_catalog/profile/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from metaphor.common.entity_id import normalize_full_dataset_name
from metaphor.common.event_util import ENTITY_TYPES
from metaphor.common.logger import get_logger
from metaphor.common.utils import safe_float
from metaphor.models.crawler_run_metadata import Platform
from metaphor.models.metadata_change_event import (
DataPlatform,
Expand Down Expand Up @@ -259,7 +260,7 @@ def get_value_from_row(key: str) -> Optional[float]:
if value:
if value == "NULL":
return None
return float(value)
return safe_float(value)
return value

stats = FieldStatistics(
Expand All @@ -272,7 +273,10 @@ def get_value_from_row(key: str) -> Optional[float]:
field_statistics.field_statistics.append(stats)

logger.info(
f"Profiled {table_info.full_name}, {dataset_statistics.data_size_bytes}, {dataset_statistics.record_count}, {time.time() - start_time} seconds"
f"Profiled {table_info.full_name} "
f"({dataset_statistics.data_size_bytes:.0f} bytes, "
f"{dataset_statistics.record_count:.0f} rows) "
f"in {(time.time() - start_time):.1f} seconds"
)

return (
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "metaphor-connectors"
version = "0.14.53"
version = "0.14.54"
license = "Apache-2.0"
description = "A collection of Python-based 'connectors' that extract metadata from various sources to ingest into the Metaphor app."
authors = ["Metaphor <[email protected]>"]
Expand Down

0 comments on commit f5400e3

Please sign in to comment.