Skip to content

Commit

Permalink
fix: added minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar-salvi-apptware committed Jan 24, 2025
1 parent 6634d1e commit 2a20992
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class LookmlConstantTransformer(LookMLViewTransformer):

CONSTANT_PATTERN = r"@{(\w+)}" # Matches @{constant}

def resolve_lookml_constant(self, text: str) -> str:
def resolve_lookml_constant(self, text: str, view_name=str) -> str:
"""
Resolves LookML constants (@{ }) from manifest or config.
Logs warnings for misplaced or missing variables.
Expand Down Expand Up @@ -402,14 +402,18 @@ def replace_constants(match):
)
return f"@{{{key}}}"

logger.warning(f"Constant '@{{{key}}}' not found in configuration.")
self.reporter.report_warning(
title="LookML constant not found",
message="The constant is missing. Either add it under 'lookml_constants' in the config or define it in `manifest.lkml`.",
context=f"view-name: {view_name}, constant: {key}",
)
return "NULL"

# Resolve @{} (constant)
return re.sub(self.CONSTANT_PATTERN, replace_constants, text)

def _apply_transformation(self, value: str, view: dict) -> str:
return self.resolve_lookml_constant(text=value)
return self.resolve_lookml_constant(text=value, view_name=view["name"])


class TransformedLookMlView:
Expand Down
2 changes: 1 addition & 1 deletion metadata-ingestion/tests/integration/lookml/test_lookml.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ def test_view_to_view_lineage_and_lookml_constant(pytestconfig, tmp_path, mock_t
pipeline = Pipeline.create(new_recipe)
pipeline.run()
pipeline.pretty_print_summary()
pipeline.raise_from_status(raise_warnings=True)
pipeline.raise_from_status(raise_warnings=False)

golden_path = test_resources_dir / "vv_lineage_lookml_constant_golden.json"
mce_helpers.check_golden_file(
Expand Down

0 comments on commit 2a20992

Please sign in to comment.