From b5d3d724da0ce7f77200f624326094a0c650da07 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 8 Nov 2024 12:53:04 -0800 Subject: [PATCH] Improve error messages. --- .../test_helpers/snapshot_helpers.py | 1 + metricflow/dataset/sql_dataset.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/metricflow-semantics/metricflow_semantics/test_helpers/snapshot_helpers.py b/metricflow-semantics/metricflow_semantics/test_helpers/snapshot_helpers.py index 5d75f9e1d0..0448e201ef 100644 --- a/metricflow-semantics/metricflow_semantics/test_helpers/snapshot_helpers.py +++ b/metricflow-semantics/metricflow_semantics/test_helpers/snapshot_helpers.py @@ -56,6 +56,7 @@ def assert_snapshot_text_equal( expectation_description: Optional[str] = None, ) -> None: """Similar to assert_plan_snapshot_text_equal(), but with more controls on how the snapshot paths are generated.""" + logger.debug(LazyFormat("Checking the generated snapshot with what's stored", generated_snapshot=snapshot_text)) file_path = ( str( snapshot_path_prefix( diff --git a/metricflow/dataset/sql_dataset.py b/metricflow/dataset/sql_dataset.py index b38da60910..9d3a944ef4 100644 --- a/metricflow/dataset/sql_dataset.py +++ b/metricflow/dataset/sql_dataset.py @@ -5,6 +5,7 @@ from dbt_semantic_interfaces.references import SemanticModelReference from metricflow_semantics.assert_one_arg import assert_exactly_one_arg_set from metricflow_semantics.instances import EntityInstance, InstanceSet +from metricflow_semantics.mf_logging.lazy_formattable import LazyFormat from metricflow_semantics.specs.column_assoc import ColumnAssociation from metricflow_semantics.specs.dimension_spec import DimensionSpec from metricflow_semantics.specs.entity_spec import EntitySpec @@ -52,7 +53,14 @@ def checked_sql_select_node(self) -> SqlSelectStatementNode: Otherwise, an exception is thrown. """ if self._sql_select_node is None: - raise RuntimeError(f"{self} was created with a SQL node that is not a {SqlSelectStatementNode}") + raise RuntimeError( + str( + LazyFormat( + f"{self} was created with a SQL node that is not a {SqlSelectStatementNode}", + sql_node=self.sql_node.structure_text(), + ) + ) + ) return self._sql_select_node def column_associations_for_entity(