-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmeasure.py
94 lines (71 loc) · 2.11 KB
/
measure.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from __future__ import annotations
from abc import abstractmethod
from typing import Optional, Protocol, Sequence
from dbt_semantic_interfaces.references import MeasureReference
from dbt_semantic_interfaces.type_enums import AggregationType
class NonAdditiveDimensionParameters(Protocol):
"""Describes the params for specifying non-additive dimensions in a measure."""
@property
@abstractmethod
def name(self) -> str: # noqa: D
pass
@property
@abstractmethod
def window_choice(self) -> AggregationType: # noqa: D
pass
@property
@abstractmethod
def window_groupings(self) -> Sequence[str]: # noqa: D
pass
class MeasureAggregationParameters(Protocol):
"""Describes parameters for aggregations."""
@property
@abstractmethod
def percentile(self) -> Optional[float]: # noqa: D
pass
@property
@abstractmethod
def use_discrete_percentile(self) -> bool: # noqa: D
pass
@property
@abstractmethod
def use_approximate_percentile(self) -> bool: # noqa: D
pass
class Measure(Protocol):
"""Describes a measure.
Measure is a field in the underlying semantic model that can be aggregated
in a specific way.
"""
@property
@abstractmethod
def name(self) -> str: # noqa: D
pass
@property
@abstractmethod
def agg(self) -> AggregationType: # noqa: D
pass
@property
@abstractmethod
def description(self) -> Optional[str]: # noqa: D
pass
@property
@abstractmethod
def expr(self) -> Optional[str]: # noqa: D
pass
@property
@abstractmethod
def agg_params(self) -> Optional[MeasureAggregationParameters]: # noqa: D
pass
@property
@abstractmethod
def non_additive_dimension(self) -> Optional[NonAdditiveDimensionParameters]: # noqa: D
pass
@property
@abstractmethod
def agg_time_dimension(self) -> Optional[str]: # noqa: D
pass
@property
@abstractmethod
def reference(self) -> MeasureReference:
"""Returns a reference to this measure."""
...