generator.explores.table_explore

Table explore type.

 1"""Table explore type."""
 2
 3from __future__ import annotations
 4
 5from pathlib import Path
 6from typing import Any, Dict, Iterator, List, Optional
 7
 8from ..views import TableView, View
 9from . import Explore
10
11ALLOWED_VIEWS = {"events_stream_table"}
12
13
14class TableExplore(Explore):
15    """A table explore."""
16
17    type: str = "table_explore"
18
19    def _to_lookml(self, v1_name: Optional[str]) -> List[Dict[str, Any]]:
20        """Generate LookML to represent this explore."""
21        explore_lookml: Dict[str, Any] = {
22            "name": self.name,
23            "view_name": self.views["base_view"],
24            "joins": self.get_unnested_fields_joins_lookml(),
25        }
26        if required_filters := self.get_required_filters("base_view"):
27            explore_lookml["always_filter"] = {
28                "filters": required_filters,
29            }
30
31        if datagroup := self.get_datagroup():
32            explore_lookml["persist_with"] = datagroup
33
34        # Now that purpose-built `events_stream` explores exist (DENG-9548), we'll hide the less functional
35        # `events_stream_table` explores until we can fully deprecate and remove them (DENG-9550).
36        if self.name == "events_stream_table":
37            explore_lookml["hidden"] = "yes"
38
39        return [explore_lookml]
40
41    @staticmethod
42    def from_views(views: List[View]) -> Iterator[TableExplore]:
43        """Don't generate all possible TableExplores from the views, only generate for ALLOWED_VIEWS."""
44        for view in views:
45            if view.view_type == TableView.type:
46                if view.name in ALLOWED_VIEWS:
47                    yield TableExplore(view.name, {"base_view": view.name})
48
49    @staticmethod
50    def from_dict(name: str, defn: dict, views_path: Path) -> TableExplore:
51        """Get an instance of this explore from a name and dictionary definition."""
52        return TableExplore(name, defn["views"], views_path)
ALLOWED_VIEWS = {'events_stream_table'}
class TableExplore(generator.explores.explore.Explore):
15class TableExplore(Explore):
16    """A table explore."""
17
18    type: str = "table_explore"
19
20    def _to_lookml(self, v1_name: Optional[str]) -> List[Dict[str, Any]]:
21        """Generate LookML to represent this explore."""
22        explore_lookml: Dict[str, Any] = {
23            "name": self.name,
24            "view_name": self.views["base_view"],
25            "joins": self.get_unnested_fields_joins_lookml(),
26        }
27        if required_filters := self.get_required_filters("base_view"):
28            explore_lookml["always_filter"] = {
29                "filters": required_filters,
30            }
31
32        if datagroup := self.get_datagroup():
33            explore_lookml["persist_with"] = datagroup
34
35        # Now that purpose-built `events_stream` explores exist (DENG-9548), we'll hide the less functional
36        # `events_stream_table` explores until we can fully deprecate and remove them (DENG-9550).
37        if self.name == "events_stream_table":
38            explore_lookml["hidden"] = "yes"
39
40        return [explore_lookml]
41
42    @staticmethod
43    def from_views(views: List[View]) -> Iterator[TableExplore]:
44        """Don't generate all possible TableExplores from the views, only generate for ALLOWED_VIEWS."""
45        for view in views:
46            if view.view_type == TableView.type:
47                if view.name in ALLOWED_VIEWS:
48                    yield TableExplore(view.name, {"base_view": view.name})
49
50    @staticmethod
51    def from_dict(name: str, defn: dict, views_path: Path) -> TableExplore:
52        """Get an instance of this explore from a name and dictionary definition."""
53        return TableExplore(name, defn["views"], views_path)

A table explore.

type: str = 'table_explore'
@staticmethod
def from_views( views: List[generator.views.view.View]) -> Iterator[TableExplore]:
42    @staticmethod
43    def from_views(views: List[View]) -> Iterator[TableExplore]:
44        """Don't generate all possible TableExplores from the views, only generate for ALLOWED_VIEWS."""
45        for view in views:
46            if view.view_type == TableView.type:
47                if view.name in ALLOWED_VIEWS:
48                    yield TableExplore(view.name, {"base_view": view.name})

Don't generate all possible TableExplores from the views, only generate for ALLOWED_VIEWS.

@staticmethod
def from_dict( name: str, defn: dict, views_path: pathlib.Path) -> TableExplore:
50    @staticmethod
51    def from_dict(name: str, defn: dict, views_path: Path) -> TableExplore:
52        """Get an instance of this explore from a name and dictionary definition."""
53        return TableExplore(name, defn["views"], views_path)

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