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 20:23:46 UTC
[superset] 01/01: fix(metadb): handle durations
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch meta_duration
in repository https://gitbox.apache.org/repos/asf/superset.git
commit ab6d5a6a59c833856d81b115e170a6bfab1db709
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Fri Oct 20 16:19:26 2023 -0400
fix(metadb): handle durations
---
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