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        return [explore_lookml]
31
32    @staticmethod
33    def from_views(views: List[View]) -> Iterator[TableExplore]:
34        """Don't generate all possible TableExplores from the views, only generate for ALLOWED_VIEWS."""
35        for view in views:
36            if view.view_type == TableView.type:
37                if view.name in ALLOWED_VIEWS:
38                    yield TableExplore(view.name, {"base_view": view.name})
39
40    @staticmethod
41    def from_dict(name: str, defn: dict, views_path: Path) -> TableExplore:
42        """Get an instance of this explore from a name and dictionary definition."""
43        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        return [explore_lookml]
32
33    @staticmethod
34    def from_views(views: List[View]) -> Iterator[TableExplore]:
35        """Don't generate all possible TableExplores from the views, only generate for ALLOWED_VIEWS."""
36        for view in views:
37            if view.view_type == TableView.type:
38                if view.name in ALLOWED_VIEWS:
39                    yield TableExplore(view.name, {"base_view": view.name})
40
41    @staticmethod
42    def from_dict(name: str, defn: dict, views_path: Path) -> TableExplore:
43        """Get an instance of this explore from a name and dictionary definition."""
44        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]:
33    @staticmethod
34    def from_views(views: List[View]) -> Iterator[TableExplore]:
35        """Don't generate all possible TableExplores from the views, only generate for ALLOWED_VIEWS."""
36        for view in views:
37            if view.view_type == TableView.type:
38                if view.name in ALLOWED_VIEWS:
39                    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:
41    @staticmethod
42    def from_dict(name: str, defn: dict, views_path: Path) -> TableExplore:
43        """Get an instance of this explore from a name and dictionary definition."""
44        return TableExplore(name, defn["views"], views_path)

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