45 строки
1.4 KiB
Python
45 строки
1.4 KiB
Python
"""Growth Accounting explore type."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
from typing import Any, Dict, Iterator, List, Optional
|
|
|
|
from ..views import View
|
|
from . import Explore
|
|
|
|
|
|
class GrowthAccountingExplore(Explore):
|
|
"""A Growth Accounting Explore, from Baseline Clients Last Seen."""
|
|
|
|
type: str = "growth_accounting_explore"
|
|
|
|
def _to_lookml(self, v1_name: Optional[str]) -> List[Dict[str, Any]]:
|
|
"""Generate LookML to represent this explore."""
|
|
return [
|
|
{
|
|
"name": self.name,
|
|
"view_name": self.views["base_view"],
|
|
"joins": self.get_unnested_fields_joins_lookml(),
|
|
}
|
|
]
|
|
|
|
@staticmethod
|
|
def from_views(views: List[View]) -> Iterator[GrowthAccountingExplore]:
|
|
"""
|
|
If possible, generate a Growth Accounting explore for this namespace.
|
|
|
|
Growth accounting explores are only created for growth_accounting views.
|
|
"""
|
|
for view in views:
|
|
if view.name == "growth_accounting":
|
|
yield GrowthAccountingExplore(
|
|
view.name,
|
|
{"base_view": "growth_accounting"},
|
|
)
|
|
|
|
@staticmethod
|
|
def from_dict(name: str, defn: dict, views_path: Path) -> GrowthAccountingExplore:
|
|
"""Get an instance of this explore from a dictionary definition."""
|
|
return GrowthAccountingExplore(name, defn["views"], views_path)
|