File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313# implicitly casts a string literal first arg to the function's own temporal type,
1414# so map each to that type (e.g. DATE_ADD('2020-01-01', ...) -> DATE,
1515# TIMESTAMP_TRUNC('...') -> TIMESTAMP).
16- _DATE_FUNC_LITERAL_TYPE : dict [type [exp .Expr ], exp .DType ] = {
16+ _DateFunc = t .Union [
17+ exp .DateAdd ,
18+ exp .DateSub ,
19+ exp .DateTrunc ,
20+ exp .DatetimeTrunc ,
21+ exp .TimestampTrunc ,
22+ ]
23+
24+ _DATE_FUNC_LITERAL_TYPE : dict [type [_DateFunc ], exp .DType ] = {
1725 exp .DateAdd : exp .DType .DATE ,
1826 exp .DateSub : exp .DType .DATE ,
1927 exp .DateTrunc : exp .DType .DATE ,
2230}
2331
2432
25- def _annotate_date_func (self : TypeAnnotator , expression : exp . Expr ) -> exp .Expr :
33+ def _annotate_date_func (self : TypeAnnotator , expression : _DateFunc ) -> exp .Expr :
2634 """Annotate DATE_ADD / DATE_SUB / *_TRUNC, which return their first arg's type.
2735
2836 A typed first argument keeps its exact type (e.g. DATE_ADD(DATETIME, ...) ->
You can’t perform that action at this time.
0 commit comments