Skip to content

Commit

Permalink
Add detail to error messages for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Nov 2, 2024
1 parent fc0415f commit 6514e81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions metricflow/dataflow/builder/dataflow_plan_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ def _build_plan(
def _optimize_plan(self, plan: DataflowPlan, optimizations: FrozenSet[DataflowPlanOptimization]) -> DataflowPlan:
optimizer_factory = DataflowPlanOptimizerFactory(self._node_data_set_resolver)
for optimizer in optimizer_factory.get_optimizers(optimizations):
logger.debug(LazyFormat(lambda: f"Applying {optimizer.__class__.__name__}"))
logger.debug(LazyFormat(lambda: f"Applying optimizer: {optimizer.__class__.__name__}"))
try:
plan = optimizer.optimize(plan)
logger.debug(
LazyFormat(
lambda: f"After applying {optimizer.__class__.__name__}, the dataflow plan is:\n"
lambda: f"After applying optimizer {optimizer.__class__.__name__}, the dataflow plan is:\n"
f"{indent(plan.structure_text())}"
)
)
Expand Down
8 changes: 7 additions & 1 deletion metricflow/sql/optimizer/column_pruner.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ def visit_select_statement_node(self, node: SqlSelectStatementNode) -> SqlQueryP
# SqlExpressionNode.

if len(pruned_select_columns) == 0:
raise RuntimeError("All columns have been pruned - this indicates an bug in the pruner or in the inputs.")
raise RuntimeError(
"All columns have been removed - this indicates an bug in the pruner or in the inputs.\n"
f"Original column aliases: {[col.column_alias for col in node.select_columns]}\n"
f"Required column aliases: {self._required_column_aliases}\n"
f"Group bys: {node.group_bys}\n"
f"Distinct: {node.distinct}"
)

# Based on the expressions in this select statement, figure out what column aliases are needed in the sources of
# this query (i.e. tables or sub-queries in the FROM or JOIN clauses).
Expand Down

0 comments on commit 6514e81

Please sign in to comment.