-
Notifications
You must be signed in to change notification settings - Fork 4
Make dealership_adv8 Test For SQL Files Check Deterministic #508
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 |
|---|---|---|
|
|
@@ -3,7 +3,10 @@ | |
| """ | ||
|
|
||
| from collections.abc import Callable | ||
| from contextlib import nullcontext | ||
| from unittest.mock import patch | ||
|
|
||
| import pandas as pd | ||
| import pytest | ||
|
|
||
| from pydough import init_pydough_context, to_sql | ||
|
|
@@ -754,6 +757,10 @@ def test_graph_structure_defog(defog_graphs: graph_fetcher, graph_name: str) -> | |
| defog_sql_text_dealership_adv8, | ||
| "dealership_adv8", | ||
| order_sensitive=True, | ||
| # Pin today so the generated VALUES clause (6 month-start | ||
| # timestamps) stays deterministic. Reference files reflect | ||
| # the Oct 2025 – Mar 2026 window (today = 2026-04-01). | ||
| fixed_today=pd.Timestamp("2026-04-01"), | ||
|
Contributor
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 this would make the same 6 month range each time, wouldn't this be a problem next month for the expected result? Because
Contributor
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. That's the point of the PR. We are fixing the date to be the same for generating the exact same SQL files. It's not impacting the execution and the expected results of the query itself. The key is that both sides of the comparison are now frozen to the same fixed point for SQL file tests only. The execution test ( |
||
| ), | ||
| id="dealership_adv8", | ||
| ), | ||
|
|
@@ -2032,7 +2039,14 @@ def test_defog_until_sql( | |
| graph: GraphMetadata = get_dialect_defog_graphs( | ||
| empty_context_database.dialect, graph_name | ||
| ) | ||
| unqualified: UnqualifiedNode = init_pydough_context(graph)(unqualified_impl)() | ||
| fixed_today = defog_pipeline_test_data.fixed_today | ||
| ctx = ( | ||
| patch.object(pd.Timestamp, "today", return_value=fixed_today) | ||
| if fixed_today is not None | ||
| else nullcontext() | ||
| ) | ||
| with ctx: | ||
| unqualified: UnqualifiedNode = init_pydough_context(graph)(unqualified_impl)() | ||
| sql_text: str = to_sql( | ||
| unqualified, | ||
| metadata=graph, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed to update version to use new pyproject Syntax and get rid of the warning message.