From 9867a1f02b2894295c46bf3e0789d718a920d5de Mon Sep 17 00:00:00 2001 From: Yong Date: Fri, 24 Jul 2026 11:29:57 -0500 Subject: [PATCH] Fix Omni pytest --- converters/omni/src/osi_omni/osi_to_omni.py | 10 +++++++++- converters/omni/tests/_util.py | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/converters/omni/src/osi_omni/osi_to_omni.py b/converters/omni/src/osi_omni/osi_to_omni.py index ffda2b8d..e2472b3f 100644 --- a/converters/omni/src/osi_omni/osi_to_omni.py +++ b/converters/omni/src/osi_omni/osi_to_omni.py @@ -373,7 +373,15 @@ def _convert_field(field, dname, expr, fscope): if instructions: dim["ai_context"] = instructions - if (field.get("dimension") or {}).get("is_time"): + dimension = field.get("dimension") + is_time = False + if dimension is not None: + is_time_explicit = dimension.get("is_time") + if is_time_explicit is not None: + is_time = bool(is_time_explicit) + else: + is_time = field.get("datatype") in ("Date", "Time", "DateTime", "DateTimez") + if is_time: # The stashed list wins even when empty (`timeframes: []` is a real # Omni value); the default list is only for hand-authored OSI. dim["timeframes"] = (stash["timeframes"] if "timeframes" in stash diff --git a/converters/omni/tests/_util.py b/converters/omni/tests/_util.py index 2cb15998..b1d72acb 100644 --- a/converters/omni/tests/_util.py +++ b/converters/omni/tests/_util.py @@ -107,8 +107,19 @@ def strip_normalized(osi): fields = ds.get("fields", []) or [] for field in fields: field.pop("custom_extensions", None) - if field.get("dimension") == {"is_time": False}: - field.pop("dimension") + dimension = field.get("dimension") + is_time = False + if dimension is not None: + is_time_explicit = dimension.get("is_time") + if is_time_explicit is not None: + is_time = bool(is_time_explicit) + else: + is_time = field.get("datatype") in ("Date", "Time", "DateTime", "DateTimez") + field.pop("datatype", None) + if is_time: + field["dimension"] = {"is_time": True} + else: + field.pop("dimension", None) # Drop backfilled key fields: a bare-column field named after a # primary_key column, carrying nothing but its expression. pk = set(ds.get("primary_key") or []) @@ -126,6 +137,7 @@ def strip_normalized(osi): rel.pop("custom_extensions", None) for metric in model.get("metrics", []) or []: metric.pop("custom_extensions", None) + metric.pop("datatype", None) # Metric order is not semantic; the import regroups metrics by the view # their measure lives on. if model.get("metrics"):