codeant-ai-for-open-source[bot] commented on code in PR #42589:
URL: https://github.com/apache/superset/pull/42589#discussion_r3678757855


##########
tests/unit_tests/utils/test_core.py:
##########
@@ -359,6 +359,46 @@ def test_normalize_dttm_col_with_offset() -> None:
     assert df["date_col"][2].strftime("%Y-%m-%d %H:%M:%S") == "2022-01-01 
03:00:00"
 
 
+def test_normalize_dttm_col_second_precision_no_offset_matches_source() -> 
None:
+    """Regression test for #37925: second-precision timestamps with no
+    dataset offset configured ("UTC", i.e. offset=0) and no time shift must
+    pass through ``normalize_dttm_col`` unchanged and identically to their
+    source values, with no per-row drift.
+
+    The issue reports charts showing datetimes shifted by inconsistent,
+    non-uniform amounts versus the same data in SQL Lab, with the reporter's
+    own examples showing each shift exactly equal to that row's own
+    time-of-day (e.g. 16:30:00 shifted by +16h30m, 10:00:00 by +10h,
+    14:20:00 by +14h20m). ``normalize_dttm_col`` applies a single
+    ``_col.offset``/``_col.time_shift`` uniformly via ``timedelta(...)`` to
+    the whole column (see ``test_normalize_dttm_col_with_offset`` above,
+    already green), which cannot structurally produce a shift that varies
+    per row based on that row's own value, so this function is not the
+    mechanism the issue describes. This test locks in the specific
+    reported config (offset=0, no time_shift, second-level grain, multiple
+    distinct timestamps) end to end to make that explicit.
+    """
+    source_values = [
+        "2026-02-15 16:30:00",
+        "2026-02-15 10:00:00",
+        "2026-02-11 14:20:00",
+    ]
+    df = pd.DataFrame({"dttm": source_values})
+    dttm_cols = (
+        DateColumn(
+            col_label="dttm",
+            timestamp_format="%Y-%m-%d %H:%M:%S",
+            offset=0,
+            time_shift=None,
+        ),
+    )

Review Comment:
   **Suggestion:** This test only exercises `normalize_dttm_col` with a 
manually constructed, timezone-naive DataFrame and an explicitly supplied 
format. The chart paths construct `DateColumn` from datasource metadata and may 
provide an inferred format or already-native datetime values, so a defect in 
that construction, format detection, or timezone-aware parsing can remain 
undetected while this test passes. Add coverage through the relevant caller 
path or use representative metadata/native datetime inputs before treating this 
as a regression test for the reported chart behavior. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Chart normalization regressions can remain undetected.
   - ⚠️ `Viz.get_df()` metadata handling is untested.
   - ⚠️ Native timezone-aware datetime inputs are untested.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=a5c0a0a0d3824044ab593674396f1093&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=a5c0a0a0d3824044ab593674396f1093&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/utils/test_core.py
   **Line:** 386:394
   **Comment:**
        *Api Mismatch: This test only exercises `normalize_dttm_col` with a 
manually constructed, timezone-naive DataFrame and an explicitly supplied 
format. The chart paths construct `DateColumn` from datasource metadata and may 
provide an inferred format or already-native datetime values, so a defect in 
that construction, format detection, or timezone-aware parsing can remain 
undetected while this test passes. Add coverage through the relevant caller 
path or use representative metadata/native datetime inputs before treating this 
as a regression test for the reported chart behavior.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42589&comment_hash=5feca0734c5d3baba8a72265d2f30aab12277de9a0450e872fae1cb1244d65f1&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42589&comment_hash=5feca0734c5d3baba8a72265d2f30aab12277de9a0450e872fae1cb1244d65f1&reaction=dislike'>👎</a>



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to