You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ossie.apache.org by jb...@apache.org on 2026/09/19 11:37:23 UTC

(ossie) branch main updated: fix(omni): correct DateTimeTz datatype check so temporal fields keep time role (#423)

This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ossie.git


The following commit(s) were added to refs/heads/main by this push:
     new a5bdbbcd fix(omni): correct DateTimeTz datatype check so temporal fields keep time role (#423)
a5bdbbcd is described below

commit a5bdbbcd981c3dfb93f99ba8221602e1c3108f8c
Author: Chris Eubank <10...@users.noreply.github.com>
AuthorDate: Sat Sep 19 04:37:18 2026 -0700

    fix(omni): correct DateTimeTz datatype check so temporal fields keep time role (#423)
    
    The Ossie->Omni converter tested `datatype` against the non-existent string
    "DateTimez" when auto-detecting time dimensions. The spec DataType enum in
    core-spec/ossie-schema.json uses "DateTimeTz", so a field with
    `datatype: DateTimeTz` and no explicit `dimension.is_time` was not recognized
    as temporal: the emitted Omni dimension received no timeframes and lost its
    time role on round-trip. Correct the string and add regression tests.
    
    Co-authored-by: Isaac <no...@databricks.com>
---
 converters/omni/src/ossie_omni/ossie_to_omni.py |  2 +-
 converters/omni/tests/test_ossie_to_omni.py     | 33 +++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/converters/omni/src/ossie_omni/ossie_to_omni.py b/converters/omni/src/ossie_omni/ossie_to_omni.py
index 415d2eaa..00b22767 100644
--- a/converters/omni/src/ossie_omni/ossie_to_omni.py
+++ b/converters/omni/src/ossie_omni/ossie_to_omni.py
@@ -385,7 +385,7 @@ def _convert_field(field, dname, expr, fscope):
         if is_time_explicit is not None:
             is_time = bool(is_time_explicit)
         else:
-            is_time = field.get("datatype") in ("Date", "Time", "DateTime", "DateTimez")
+            is_time = field.get("datatype") in ("Date", "Time", "DateTime", "DateTimeTz")
     if is_time:
         # The stashed list wins even when empty (`timeframes: []` is a real
         # Omni value); the default list is only for hand-authored Ossie.
diff --git a/converters/omni/tests/test_ossie_to_omni.py b/converters/omni/tests/test_ossie_to_omni.py
index a3c8a53c..66d381ba 100644
--- a/converters/omni/tests/test_ossie_to_omni.py
+++ b/converters/omni/tests/test_ossie_to_omni.py
@@ -120,6 +120,39 @@ def test_is_time_maps_to_default_timeframes():
         "raw", "date", "week", "month", "quarter", "year"]
 
 
+@pytest.mark.parametrize("datatype", ["Date", "Time", "DateTime", "DateTimeTz"])
+def test_temporal_datatype_auto_detected_as_time_dimension(datatype):
+    # With no explicit dimension.is_time, a temporal datatype defaults to a
+    # time dimension and receives the default timeframes.
+    files = export(minimal(datasets=[
+        {"name": "orders", "source": "db.sch.orders",
+         "fields": [_field("event_time", datatype=datatype,
+                           dimension={"is_time": None})]}]))
+    dims = parse(files["views/orders.view.yaml"])["dimensions"]
+    assert dims["event_time"]["timeframes"] == [
+        "raw", "date", "week", "month", "quarter", "year"]
+
+
+def test_non_temporal_datatype_is_not_a_time_dimension():
+    files = export(minimal(datasets=[
+        {"name": "orders", "source": "db.sch.orders",
+         "fields": [_field("amount", datatype="Integer",
+                           dimension={"is_time": None})]}]))
+    assert "timeframes" not in parse(
+        files["views/orders.view.yaml"])["dimensions"]["amount"]
+
+
+def test_explicit_is_time_false_overrides_temporal_datatype():
+    # An explicit is_time: false opts a temporal-typed column out of
+    # time-dimension treatment regardless of datatype.
+    files = export(minimal(datasets=[
+        {"name": "orders", "source": "db.sch.orders",
+         "fields": [_field("audit_ts", datatype="DateTimeTz",
+                           dimension={"is_time": False})]}]))
+    assert "timeframes" not in parse(
+        files["views/orders.view.yaml"])["dimensions"]["audit_ts"]
+
+
 def test_single_primary_key_marks_dimension():
     files = export(minimal(datasets=[
         {"name": "orders", "source": "db.sch.orders", "primary_key": ["id"],