refactor: refine timestamp expr function (#21510)

This commit is contained in:
Yongjie Zhao
2022-09-20 18:51:01 +08:00
committed by GitHub
parent 42000823be
commit 737d4dcf0c
4 changed files with 6 additions and 9 deletions

View File

@@ -476,7 +476,6 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
col: ColumnClause,
pdf: Optional[str],
time_grain: Optional[str],
type_: Optional[str] = None,
) -> TimestampExpression:
"""
Construct a TimestampExpression to be used in a SQLAlchemy query.
@@ -484,10 +483,10 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
:param col: Target column for the TimestampExpression
:param pdf: date format (seconds or milliseconds)
:param time_grain: time grain, e.g. P1Y for 1 year
:param type_: the source column type
:return: TimestampExpression object
"""
if time_grain:
type_ = str(getattr(col, "type", ""))
time_expr = cls.get_time_grain_expressions().get(time_grain)
if not time_expr:
raise NotImplementedError(