amitmiran137 commented on a change in pull request #13138:
URL: https://github.com/apache/superset/pull/13138#discussion_r576586650
##########
File path: tests/utils_tests.py
##########
@@ -1131,3 +1133,20 @@ def test_extract_dataframe_dtypes(self):
df = pd.DataFrame(data={col[0]: col[2] for col in cols})
assert extract_dataframe_dtypes(df) == [col[1] for col in cols]
+
+ def test_normalize_dttm_col(self):
+ ts = pd.Timestamp(2021, 2, 15, 19, 0, 0, 0)
+ df = pd.DataFrame([{"__timestamp": ts, "a": 1}])
+
+ # test non-numeric format
+ assert normalize_dttm_col(df, None, 0, None)[DTTM_ALIAS][0] == ts
+ assert normalize_dttm_col(df, "epoch_ms", 0, None)[DTTM_ALIAS][0] == ts
+ assert normalize_dttm_col(df, "epoch_s", 0, None)[DTTM_ALIAS][0] == ts
+
+ # test numeric epoch_s format
+ df = pd.DataFrame([{"__timestamp": ts.timestamp(), "a": 1}])
+ assert normalize_dttm_col(df, "epoch_s", 0, None)[DTTM_ALIAS][0] == ts
+
+ # test numeric epoch_ms format
+ df = pd.DataFrame([{"__timestamp": ts.timestamp() * 1000, "a": 1}])
+ assert normalize_dttm_col(df, "epoch_ms", 0, None)[DTTM_ALIAS][0] == ts
Review comment:
I'm missing 2 use-cases here:
1. offeset
2. timeshift
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]