Fix metric expression extraction: use 'code' field

OpenMetadata stores SQL in metricExpression.code, not .expression.
This caused all metric expressions to export as empty strings.
This commit is contained in:
Petr 2026-03-18 13:01:23 +01:00
parent 908d1f2247
commit e63c8747b5

View file

@ -102,7 +102,8 @@ def extract_expression(raw_metric: Dict[str, Any]) -> str:
"""
metric_expr = raw_metric.get("metricExpression", {})
if isinstance(metric_expr, dict):
return metric_expr.get("expression", "") or ""
# OpenMetadata uses "code" field for the SQL expression
return metric_expr.get("code", "") or metric_expr.get("expression", "") or ""
if isinstance(metric_expr, str):
return metric_expr
return ""