Skip to content

Commit 88091ec

Browse files
authored
refactor(lookml): Fixed log levels for source reporters (#15318)
1 parent 774f4c5 commit 88091ec

File tree

5 files changed

+45
-25
lines changed

5 files changed

+45
-25
lines changed

metadata-ingestion/src/datahub/ingestion/source/looker/lookml_source.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,8 @@ def get_manifest_if_present(self, folder: pathlib.Path) -> Optional[LookerManife
492492
manifest_file = folder / "manifest.lkml"
493493

494494
if not manifest_file.exists():
495-
self.reporter.info(
495+
self.reporter.report_warning(
496+
title="Manifest File Missing",
496497
message="manifest.lkml file missing from project",
497498
context=str(manifest_file),
498499
)

metadata-ingestion/src/datahub/ingestion/source/looker/view_upstream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ def _report_field_splitting_stats(
917917

918918
if success_rate == 100:
919919
# All queries succeeded
920-
self.reporter.report_warning(
920+
self.reporter.info(
921921
title="Field Splitting Statistics - Complete Success",
922922
message="Field splitting completed successfully",
923923
context=f"View-name: {self.view_context.name()}, Success rate: {success_rate:.1f}%, Total fields: {total_fields}, Chunks: {total_chunks}, Upstream tables: {upstream_tables}, Column lineages: {column_lineages}{fallback_info}",

metadata-ingestion/tests/integration/lookml/test_lookml.py

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ def test_lookml_ingest(pytestconfig, tmp_path, mock_time):
9898
pipeline.run()
9999
pipeline.pretty_print_summary()
100100
pipeline.raise_from_status(raise_warnings=False)
101-
assert pipeline.source.get_report().warnings.total_elements == 1
101+
# Expect 2 warnings: "Manifest File Missing" and "Skipped View File"
102+
assert pipeline.source.get_report().warnings.total_elements == 2
102103

103104
mce_helpers.check_golden_file(
104105
pytestconfig,
@@ -133,7 +134,8 @@ def test_lookml_refinement_ingest(pytestconfig, tmp_path, mock_time):
133134
pipeline.run()
134135
pipeline.pretty_print_summary()
135136
pipeline.raise_from_status(raise_warnings=False)
136-
assert pipeline.source.get_report().warnings.total_elements == 1
137+
# Expect 2 warnings: "Manifest File Missing" and "Skipped View File"
138+
assert pipeline.source.get_report().warnings.total_elements == 2
137139

138140
golden_path = test_resources_dir / "refinements_ingestion_golden.json"
139141
mce_helpers.check_golden_file(
@@ -164,7 +166,8 @@ def test_lookml_refinement_include_order(pytestconfig, tmp_path, mock_time):
164166
pipeline.run()
165167
pipeline.pretty_print_summary()
166168
pipeline.raise_from_status(raise_warnings=False)
167-
assert pipeline.source.get_report().warnings.total_elements == 1
169+
# Expect 2 warnings: "Manifest File Missing" and "Skipped View File"
170+
assert pipeline.source.get_report().warnings.total_elements == 2
168171

169172
golden_path = test_resources_dir / "refinement_include_order_golden.json"
170173
mce_helpers.check_golden_file(
@@ -363,7 +366,8 @@ def test_lookml_ingest_offline(pytestconfig, tmp_path, mock_time):
363366
pipeline.run()
364367
pipeline.pretty_print_summary()
365368
pipeline.raise_from_status(raise_warnings=False)
366-
assert pipeline.source.get_report().warnings.total_elements == 1
369+
# Expect 2 warnings: "Manifest File Missing" and "Skipped View File"
370+
assert pipeline.source.get_report().warnings.total_elements == 2
367371

368372
mce_helpers.check_golden_file(
369373
pytestconfig,
@@ -409,7 +413,8 @@ def test_lookml_ingest_offline_with_model_deny(pytestconfig, tmp_path, mock_time
409413
pipeline.run()
410414
pipeline.pretty_print_summary()
411415
pipeline.raise_from_status(raise_warnings=False)
412-
assert pipeline.source.get_report().warnings.total_elements == 1
416+
# Expect 2 warnings: "Manifest File Missing" and "Skipped View File"
417+
assert pipeline.source.get_report().warnings.total_elements == 2
413418

414419
mce_helpers.check_golden_file(
415420
pytestconfig,
@@ -465,7 +470,8 @@ def test_lookml_ingest_offline_platform_instance(pytestconfig, tmp_path, mock_ti
465470
pipeline.run()
466471
pipeline.pretty_print_summary()
467472
pipeline.raise_from_status(raise_warnings=False)
468-
assert pipeline.source.get_report().warnings.total_elements == 1
473+
# Expect 2 warnings: "Manifest File Missing" and "Skipped View File"
474+
assert pipeline.source.get_report().warnings.total_elements == 2
469475

470476
mce_helpers.check_golden_file(
471477
pytestconfig,
@@ -557,7 +563,8 @@ def ingestion_test(
557563
pipeline.run()
558564
pipeline.pretty_print_summary()
559565
pipeline.raise_from_status(raise_warnings=False)
560-
assert pipeline.source.get_report().warnings.total_elements == 1
566+
# Expect 2 warnings: "Manifest File Missing" and "Skipped View File"
567+
assert pipeline.source.get_report().warnings.total_elements == 2
561568

562569
mce_helpers.check_golden_file(
563570
pytestconfig,
@@ -612,7 +619,8 @@ def test_lookml_git_info(pytestconfig, tmp_path, mock_time):
612619
pipeline.run()
613620
pipeline.pretty_print_summary()
614621
pipeline.raise_from_status(raise_warnings=False)
615-
assert pipeline.source.get_report().warnings.total_elements == 1
622+
# Expect 2 warnings: "Manifest File Missing" and "Skipped View File"
623+
assert pipeline.source.get_report().warnings.total_elements == 2
616624

617625
mce_helpers.check_golden_file(
618626
pytestconfig,
@@ -673,7 +681,7 @@ def test_reachable_views(pytestconfig, tmp_path, mock_time):
673681
)
674682
pipeline.run()
675683
pipeline.pretty_print_summary()
676-
pipeline.raise_from_status(raise_warnings=True)
684+
pipeline.raise_from_status(raise_warnings=False)
677685

678686
mce_helpers.check_golden_file(
679687
pytestconfig,
@@ -736,7 +744,8 @@ def test_hive_platform_drops_ids(pytestconfig, tmp_path, mock_time):
736744
pipeline.run()
737745
pipeline.pretty_print_summary()
738746
pipeline.raise_from_status(raise_warnings=False)
739-
assert pipeline.source.get_report().warnings.total_elements == 1
747+
# Expect 2 warnings: "Manifest File Missing" and "Skipped View File"
748+
assert pipeline.source.get_report().warnings.total_elements == 2
740749

741750
events = read_metadata_file(tmp_path / mce_out)
742751
for mce in events:
@@ -882,7 +891,7 @@ def test_same_name_views_different_file_path(pytestconfig, tmp_path, mock_time):
882891
)
883892
pipeline.run()
884893
pipeline.pretty_print_summary()
885-
pipeline.raise_from_status(raise_warnings=True)
894+
pipeline.raise_from_status(raise_warnings=False)
886895

887896
mce_helpers.check_golden_file(
888897
pytestconfig,
@@ -918,7 +927,7 @@ def test_duplicate_field_ingest(pytestconfig, tmp_path, mock_time):
918927
pipeline = Pipeline.create(new_recipe)
919928
pipeline.run()
920929
pipeline.pretty_print_summary()
921-
pipeline.raise_from_status(raise_warnings=True)
930+
pipeline.raise_from_status(raise_warnings=False)
922931

923932
golden_path = test_resources_dir / "duplicate_field_ingestion_golden.json"
924933
mce_helpers.check_golden_file(
@@ -953,7 +962,7 @@ def test_view_to_view_lineage_and_liquid_template(pytestconfig, tmp_path, mock_t
953962
pipeline = Pipeline.create(new_recipe)
954963
pipeline.run()
955964
pipeline.pretty_print_summary()
956-
pipeline.raise_from_status(raise_warnings=True)
965+
pipeline.raise_from_status(raise_warnings=False)
957966

958967
golden_path = test_resources_dir / "vv_lineage_liquid_template_golden.json"
959968
mce_helpers.check_golden_file(
@@ -978,6 +987,7 @@ def test_view_to_view_lineage_and_lookml_constant(pytestconfig, tmp_path, mock_t
978987
pipeline = Pipeline.create(new_recipe)
979988
pipeline.run()
980989
pipeline.pretty_print_summary()
990+
# Expect 1 warning: "LookML constant not found" (no manifest file or skipped views in this test scenario)
981991
assert pipeline.source.get_report().warnings.total_elements == 1
982992

983993
golden_path = test_resources_dir / "vv_lineage_lookml_constant_golden.json"
@@ -1223,7 +1233,7 @@ def test_field_tag_ingest(pytestconfig, tmp_path, mock_time):
12231233
pipeline = Pipeline.create(new_recipe)
12241234
pipeline.run()
12251235
pipeline.pretty_print_summary()
1226-
pipeline.raise_from_status(raise_warnings=True)
1236+
pipeline.raise_from_status(raise_warnings=False)
12271237

12281238
golden_path = test_resources_dir / "field_tag_ingestion_golden.json"
12291239
mce_helpers.check_golden_file(
@@ -1250,7 +1260,7 @@ def test_drop_hive(pytestconfig, tmp_path, mock_time):
12501260
pipeline = Pipeline.create(new_recipe)
12511261
pipeline.run()
12521262
pipeline.pretty_print_summary()
1253-
pipeline.raise_from_status(raise_warnings=True)
1263+
pipeline.raise_from_status(raise_warnings=False)
12541264

12551265
golden_path = test_resources_dir / "drop_hive_dot_golden.json"
12561266
mce_helpers.check_golden_file(
@@ -1287,7 +1297,7 @@ def test_gms_schema_resolution(pytestconfig, tmp_path, mock_time):
12871297
pipeline = Pipeline.create(new_recipe)
12881298
pipeline.run()
12891299
pipeline.pretty_print_summary()
1290-
pipeline.raise_from_status(raise_warnings=True)
1300+
pipeline.raise_from_status(raise_warnings=False)
12911301

12921302
golden_path = test_resources_dir / "gms_schema_resolution_golden.json"
12931303
mce_helpers.check_golden_file(
@@ -1336,7 +1346,8 @@ def test_unreachable_views(pytestconfig):
13361346
assert (
13371347
len(converted_workunits) == 22
13381348
) # this num was updated when we converted entities to metadata work units part of SDKv2 migration
1339-
assert source.reporter.warnings.total_elements == 1
1349+
# Expect 2 warnings: "Manifest File Missing" and "Skipped View File"
1350+
assert source.reporter.warnings.total_elements == 2
13401351
assert (
13411352
"The Looker view file was skipped because it may not be referenced by any models."
13421353
in [failure.message for failure in source.get_report().warnings]
@@ -1512,7 +1523,7 @@ def mock_run_inline_query(
15121523
pipeline = Pipeline.create(recipe)
15131524
pipeline.run()
15141525
pipeline.pretty_print_summary()
1515-
pipeline.raise_from_status(raise_warnings=True)
1526+
pipeline.raise_from_status(raise_warnings=False)
15161527

15171528
mce_helpers.check_golden_file(
15181529
pytestconfig,

metadata-ingestion/tests/integration/lookml/test_lookml_field_splitting_integration.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,12 @@ def run_inline_query_side_effect(result_format=None, body=None, **kwargs):
166166
report = pipeline.source.get_report()
167167
assert report is not None
168168

169-
# Check that warnings contain field splitting statistics
169+
# Check that field splitting statistics are reported (in warnings for partial/failure, or infos for complete success)
170170
warnings = [w for w in report.warnings if "Field Splitting" in str(w)]
171-
assert len(warnings) > 0, "Expected field splitting statistics to be reported"
171+
infos = [w for w in report.infos if "Field Splitting" in str(w)]
172+
assert len(warnings) > 0 or len(infos) > 0, (
173+
"Expected field splitting statistics to be reported"
174+
)
172175

173176

174177
@freeze_time(FROZEN_TIME)
@@ -205,13 +208,17 @@ def test_integration_individual_field_fallback_on_chunk_failure(
205208
query_call_count = [0]
206209

207210
def run_inline_query_side_effect(result_format=None, body=None, **kwargs):
208-
"""Simulate chunk failure, then individual field success."""
211+
"""Simulate chunk failure, then some individual field failures and successes."""
209212
if result_format == "sql":
210213
query_call_count[0] += 1
211214
# First chunk fails (returns invalid SQL that causes parsing error)
212215
if query_call_count[0] == 1:
213216
return "INVALID SQL SYNTAX ERROR"
214-
# Subsequent individual field queries succeed
217+
# Some individual field queries fail (to test problematic fields reporting)
218+
# Fail every 5th field to create some problematic fields
219+
if (query_call_count[0] - 1) % 5 == 0:
220+
return "INVALID SQL SYNTAX ERROR"
221+
# Other individual field queries succeed
215222
return f"SELECT {view_name}.field_{query_call_count[0] - 2} FROM test_table"
216223
return ""
217224

metadata-ingestion/tests/unit/lookml/test_lookml_api_based_view_upstream.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,4 +1356,5 @@ def test_field_splitting_statistics_reporting(
13561356
upstream_instance_with_splitting._get_spr()
13571357

13581358
# Verify reporter was called for statistics
1359-
assert upstream_instance_with_splitting.reporter.report_warning.called
1359+
# For complete success (100% success rate), info() is called instead of report_warning()
1360+
assert upstream_instance_with_splitting.reporter.info.called

0 commit comments

Comments
 (0)