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:45 UTC

[superset] branch meta_duration created (now ab6d5a6a59)

This is an automated email from the ASF dual-hosted git repository.

beto pushed a change to branch meta_duration
in repository https://gitbox.apache.org/repos/asf/superset.git


      at ab6d5a6a59 fix(metadb): handle durations

This branch includes the following new commits:

     new ab6d5a6a59 fix(metadb): handle durations

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[superset] 01/01: fix(metadb): handle durations

Posted by be...@apache.org.
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