Skip to content

Commit

Permalink
fix(ingest): match nested LookML files mentioned in 'include' stateme…
Browse files Browse the repository at this point in the history
…nts (#2957)
  • Loading branch information
jameslamb authored Jul 26, 2021
1 parent 79c956a commit 5d396b1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion metadata-ingestion/src/datahub/ingestion/source/lookml.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ def from_looker_dict(
def resolve_includes(
includes: List[str], base_folder: str, path: str, reporter: LookMLSourceReport
) -> List[str]:
"""Resolve ``include`` statements in LookML model files to a list of ``.lkml`` files.
For rules on how LookML ``include`` statements are written, see
https://docs.looker.com/data-modeling/getting-started/ide-folders#wildcard_examples
"""
resolved = []
for inc in includes:
# Filter out dashboards - we get those through the looker source.
Expand All @@ -128,7 +133,10 @@ def resolve_includes(
else:
# Need to handle a relative path.
glob_expr = str(pathlib.Path(path).parent / inc)
outputs = glob.glob(glob_expr) + glob.glob(f"{glob_expr}.lkml")
# "**" matches an arbitrary number of directories in LookML
outputs = glob.glob(glob_expr, recursive=True) + glob.glob(
f"{glob_expr}.lkml", recursive=True
)
if "*" not in inc and not outputs:
reporter.report_failure(path, f"cannot resolve include {inc}")
elif not outputs:
Expand Down

0 comments on commit 5d396b1

Please sign in to comment.