[CT-2558] [Feature] Make run_started_at
an aware Python datetime
#7581
Labels
enhancement
New feature or request
tech_debt
Behind-the-scenes changes, with little direct impact on end-user functionality
Is this your first time submitting a feature request?
Describe the feature
In the following source code, we can see how
run_started_at
is a naive(!) Python datetime representing the current time in UTC:dbt-core/core/dbt/context/base.py
Line 565 in dffbb6a
dbt-core/core/dbt/tracking.py
Line 118 in dffbb6a
dbt-core/core/dbt/tracking.py
Line 453 in dffbb6a
So that the
run_started_at
can be compared unambiguously with aware timestamps, it should probably be aware as well with one of the two approaches:dt.now(timezone.utc).isoformat()
(offset from UTC)dt.now().astimezone().isoformat()
(offset from system time zone)There's a good summary here of dbt Python datetimes.
But regardless of
deprecation_date
for dbt model versions, the fact that it's naive is tech debt that we should pay down, IMO by upgradingrun_started_at
to an aware timestamp with UTC offset of +00:00.Describe alternatives you've considered
The most obvious alternative is to leave it as-is (if it's not broke, don't fix it, right?).
I actually don't know if "fixing" this would have any unintended consequences for folks using it like either of these examples:
I would hope that it wouldn't break in either of those cases, but I didn't try them out one way or the other.
Who will this benefit?
One place this could come into play is here:
Are you interested in contributing this feature?
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: