jesperct commented on code in PR #41060:
URL: https://github.com/apache/superset/pull/41060#discussion_r3415571253


##########
superset/models/helpers.py:
##########
@@ -1564,6 +1565,49 @@ def exc_query(self, qry: Any) -> QueryResult:
         """
         return self.query(qry)
 
+    def _python_date_format(self, column: str | None) -> str | None:
+        """Return the column's configured ``python_date_format`` (e.g. 
``epoch_s``
+        or a strftime pattern), or ``None`` if the column declares no 
format."""
+        if not hasattr(self, "get_column"):
+            return None
+        column_obj = self.get_column(column)
+        if (
+            column_obj
+            and hasattr(column_obj, "python_date_format")
+            and (formatter := column_obj.python_date_format)
+        ):
+            return str(formatter)

Review Comment:
   Made `_python_date_format` read from a dict or an object via the same shape 
check as `_is_dttm`, so the two are symmetric. In practice both 
SqlaTable.get_column and Query.get_column return column objects rather than 
dicts, so this is a consistency/defensive change rather than a crash path. 
Added a dict-shaped-column unit test. Done in e25962b.



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