diff --git a/superset/connectors/druid/models.py b/superset/connectors/druid/models.py index 47f9f4849340d..2a7e0f96a7502 100644 --- a/superset/connectors/druid/models.py +++ b/superset/connectors/druid/models.py @@ -57,7 +57,7 @@ from superset.models.helpers import AuditMixinNullable, ImportExportMixin, QueryResult from superset.typing import FilterValues, Granularity, Metric, QueryObjectDict from superset.utils import core as utils -from superset.utils.date_parser import parse_human_datetime +from superset.utils.date_parser import parse_human_datetime, parse_human_timedelta try: import requests @@ -796,7 +796,7 @@ def granularity( else: granularity["type"] = "duration" granularity["duration"] = ( - utils.parse_human_timedelta(period_name).total_seconds() # type: ignore + parse_human_timedelta(period_name).total_seconds() # type: ignore * 1000 ) return granularity diff --git a/superset/migrations/versions/3dda56f1c4c6_migrate_num_period_compare_and_period_.py b/superset/migrations/versions/3dda56f1c4c6_migrate_num_period_compare_and_period_.py index ca4de4e3e2ff5..1d0d81faaf2cf 100644 --- a/superset/migrations/versions/3dda56f1c4c6_migrate_num_period_compare_and_period_.py +++ b/superset/migrations/versions/3dda56f1c4c6_migrate_num_period_compare_and_period_.py @@ -33,7 +33,7 @@ from sqlalchemy.ext.declarative import declarative_base from superset import db -from superset.utils.core import parse_human_timedelta +from superset.utils.date_parser import parse_human_timedelta revision = "3dda56f1c4c6" down_revision = "bddc498dd179" diff --git a/superset/utils/date_parser.py b/superset/utils/date_parser.py index c8ece31fd6c11..aee2c83a0d7c3 100644 --- a/superset/utils/date_parser.py +++ b/superset/utils/date_parser.py @@ -17,7 +17,7 @@ import calendar import logging import re -from datetime import date, datetime, timedelta +from datetime import datetime, timedelta from time import struct_time from typing import List, Optional, Tuple diff --git a/superset/viz_sip38.py b/superset/viz_sip38.py index 0af949eefda2c..9ec1752741590 100644 --- a/superset/viz_sip38.py +++ b/superset/viz_sip38.py @@ -63,7 +63,7 @@ merge_extra_filters, to_adhoc, ) -from superset.utils.date_parser import get_since_until +from superset.utils.date_parser import get_since_until, parse_past_timedelta import dataclasses # isort:skip @@ -368,7 +368,7 @@ def query_obj(self) -> Dict[str, Any]: until=form_data.get("until"), ) time_shift = form_data.get("time_shift", "") - self.time_shift = utils.parse_past_timedelta(time_shift) + self.time_shift = parse_past_timedelta(time_shift) from_dttm = None if since is None else (since - self.time_shift) to_dttm = None if until is None else (until - self.time_shift) if from_dttm and to_dttm and from_dttm > to_dttm: @@ -1266,7 +1266,7 @@ def run_extra_queries(self): for option in time_compare: query_object = self.query_obj() - delta = utils.parse_past_timedelta(option) + delta = parse_past_timedelta(option) query_object["inner_from_dttm"] = query_object["from_dttm"] query_object["inner_to_dttm"] = query_object["to_dttm"]