Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion converters/omni/src/osi_omni/osi_to_omni.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions converters/omni/tests/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [])
Expand All @@ -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"):
Expand Down