Skip to content

Commit

Permalink
feat(ingestion/lookml): support looker -- if comments (#11113)
Browse files Browse the repository at this point in the history
  • Loading branch information
sid-acryl authored Aug 16, 2024
1 parent 437569a commit cb33c0f
Show file tree
Hide file tree
Showing 11 changed files with 867 additions and 48 deletions.
1 change: 1 addition & 0 deletions metadata-ingestion/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
*sqlglot_lib,
"GitPython>2",
"python-liquid",
"deepmerge>=1.1.1"
}

bigquery_common = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
IMPORTED_PROJECTS = "imported_projects"
SQL_TABLE_NAME = "sql_table_name"
DATAHUB_TRANSFORMED_SQL_TABLE_NAME = "datahub_transformed_sql_table_name"
DERIVED_TABLE = "derived_table"
SQL = "sql"
DATAHUB_TRANSFORMED_SQL = "datahub_transformed_sql"
prod = "prod"
dev = "dev"
NAME = "name"
DERIVED_DOT_SQL = "derived.sql"
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import logging
import pathlib
from dataclasses import replace
from typing import Any, Dict, Optional
from typing import Dict, Optional

from datahub.ingestion.source.looker.lkml_patched import load_lkml
from datahub.ingestion.source.looker.looker_config import LookerConnectionDefinition
from datahub.ingestion.source.looker.looker_dataclasses import LookerViewFile
from datahub.ingestion.source.looker.looker_template_language import (
resolve_liquid_variable_in_view_dict,
process_lookml_template_language,
)
from datahub.ingestion.source.looker.lookml_config import (
_EXPLORE_FILE_EXTENSION,
_VIEW_FILE_EXTENSION,
LookMLSourceConfig,
LookMLSourceReport,
)

Expand All @@ -29,13 +30,13 @@ def __init__(
root_project_name: Optional[str],
base_projects_folder: Dict[str, pathlib.Path],
reporter: LookMLSourceReport,
liquid_variable: Dict[Any, Any],
source_config: LookMLSourceConfig,
) -> None:
self.viewfile_cache: Dict[str, Optional[LookerViewFile]] = {}
self._root_project_name = root_project_name
self._base_projects_folder = base_projects_folder
self.reporter = reporter
self.liquid_variable = liquid_variable
self.source_config = source_config

def _load_viewfile(
self, project_name: str, path: str, reporter: LookMLSourceReport
Expand Down Expand Up @@ -73,9 +74,9 @@ def _load_viewfile(

parsed = load_lkml(path)

resolve_liquid_variable_in_view_dict(
raw_view=parsed,
liquid_variable=self.liquid_variable,
process_lookml_template_language(
view_lkml_file_dict=parsed,
source_config=self.source_config,
)

looker_viewfile = LookerViewFile.from_looker_dict(
Expand Down
Loading

0 comments on commit cb33c0f

Please sign in to comment.