Skip to content

Commit

Permalink
fix(metadb): handle durations (apache#25727)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Oct 20, 2023
1 parent 4ac8f82 commit ed87470
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions superset/extensions/metadb.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ def wrapper(self: SupersetShillelaghAdapter, *args: Any, **kwargs: Any) -> Any:
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):

Expand All @@ -180,6 +189,7 @@ class SupersetShillelaghAdapter(Adapter):
datetime.date: Date,
datetime.datetime: DateTime,
datetime.time: Time,
datetime.timedelta: Duration,
}

@staticmethod
Expand Down

0 comments on commit ed87470

Please sign in to comment.