generator.explores.ping_explore

Ping explore type.

 1"""Ping explore type."""
 2
 3from __future__ import annotations
 4
 5from pathlib import Path
 6from typing import Any, Dict, Iterator, List, Optional
 7
 8from ..views import PingView, View
 9from . import Explore
10
11
12class PingExplore(Explore):
13    """A Ping Table explore."""
14
15    type: str = "ping_explore"
16
17    def _to_lookml(self, v1_name: Optional[str]) -> List[Dict[str, Any]]:
18        """Generate LookML to represent this explore."""
19        explore_lookml = {
20            "name": self.name,
21            "view_name": self.views["base_view"],
22            "always_filter": {
23                "filters": self.get_required_filters("base_view"),
24            },
25            "joins": self.get_unnested_fields_joins_lookml(),
26        }
27
28        if datagroup := self.get_datagroup():
29            explore_lookml["persist_with"] = datagroup
30
31        return [explore_lookml]
32
33    @staticmethod
34    def from_views(views: List[View]) -> Iterator[PingExplore]:
35        """Generate all possible PingExplores from the views."""
36        for view in views:
37            if view.view_type == PingView.type:
38                yield PingExplore(view.name, {"base_view": view.name})
39
40    @staticmethod
41    def from_dict(name: str, defn: dict, views_path: Path) -> PingExplore:
42        """Get an instance of this explore from a name and dictionary definition."""
43        return PingExplore(name, defn["views"], views_path)
class PingExplore(generator.explores.explore.Explore):
13class PingExplore(Explore):
14    """A Ping Table explore."""
15
16    type: str = "ping_explore"
17
18    def _to_lookml(self, v1_name: Optional[str]) -> List[Dict[str, Any]]:
19        """Generate LookML to represent this explore."""
20        explore_lookml = {
21            "name": self.name,
22            "view_name": self.views["base_view"],
23            "always_filter": {
24                "filters": self.get_required_filters("base_view"),
25            },
26            "joins": self.get_unnested_fields_joins_lookml(),
27        }
28
29        if datagroup := self.get_datagroup():
30            explore_lookml["persist_with"] = datagroup
31
32        return [explore_lookml]
33
34    @staticmethod
35    def from_views(views: List[View]) -> Iterator[PingExplore]:
36        """Generate all possible PingExplores from the views."""
37        for view in views:
38            if view.view_type == PingView.type:
39                yield PingExplore(view.name, {"base_view": view.name})
40
41    @staticmethod
42    def from_dict(name: str, defn: dict, views_path: Path) -> PingExplore:
43        """Get an instance of this explore from a name and dictionary definition."""
44        return PingExplore(name, defn["views"], views_path)

A Ping Table explore.

type: str = 'ping_explore'
@staticmethod
def from_views( views: List[generator.views.view.View]) -> Iterator[PingExplore]:
34    @staticmethod
35    def from_views(views: List[View]) -> Iterator[PingExplore]:
36        """Generate all possible PingExplores from the views."""
37        for view in views:
38            if view.view_type == PingView.type:
39                yield PingExplore(view.name, {"base_view": view.name})

Generate all possible PingExplores from the views.

@staticmethod
def from_dict( name: str, defn: dict, views_path: pathlib.Path) -> PingExplore:
41    @staticmethod
42    def from_dict(name: str, defn: dict, views_path: Path) -> PingExplore:
43        """Get an instance of this explore from a name and dictionary definition."""
44        return PingExplore(name, defn["views"], views_path)

Get an instance of this explore from a name and dictionary definition.