Change view defns for tests and code
This commit is contained in:
Родитель
55608b4297
Коммит
daba1d38e4
|
@ -3,7 +3,7 @@ import logging
|
|||
import re
|
||||
from itertools import filterfalse
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Iterable, List, Tuple
|
||||
from typing import Any, Dict, Iterable, List, Tuple, TypedDict
|
||||
|
||||
import click
|
||||
import lkml
|
||||
|
@ -38,6 +38,13 @@ MAP_LAYER_NAMES = {
|
|||
}
|
||||
|
||||
|
||||
class ViewDict(TypedDict):
|
||||
"""Represent a view definition."""
|
||||
|
||||
type: str
|
||||
tables: List[Dict[str, str]]
|
||||
|
||||
|
||||
def _get_dimension(path: Tuple[str, ...], field_type: str, mode: str) -> Dict[str, Any]:
|
||||
result: Dict[str, Any] = {}
|
||||
result["sql"] = "${TABLE}." + ".".join(path)
|
||||
|
@ -142,7 +149,7 @@ def _generate_measures(dimensions: List[dict], table: str) -> List[Dict[str, str
|
|||
|
||||
|
||||
def _generate_views(
|
||||
client, out_dir: Path, views: Dict[str, List[Dict[str, str]]]
|
||||
client, out_dir: Path, views: Dict[str, ViewDict]
|
||||
) -> Iterable[Path]:
|
||||
for name, defn in views.items():
|
||||
tables = defn["tables"]
|
||||
|
|
|
@ -114,16 +114,20 @@ def test_lookml(runner, tmp_path):
|
|||
canonical_app_name: Custom
|
||||
views:
|
||||
baseline:
|
||||
- channel: release
|
||||
table: mozdata.custom.baseline
|
||||
type: ping_view
|
||||
tables:
|
||||
- channel: release
|
||||
table: mozdata.custom.baseline
|
||||
glean-app:
|
||||
canonical_app_name: Glean App
|
||||
views:
|
||||
baseline:
|
||||
- channel: release
|
||||
table: mozdata.glean_app.baseline
|
||||
- channel: beta
|
||||
table: mozdata.glean_app_beta.baseline
|
||||
type: ping_view
|
||||
tables:
|
||||
- channel: release
|
||||
table: mozdata.glean_app.baseline
|
||||
- channel: beta
|
||||
table: mozdata.glean_app_beta.baseline
|
||||
explores:
|
||||
baseline:
|
||||
type: ping_explore
|
||||
|
@ -361,8 +365,10 @@ def test_duplicate_dimension(runner, tmp_path):
|
|||
canonical_app_name: Custom
|
||||
views:
|
||||
baseline:
|
||||
- channel: release
|
||||
table: mozdata.fail.duplicate_dimension
|
||||
type: ping_explore
|
||||
tables:
|
||||
- channel: release
|
||||
table: mozdata.fail.duplicate_dimension
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
@ -391,8 +397,10 @@ def test_duplicate_measure(runner, tmp_path):
|
|||
canonical_app_name: Custom
|
||||
views:
|
||||
baseline:
|
||||
- channel: release
|
||||
table: mozdata.fail.duplicate_measure
|
||||
type: ping_explore
|
||||
tables:
|
||||
- channel: release
|
||||
table: mozdata.fail.duplicate_measure
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче