Skip to content

Commit

Permalink
WIP - coalesce nulls for multi-metric queries
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Nov 4, 2023
1 parent b243aad commit a565dab
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions metricflow/plan_conversion/dataflow_to_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,23 @@ def _make_select_columns_for_metrics(
else:
select_expression = column_reference_expression

input_measures = self._metric_lookup.measures_for_metric(
# Using alias instead of element name in reference, where did we lose the name?
metric_reference=metric_spec.as_reference,
column_association_resolver=self._column_association_resolver,
)
if input_measures:
# TODO: update type after other PR merges
input_measure = input_measures[0]
if input_measure.fill_nulls_with is not None:
select_expression = SqlAggregateFunctionExpression(
sql_function=SqlFunction.COALESCE,
sql_function_args=[
select_expression,
SqlStringExpression(str(input_measure.fill_nulls_with)),
],
)

select_columns.append(
SqlSelectColumn(
expr=select_expression,
Expand Down

0 comments on commit a565dab

Please sign in to comment.