File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -109,21 +109,24 @@ def _build_formatted_time(
109109 exp_class : t .Type [E ], full_format_mapping : t .Optional [bool ] = None
110110) -> t .Callable [[t .List ], E ]:
111111 def _builder (args : t .List ) -> E :
112- assert len (args ) == 2
113-
114- return exp_class (
115- this = exp .cast (args [1 ], exp .DataType .Type .DATETIME2 ),
116- format = exp .Literal .string (
112+ fmt = seq_get (args , 0 )
113+ if isinstance (fmt , exp .Expression ):
114+ fmt = exp .Literal .string (
117115 format_time (
118- args [ 0 ] .name .lower (),
116+ fmt .name .lower (),
119117 (
120118 {** TSQL .TIME_MAPPING , ** FULL_FORMAT_TIME_MAPPING }
121119 if full_format_mapping
122120 else TSQL .TIME_MAPPING
123121 ),
124122 )
125- ),
126- )
123+ )
124+
125+ this = seq_get (args , 1 )
126+ if isinstance (this , exp .Expression ):
127+ this = exp .cast (this , exp .DataType .Type .DATETIME2 )
128+
129+ return exp_class (this = this , format = fmt )
127130
128131 return _builder
129132
You can’t perform that action at this time.
0 commit comments