rusackas commented on code in PR #40645:
URL: https://github.com/apache/superset/pull/40645#discussion_r3342380214


##########
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:
   Intentionally leaving this as `datetime.utcnow()`: `Log.dttm` is stored as a 
naive UTC datetime (`default=datetime.utcnow`), so switching to the aware 
`datetime.now(datetime.UTC)` would reintroduce the naive/aware comparison error 
on PostgreSQL that this PR fixes (see the earlier thread on this same line). 
The trailing comma is cosmetic and not required for a single-clause `where()`.



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