-
Notifications
You must be signed in to change notification settings - Fork 380
Fix: normalize datetime values to strings in unit tests #4696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2609,3 +2609,34 @@ def test_model_test_text_result_reporting_no_traceback( | |
| prefix = "ERROR" if is_error else "FAIL" | ||
| assert f"{prefix}: test_foo (None)" in output | ||
| assert "Exception: failure" in output | ||
|
|
||
|
|
||
| def test_timestamp_normalization() -> None: | ||
| model = _create_model( | ||
| "SELECT id, array_agg(timestamp_col::timestamp) as agg_timestamp_col FROM temp_model_with_timestamp GROUP BY id", | ||
| meta="MODEL (name foo, kind FULL)", | ||
| ) | ||
|
|
||
| _check_successful_or_raise( | ||
| _create_test( | ||
| body=load_yaml( | ||
| """ | ||
| test_foo: | ||
| model: temp_agg_model_with_timestamp | ||
| inputs: | ||
| temp_model_with_timestamp: | ||
| rows: | ||
| - id: "id1" | ||
| timestamp_col: "2024-01-02T15:00:00" | ||
| outputs: | ||
| query: | ||
| rows: | ||
| - id: id1 | ||
| agg_timestamp_col: ["2024-01-02T15:00:00.000000"] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would the same output comparison work properly if we compared an equivalent datetime value from a different string? E.g `2024-01-02T15:00:00.00" or one based on a different timezone that results in the same time? Ideally we'd normalize all datetime types into a common representation at a common timezone (?)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so, there's a test for this: https://github.com/TobikoData/sqlmesh/blob/f87d3f0a6dad639584a4b70540ac19010c0ca92c/tests/core/test_test.py#L1220
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like it's on the same timezone from a quick look, I was referring to a scenario such as : this test should be correct, right? But if it's a string comparison (or at best, normalized to a certain precision with zeroes) then it'd fail
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that we encourage specifying time zones in the timestamp values (in the sense that it's unsupported). The |
||
| """ | ||
| ), | ||
| test_name="test_foo", | ||
| model=model, | ||
| context=Context(config=Config(model_defaults=ModelDefaultsConfig(dialect="duckdb"))), | ||
| ).run() | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.