generator.views.operational_monitoring_alerting_view

Class to describe an Operational Monitoring Alert View.

 1"""Class to describe an Operational Monitoring Alert View."""
 2
 3from typing import Any, Dict, Optional
 4
 5from . import lookml_utils
 6from .operational_monitoring_view import OperationalMonitoringView
 7
 8
 9class OperationalMonitoringAlertingView(OperationalMonitoringView):
10    """A view on a alert operational monitoring table."""
11
12    type: str = "operational_monitoring_alerting_view"
13
14    def to_lookml(self, v1_name: Optional[str], dryrun) -> Dict[str, Any]:
15        """Get this view as LookML."""
16        if len(self.tables) == 0:
17            raise Exception((f"Operational Monitoring view {self.name} has no tables"))
18
19        reference_table = self.tables[0]["table"]
20        dimensions = [
21            d
22            for d in lookml_utils._generate_dimensions(reference_table, dryrun=dryrun)
23            if d["name"] != "submission"
24        ]
25
26        dimensions.append(
27            {
28                "name": "submission_date",
29                "type": "date",
30                "sql": "${TABLE}.submission_date",
31                "datatype": "date",
32                "convert_tz": "no",
33            }
34        )
35
36        dimensions.append(
37            {
38                "name": "build_id_date",
39                "type": "date",
40                "hidden": "yes",
41                "sql": "PARSE_DATE('%Y%m%d', CAST(${TABLE}.build_id AS STRING))",
42                "datatype": "date",
43                "convert_tz": "no",
44            }
45        )
46
47        return {
48            "views": [
49                {
50                    "name": self.name,
51                    "sql_table_name": f"`{reference_table}`",
52                    "dimensions": dimensions,
53                    "measures": [
54                        {"name": "errors", "type": "number", "sql": "COUNT(*)"}
55                    ],
56                }
57            ]
58        }
class OperationalMonitoringAlertingView(generator.views.operational_monitoring_view.OperationalMonitoringView):
10class OperationalMonitoringAlertingView(OperationalMonitoringView):
11    """A view on a alert operational monitoring table."""
12
13    type: str = "operational_monitoring_alerting_view"
14
15    def to_lookml(self, v1_name: Optional[str], dryrun) -> Dict[str, Any]:
16        """Get this view as LookML."""
17        if len(self.tables) == 0:
18            raise Exception((f"Operational Monitoring view {self.name} has no tables"))
19
20        reference_table = self.tables[0]["table"]
21        dimensions = [
22            d
23            for d in lookml_utils._generate_dimensions(reference_table, dryrun=dryrun)
24            if d["name"] != "submission"
25        ]
26
27        dimensions.append(
28            {
29                "name": "submission_date",
30                "type": "date",
31                "sql": "${TABLE}.submission_date",
32                "datatype": "date",
33                "convert_tz": "no",
34            }
35        )
36
37        dimensions.append(
38            {
39                "name": "build_id_date",
40                "type": "date",
41                "hidden": "yes",
42                "sql": "PARSE_DATE('%Y%m%d', CAST(${TABLE}.build_id AS STRING))",
43                "datatype": "date",
44                "convert_tz": "no",
45            }
46        )
47
48        return {
49            "views": [
50                {
51                    "name": self.name,
52                    "sql_table_name": f"`{reference_table}`",
53                    "dimensions": dimensions,
54                    "measures": [
55                        {"name": "errors", "type": "number", "sql": "COUNT(*)"}
56                    ],
57                }
58            ]
59        }

A view on a alert operational monitoring table.

type: str = 'operational_monitoring_alerting_view'
def to_lookml(self, v1_name: Optional[str], dryrun) -> Dict[str, Any]:
15    def to_lookml(self, v1_name: Optional[str], dryrun) -> Dict[str, Any]:
16        """Get this view as LookML."""
17        if len(self.tables) == 0:
18            raise Exception((f"Operational Monitoring view {self.name} has no tables"))
19
20        reference_table = self.tables[0]["table"]
21        dimensions = [
22            d
23            for d in lookml_utils._generate_dimensions(reference_table, dryrun=dryrun)
24            if d["name"] != "submission"
25        ]
26
27        dimensions.append(
28            {
29                "name": "submission_date",
30                "type": "date",
31                "sql": "${TABLE}.submission_date",
32                "datatype": "date",
33                "convert_tz": "no",
34            }
35        )
36
37        dimensions.append(
38            {
39                "name": "build_id_date",
40                "type": "date",
41                "hidden": "yes",
42                "sql": "PARSE_DATE('%Y%m%d', CAST(${TABLE}.build_id AS STRING))",
43                "datatype": "date",
44                "convert_tz": "no",
45            }
46        )
47
48        return {
49            "views": [
50                {
51                    "name": self.name,
52                    "sql_table_name": f"`{reference_table}`",
53                    "dimensions": dimensions,
54                    "measures": [
55                        {"name": "errors", "type": "number", "sql": "COUNT(*)"}
56                    ],
57                }
58            ]
59        }

Get this view as LookML.