You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2023/10/20 21:47:03 UTC
[superset] branch master updated: fix(metadb): handle durations (#25727)
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new ed87470bcc fix(metadb): handle durations (#25727)
ed87470bcc is described below
commit ed87470bcc8c85d403bc42c337352ec1e682ced0
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Fri Oct 20 17:46:57 2023 -0400
fix(metadb): handle durations (#25727)
---
superset/extensions/metadb.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/superset/extensions/metadb.py b/superset/extensions/metadb.py
index ef2c093475..5b014b7af6 100644
--- a/superset/extensions/metadb.py
+++ b/superset/extensions/metadb.py
@@ -155,6 +155,15 @@ def has_rowid(method: F) -> F:
return cast(F, wrapper)
+class Duration(Field[datetime.timedelta, datetime.timedelta]):
+ """
+ Shillelagh field used for representing durations as `timedelta` objects.
+ """
+
+ type = "DURATION"
+ db_api_type = "DATETIME"
+
+
# pylint: disable=too-many-instance-attributes
class SupersetShillelaghAdapter(Adapter):
@@ -180,6 +189,7 @@ class SupersetShillelaghAdapter(Adapter):
datetime.date: Date,
datetime.datetime: DateTime,
datetime.time: Time,
+ datetime.timedelta: Duration,
}
@staticmethod