from typing import Any
from typing import Dict
from typing import Type
from typing import TypeVar
from typing import Union
from attrs import define as _attrs_define
from ..models.metrics_boolean import MetricsBoolean
from ..models.metrics_categorical import MetricsCategorical
from ..models.metrics_numeric import MetricsNumeric
from ..models.metrics_temporal import MetricsTemporal
from ..models.metrics_text import MetricsText
from ..types import UNSET
from ..types import Unset
T = TypeVar("T", bound="ColumnStatistics")
[docs]
@_attrs_define
class ColumnStatistics:
"""ColumnStatistics model
Attributes:
distinct_count (int):
non_null_count (int):
null_count (int):
boolean (Union[Unset, MetricsBoolean]):
categorical (Union[Unset, MetricsCategorical]):
is_distinct_estimated (Union[Unset, bool]): Default: False.
numeric (Union[Unset, MetricsNumeric]):
temporal (Union[Unset, MetricsTemporal]):
text (Union[Unset, MetricsText]):
"""
distinct_count: int
non_null_count: int
null_count: int
boolean: Union[Unset, "MetricsBoolean"] = UNSET
categorical: Union[Unset, "MetricsCategorical"] = UNSET
is_distinct_estimated: Union[Unset, bool] = False
numeric: Union[Unset, "MetricsNumeric"] = UNSET
temporal: Union[Unset, "MetricsTemporal"] = UNSET
text: Union[Unset, "MetricsText"] = UNSET
[docs]
def to_dict(self) -> Dict[str, Any]:
"""Convert to a dict"""
distinct_count = self.distinct_count
non_null_count = self.non_null_count
null_count = self.null_count
boolean: Union[Unset, Dict[str, Any]] = UNSET
if not isinstance(self.boolean, Unset):
boolean = self.boolean.to_dict()
categorical: Union[Unset, Dict[str, Any]] = UNSET
if not isinstance(self.categorical, Unset):
categorical = self.categorical.to_dict()
is_distinct_estimated = self.is_distinct_estimated
numeric: Union[Unset, Dict[str, Any]] = UNSET
if not isinstance(self.numeric, Unset):
numeric = self.numeric.to_dict()
temporal: Union[Unset, Dict[str, Any]] = UNSET
if not isinstance(self.temporal, Unset):
temporal = self.temporal.to_dict()
text: Union[Unset, Dict[str, Any]] = UNSET
if not isinstance(self.text, Unset):
text = self.text.to_dict()
field_dict: Dict[str, Any] = {}
field_dict.update(
{
"distinctCount": distinct_count,
"nonNullCount": non_null_count,
"nullCount": null_count,
}
)
if boolean is not UNSET:
field_dict["boolean"] = boolean
if categorical is not UNSET:
field_dict["categorical"] = categorical
if is_distinct_estimated is not UNSET:
field_dict["isDistinctEstimated"] = is_distinct_estimated
if numeric is not UNSET:
field_dict["numeric"] = numeric
if temporal is not UNSET:
field_dict["temporal"] = temporal
if text is not UNSET:
field_dict["text"] = text
return field_dict
[docs]
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
"""Create an instance of :py:class:`ColumnStatistics` from a dict"""
d = src_dict.copy()
distinct_count = d.pop("distinctCount")
non_null_count = d.pop("nonNullCount")
null_count = d.pop("nullCount")
_boolean = d.pop("boolean", UNSET)
boolean: Union[Unset, MetricsBoolean]
if isinstance(_boolean, Unset):
boolean = UNSET
else:
boolean = MetricsBoolean.from_dict(_boolean)
_categorical = d.pop("categorical", UNSET)
categorical: Union[Unset, MetricsCategorical]
if isinstance(_categorical, Unset):
categorical = UNSET
else:
categorical = MetricsCategorical.from_dict(_categorical)
is_distinct_estimated = d.pop("isDistinctEstimated", UNSET)
_numeric = d.pop("numeric", UNSET)
numeric: Union[Unset, MetricsNumeric]
if isinstance(_numeric, Unset):
numeric = UNSET
else:
numeric = MetricsNumeric.from_dict(_numeric)
_temporal = d.pop("temporal", UNSET)
temporal: Union[Unset, MetricsTemporal]
if isinstance(_temporal, Unset):
temporal = UNSET
else:
temporal = MetricsTemporal.from_dict(_temporal)
_text = d.pop("text", UNSET)
text: Union[Unset, MetricsText]
if isinstance(_text, Unset):
text = UNSET
else:
text = MetricsText.from_dict(_text)
column_statistics = cls(
distinct_count=distinct_count,
non_null_count=non_null_count,
null_count=null_count,
boolean=boolean,
categorical=categorical,
is_distinct_estimated=is_distinct_estimated,
numeric=numeric,
temporal=temporal,
text=text,
)
return column_statistics