bito-code-review[bot] commented on code in PR #40645:
URL: https://github.com/apache/superset/pull/40645#discussion_r3342382171
##########
superset/commands/logs/prune.py:
##########
@@ -64,8 +64,11 @@ def run(self) -> None:
start_time = time.time()
# Select all IDs that need to be deleted
+ # Log.dttm is stored as a naive UTC datetime (no tzinfo), so compute
+ # the cutoff with utcnow() to avoid a naive/aware mismatch that raises
+ # on PostgreSQL ("operator does not exist: timestamp without time
zone").
select_stmt = sa.select(Log.id).where(
- Log.dttm < datetime.now() -
timedelta(days=self.retention_period_days)
+ Log.dttm < datetime.utcnow() -
timedelta(days=self.retention_period_days)
)
Review Comment:
<!-- Bito Reply -->
The suggestion to use `datetime.now(datetime.UTC)` is intended to improve
timezone awareness, but your assessment that it would reintroduce a naive/aware
comparison error with the existing PostgreSQL `Log.dttm` column is correct.
Given that the current implementation relies on naive UTC datetimes,
maintaining `datetime.utcnow()` is appropriate to avoid this runtime error. You
may safely ignore this suggestion.
--
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]