Skip to content

Commit

Permalink
Improve error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed Nov 10, 2024
1 parent 8d407ec commit 7f0c36f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 9 additions & 1 deletion metricflow/dataset/sql_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 7f0c36f

Please sign in to comment.