Edit on GitHub

sqlglot expressions - date, time, and timestamp functions.

  1"""sqlglot expressions - date, time, and timestamp functions."""
  2
  3from __future__ import annotations
  4
  5import typing as t
  6
  7from sqlglot.expressions.core import (
  8    Expression,
  9    Func,
 10    TimeUnit,
 11    IntervalOp,
 12    Literal,
 13    Column,
 14    TIMESTAMP_PARTS,
 15)
 16from sqlglot.expressions.datatypes import DataType, DType
 17
 18if t.TYPE_CHECKING:
 19    from sqlglot.expressions.core import Expr, Neg
 20
 21
 22# Current date/time
 23
 24
 25class CurrentDate(Expression, Func):
 26    arg_types = {"this": False}
 27
 28
 29class CurrentDatetime(Expression, Func):
 30    arg_types = {"this": False}
 31
 32
 33class CurrentTime(Expression, Func):
 34    arg_types = {"this": False}
 35
 36
 37class CurrentTimestamp(Expression, Func):
 38    arg_types = {"this": False, "sysdate": False}
 39
 40
 41class CurrentTimestampLTZ(Expression, Func):
 42    arg_types = {}
 43
 44
 45class CurrentTimezone(Expression, Func):
 46    arg_types = {}
 47
 48
 49class Localtime(Expression, Func):
 50    arg_types = {"this": False}
 51
 52
 53class Localtimestamp(Expression, Func):
 54    arg_types = {"this": False}
 55
 56
 57class Systimestamp(Expression, Func):
 58    arg_types = {"this": False}
 59
 60
 61class UtcDate(Expression, Func):
 62    arg_types = {}
 63
 64
 65class UtcTime(Expression, Func):
 66    arg_types = {"this": False}
 67
 68
 69class UtcTimestamp(Expression, Func):
 70    arg_types = {"this": False}
 71
 72
 73# Date arithmetic
 74
 75
 76class AddMonths(Expression, Func):
 77    arg_types = {"this": True, "expression": True, "preserve_end_of_month": False}
 78
 79
 80class DateAdd(Expression, Func, IntervalOp):
 81    arg_types = {"this": True, "expression": True, "unit": False}
 82
 83
 84class DateBin(Expression, Func, IntervalOp):
 85    arg_types = {"this": True, "expression": True, "unit": False, "zone": False, "origin": False}
 86
 87
 88class DateDiff(Expression, Func, TimeUnit):
 89    _sql_names = ["DATEDIFF", "DATE_DIFF"]
 90    arg_types = {
 91        "this": True,
 92        "expression": True,
 93        "unit": False,
 94        "zone": False,
 95        "big_int": False,
 96        "date_part_boundary": False,
 97    }
 98
 99
100class DateSub(Expression, Func, IntervalOp):
101    arg_types = {"this": True, "expression": True, "unit": False}
102
103
104class DatetimeAdd(Expression, Func, IntervalOp):
105    arg_types = {"this": True, "expression": True, "unit": False}
106
107
108class DatetimeDiff(Expression, Func, TimeUnit):
109    arg_types = {"this": True, "expression": True, "unit": False, "date_part_boundary": False}
110
111
112class DatetimeSub(Expression, Func, IntervalOp):
113    arg_types = {"this": True, "expression": True, "unit": False}
114
115
116class MonthsBetween(Expression, Func):
117    arg_types = {"this": True, "expression": True, "roundoff": False}
118
119
120class TimeAdd(Expression, Func, TimeUnit):
121    arg_types = {"this": True, "expression": True, "unit": False}
122
123
124class TimeDiff(Expression, Func, TimeUnit):
125    arg_types = {"this": True, "expression": True, "unit": False}
126
127
128class TimeSub(Expression, Func, TimeUnit):
129    arg_types = {"this": True, "expression": True, "unit": False}
130
131
132class TimestampAdd(Expression, Func, TimeUnit):
133    arg_types = {"this": True, "expression": True, "unit": False}
134
135
136class TimestampDiff(Expression, Func, TimeUnit):
137    _sql_names = ["TIMESTAMPDIFF", "TIMESTAMP_DIFF"]
138    arg_types = {"this": True, "expression": True, "unit": False, "boundary_for_date": False}
139
140
141class TimestampSub(Expression, Func, TimeUnit):
142    arg_types = {"this": True, "expression": True, "unit": False}
143
144
145class TsOrDsAdd(Expression, Func, TimeUnit):
146    # return_type is used to correctly cast the arguments of this expression when transpiling it
147    arg_types = {"this": True, "expression": True, "unit": False, "return_type": False}
148
149    @property
150    def return_type(self) -> DataType:
151        return DataType.build(self.args.get("return_type") or DType.DATE)
152
153
154class TsOrDsDiff(Expression, Func, TimeUnit):
155    arg_types = {"this": True, "expression": True, "unit": False}
156
157
158# Truncation
159
160
161class DatetimeTrunc(Expression, Func, TimeUnit):
162    arg_types = {"this": True, "unit": True, "zone": False}
163
164
165class DateTrunc(Expression, Func):
166    arg_types = {
167        "unit": True,
168        "this": True,
169        "zone": False,
170        "input_type_preserved": False,
171        "century_from_zero": False,
172    }
173
174    def __init__(self, **args):
175        # Across most dialects it's safe to unabbreviate the unit (e.g. 'Q' -> 'QUARTER') except Oracle
176        # https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ROUND-and-TRUNC-Date-Functions.html
177        unabbreviate = args.pop("unabbreviate", True)
178
179        unit = args.get("unit")
180        if isinstance(unit, TimeUnit.VAR_LIKE) and not (
181            isinstance(unit, Column) and len(unit.parts) != 1
182        ):
183            unit_name = unit.name.upper()
184            if unabbreviate and unit_name in TimeUnit.UNABBREVIATED_UNIT_NAME:
185                unit_name = TimeUnit.UNABBREVIATED_UNIT_NAME[unit_name]
186
187            args["unit"] = Literal.string(unit_name)
188
189        super().__init__(**args)
190
191    @property
192    def unit(self) -> Expr:
193        return self.args["unit"]
194
195
196class TimestampTrunc(Expression, Func, TimeUnit):
197    arg_types = {
198        "this": True,
199        "unit": True,
200        "zone": False,
201        "input_type_preserved": False,
202        "century_from_zero": False,
203    }
204
205
206class TimeSlice(Expression, Func, TimeUnit):
207    arg_types = {"this": True, "expression": True, "unit": True, "kind": False, "origin": False}
208
209
210class TimeTrunc(Expression, Func, TimeUnit):
211    arg_types = {"this": True, "unit": True, "zone": False}
212
213
214# Date/time extraction
215
216
217class Day(Expression, Func):
218    pass
219
220
221class DayOfMonth(Expression, Func):
222    _sql_names = ["DAY_OF_MONTH", "DAYOFMONTH"]
223
224
225class DayOfWeek(Expression, Func):
226    """Sunday is 1 by default, or 0 when zero_based is set."""
227
228    arg_types = {"this": True, "zero_based": False}
229    _sql_names = ["DAY_OF_WEEK", "DAYOFWEEK"]
230
231
232class DayOfWeekIso(Expression, Func):
233    _sql_names = ["DAYOFWEEK_ISO", "ISODOW"]
234
235
236class DayOfYear(Expression, Func):
237    _sql_names = ["DAY_OF_YEAR", "DAYOFYEAR"]
238
239
240class Dayname(Expression, Func):
241    arg_types = {"this": True, "abbreviated": False}
242
243
244class Extract(Expression, Func):
245    arg_types = {
246        "this": True,
247        "expression": True,
248        "date_part": False,
249        "zero_based_dow": False,
250        "uses_session_timezone": False,
251    }
252
253
254class GetExtract(Expression, Func):
255    arg_types = {"this": True, "expression": True}
256
257
258class Hour(Expression, Func):
259    pass
260
261
262class Minute(Expression, Func):
263    pass
264
265
266class Month(Expression, Func):
267    pass
268
269
270class Monthname(Expression, Func):
271    arg_types = {"this": True, "abbreviated": False}
272
273
274class Quarter(Expression, Func):
275    pass
276
277
278class Second(Expression, Func):
279    pass
280
281
282class ToDays(Expression, Func):
283    pass
284
285
286class Week(Expression, Func):
287    arg_types = {"this": True, "mode": False}
288
289
290class WeekOfYear(Expression, Func):
291    _sql_names = ["WEEK_OF_YEAR", "WEEKOFYEAR"]
292
293
294class Year(Expression, Func):
295    pass
296
297
298class YearOfWeek(Expression, Func):
299    _sql_names = ["YEAR_OF_WEEK", "YEAROFWEEK"]
300
301
302class YearOfWeekIso(Expression, Func):
303    _sql_names = ["YEAR_OF_WEEK_ISO", "YEAROFWEEKISO"]
304
305
306# Date/time construction
307
308
309class Date(Expression, Func):
310    arg_types = {"this": False, "zone": False, "expressions": False}
311    is_var_len_args = True
312
313
314class DateFromParts(Expression, Func):
315    _sql_names = ["DATE_FROM_PARTS", "DATEFROMPARTS"]
316    arg_types = {"year": True, "month": False, "day": False, "allow_overflow": False}
317
318
319class DateFromUnixDate(Expression, Func):
320    pass
321
322
323class Datetime(Expression, Func):
324    arg_types = {"this": True, "expression": False}
325
326
327class GapFill(Expression, Func):
328    arg_types = {
329        "this": True,
330        "ts_column": True,
331        "bucket_width": True,
332        "partitioning_columns": False,
333        "value_columns": False,
334        "origin": False,
335        "ignore_nulls": False,
336    }
337
338
339class GenerateDateArray(Expression, Func):
340    arg_types = {"start": True, "end": True, "step": False}
341
342
343class GenerateTimestampArray(Expression, Func):
344    arg_types = {"start": True, "end": True, "step": True}
345
346
347class JustifyDays(Expression, Func):
348    pass
349
350
351class JustifyHours(Expression, Func):
352    pass
353
354
355class JustifyInterval(Expression, Func):
356    pass
357
358
359class LastDay(Expression, Func, TimeUnit):
360    _sql_names = ["LAST_DAY", "LAST_DAY_OF_MONTH"]
361    arg_types = {"this": True, "unit": False}
362
363
364class MakeInterval(Expression, Func):
365    arg_types = {
366        "year": False,
367        "month": False,
368        "week": False,
369        "day": False,
370        "hour": False,
371        "minute": False,
372        "second": False,
373    }
374
375
376class NextDay(Expression, Func):
377    arg_types = {"this": True, "expression": True}
378
379
380class PreviousDay(Expression, Func):
381    arg_types = {"this": True, "expression": True}
382
383
384class Time(Expression, Func):
385    arg_types = {"this": False, "zone": False}
386
387
388class TimeFromParts(Expression, Func):
389    _sql_names = ["TIME_FROM_PARTS", "TIMEFROMPARTS"]
390    arg_types = {
391        "hour": True,
392        "min": True,
393        "sec": True,
394        "nano": False,
395        "fractions": False,
396        "precision": False,
397        "overflow": False,
398    }
399
400
401class Timestamp(Expression, Func):
402    arg_types = {"this": False, "zone": False, "with_tz": False}
403
404
405class TimestampFromParts(Expression, Func):
406    _sql_names = ["TIMESTAMP_FROM_PARTS", "TIMESTAMPFROMPARTS"]
407    arg_types = {
408        **TIMESTAMP_PARTS,
409        "zone": False,
410        "milli": False,
411        "this": False,
412        "expression": False,
413    }
414
415
416class TimestampLtzFromParts(Expression, Func):
417    _sql_names = ["TIMESTAMP_LTZ_FROM_PARTS", "TIMESTAMPLTZFROMPARTS"]
418    arg_types = TIMESTAMP_PARTS.copy()
419
420
421class TimestampTzFromParts(Expression, Func):
422    _sql_names = ["TIMESTAMP_TZ_FROM_PARTS", "TIMESTAMPTZFROMPARTS"]
423    arg_types = {
424        **TIMESTAMP_PARTS,
425        "zone": False,
426    }
427
428
429# Date/time conversion
430
431
432class ConvertTimezone(Expression, Func):
433    arg_types = {
434        "source_tz": False,
435        "target_tz": True,
436        "timestamp": True,
437        "options": False,
438    }
439
440
441class DateStrToDate(Expression, Func):
442    pass
443
444
445class DateToDateStr(Expression, Func):
446    pass
447
448
449class DateToDi(Expression, Func):
450    pass
451
452
453class DiToDate(Expression, Func):
454    pass
455
456
457class FromISO8601Timestamp(Expression, Func):
458    _sql_names = ["FROM_ISO8601_TIMESTAMP"]
459
460
461class FromISO8601Date(Expression, Func):
462    _sql_names = ["FROM_ISO8601_DATE"]
463
464
465class FromISO8601TimestampNanos(Expression, Func):
466    _sql_names = ["FROM_ISO8601_TIMESTAMP_NANOS"]
467
468
469class ParseDatetime(Expression, Func):
470    arg_types = {"this": True, "format": False, "zone": False, "default_year": False}
471
472
473class ParseTime(Expression, Func):
474    arg_types = {"this": True, "format": True}
475
476
477class StrToDate(Expression, Func):
478    arg_types = {
479        "this": True,
480        "format": False,
481        "safe": False,
482        "default_year": False,
483        "nlsparam": False,
484    }
485
486
487class StrToTime(Expression, Func):
488    arg_types = {
489        "this": True,
490        "format": True,
491        "zone": False,
492        "safe": False,
493        "target_type": False,
494        "default_year": False,
495        "nlsparam": False,
496    }
497
498
499class StrToUnix(Expression, Func):
500    arg_types = {"this": False, "format": False}
501
502
503class TimeStrToDate(Expression, Func):
504    pass
505
506
507class TimeStrToTime(Expression, Func):
508    arg_types = {"this": True, "zone": False}
509
510
511class TimeStrToUnix(Expression, Func):
512    pass
513
514
515class TimeToStr(Expression, Func):
516    # joda: parsed from Presto/Trino's FORMAT_DATETIME, which DATE_FORMAT can't always express
517    arg_types = {"this": True, "format": True, "culture": False, "zone": False, "joda": False}
518
519
520class TimeToTimeStr(Expression, Func):
521    pass
522
523
524class TimeToUnix(Expression, Func):
525    pass
526
527
528class TsOrDiToDi(Expression, Func):
529    pass
530
531
532class TsOrDsToDate(Expression, Func):
533    arg_types = {"this": True, "format": False, "safe": False, "default_date": False}
534
535
536class TsOrDsToDateStr(Expression, Func):
537    pass
538
539
540class TsOrDsToDatetime(Expression, Func):
541    pass
542
543
544class TsOrDsToTime(Expression, Func):
545    arg_types = {"this": True, "format": False, "safe": False}
546
547
548class TsOrDsToTimestamp(Expression, Func):
549    pass
550
551
552class UnixDate(Expression, Func):
553    pass
554
555
556class UnixMicros(Expression, Func):
557    pass
558
559
560class UnixMillis(Expression, Func):
561    pass
562
563
564class UnixSeconds(Expression, Func):
565    pass
566
567
568class UnixToStr(Expression, Func):
569    arg_types = {"this": True, "format": False}
570
571
572class UnixToTime(Expression, Func):
573    arg_types = {
574        "this": True,
575        "scale": False,
576        "zone": False,
577        "hours": False,
578        "minutes": False,
579        "format": False,
580        "target_type": False,
581    }
582
583    SECONDS: t.ClassVar[Literal | Neg] = Literal.number(0)
584    DECIS: t.ClassVar[Literal | Neg] = Literal.number(1)
585    CENTIS: t.ClassVar[Literal | Neg] = Literal.number(2)
586    MILLIS: t.ClassVar[Literal | Neg] = Literal.number(3)
587    DECIMILLIS: t.ClassVar[Literal | Neg] = Literal.number(4)
588    CENTIMILLIS: t.ClassVar[Literal | Neg] = Literal.number(5)
589    MICROS: t.ClassVar[Literal | Neg] = Literal.number(6)
590    DECIMICROS: t.ClassVar[Literal | Neg] = Literal.number(7)
591    CENTIMICROS: t.ClassVar[Literal | Neg] = Literal.number(8)
592    NANOS: t.ClassVar[Literal | Neg] = Literal.number(9)
593
594
595class UnixToTimeStr(Expression, Func):
596    pass
26class CurrentDate(Expression, Func):
27    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'currentdate'
required_args: 't.ClassVar[set[str]]' = set()
30class CurrentDatetime(Expression, Func):
31    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'currentdatetime'
required_args: 't.ClassVar[set[str]]' = set()
34class CurrentTime(Expression, Func):
35    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'currenttime'
required_args: 't.ClassVar[set[str]]' = set()
38class CurrentTimestamp(Expression, Func):
39    arg_types = {"this": False, "sysdate": False}
arg_types = {'this': False, 'sysdate': False}
key: ClassVar[str] = 'currenttimestamp'
required_args: 't.ClassVar[set[str]]' = set()
class CurrentTimestampLTZ(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
42class CurrentTimestampLTZ(Expression, Func):
43    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currenttimestampltz'
required_args: 't.ClassVar[set[str]]' = set()
46class CurrentTimezone(Expression, Func):
47    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currenttimezone'
required_args: 't.ClassVar[set[str]]' = set()
50class Localtime(Expression, Func):
51    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'localtime'
required_args: 't.ClassVar[set[str]]' = set()
54class Localtimestamp(Expression, Func):
55    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'localtimestamp'
required_args: 't.ClassVar[set[str]]' = set()
58class Systimestamp(Expression, Func):
59    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'systimestamp'
required_args: 't.ClassVar[set[str]]' = set()
62class UtcDate(Expression, Func):
63    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'utcdate'
required_args: 't.ClassVar[set[str]]' = set()
66class UtcTime(Expression, Func):
67    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'utctime'
required_args: 't.ClassVar[set[str]]' = set()
70class UtcTimestamp(Expression, Func):
71    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'utctimestamp'
required_args: 't.ClassVar[set[str]]' = set()
77class AddMonths(Expression, Func):
78    arg_types = {"this": True, "expression": True, "preserve_end_of_month": False}
arg_types = {'this': True, 'expression': True, 'preserve_end_of_month': False}
key: ClassVar[str] = 'addmonths'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
81class DateAdd(Expression, Func, IntervalOp):
82    arg_types = {"this": True, "expression": True, "unit": False}
arg_types = {'this': True, 'expression': True, 'unit': False}
key: ClassVar[str] = 'dateadd'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
85class DateBin(Expression, Func, IntervalOp):
86    arg_types = {"this": True, "expression": True, "unit": False, "zone": False, "origin": False}
arg_types = {'this': True, 'expression': True, 'unit': False, 'zone': False, 'origin': False}
key: ClassVar[str] = 'datebin'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
89class DateDiff(Expression, Func, TimeUnit):
90    _sql_names = ["DATEDIFF", "DATE_DIFF"]
91    arg_types = {
92        "this": True,
93        "expression": True,
94        "unit": False,
95        "zone": False,
96        "big_int": False,
97        "date_part_boundary": False,
98    }
arg_types = {'this': True, 'expression': True, 'unit': False, 'zone': False, 'big_int': False, 'date_part_boundary': False}
key: ClassVar[str] = 'datediff'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
101class DateSub(Expression, Func, IntervalOp):
102    arg_types = {"this": True, "expression": True, "unit": False}
arg_types = {'this': True, 'expression': True, 'unit': False}
key: ClassVar[str] = 'datesub'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
105class DatetimeAdd(Expression, Func, IntervalOp):
106    arg_types = {"this": True, "expression": True, "unit": False}
arg_types = {'this': True, 'expression': True, 'unit': False}
key: ClassVar[str] = 'datetimeadd'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
109class DatetimeDiff(Expression, Func, TimeUnit):
110    arg_types = {"this": True, "expression": True, "unit": False, "date_part_boundary": False}
arg_types = {'this': True, 'expression': True, 'unit': False, 'date_part_boundary': False}
key: ClassVar[str] = 'datetimediff'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
113class DatetimeSub(Expression, Func, IntervalOp):
114    arg_types = {"this": True, "expression": True, "unit": False}
arg_types = {'this': True, 'expression': True, 'unit': False}
key: ClassVar[str] = 'datetimesub'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
117class MonthsBetween(Expression, Func):
118    arg_types = {"this": True, "expression": True, "roundoff": False}
arg_types = {'this': True, 'expression': True, 'roundoff': False}
key: ClassVar[str] = 'monthsbetween'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
121class TimeAdd(Expression, Func, TimeUnit):
122    arg_types = {"this": True, "expression": True, "unit": False}
arg_types = {'this': True, 'expression': True, 'unit': False}
key: ClassVar[str] = 'timeadd'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
125class TimeDiff(Expression, Func, TimeUnit):
126    arg_types = {"this": True, "expression": True, "unit": False}
arg_types = {'this': True, 'expression': True, 'unit': False}
key: ClassVar[str] = 'timediff'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
129class TimeSub(Expression, Func, TimeUnit):
130    arg_types = {"this": True, "expression": True, "unit": False}
arg_types = {'this': True, 'expression': True, 'unit': False}
key: ClassVar[str] = 'timesub'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
133class TimestampAdd(Expression, Func, TimeUnit):
134    arg_types = {"this": True, "expression": True, "unit": False}
arg_types = {'this': True, 'expression': True, 'unit': False}
key: ClassVar[str] = 'timestampadd'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
137class TimestampDiff(Expression, Func, TimeUnit):
138    _sql_names = ["TIMESTAMPDIFF", "TIMESTAMP_DIFF"]
139    arg_types = {"this": True, "expression": True, "unit": False, "boundary_for_date": False}
arg_types = {'this': True, 'expression': True, 'unit': False, 'boundary_for_date': False}
key: ClassVar[str] = 'timestampdiff'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
142class TimestampSub(Expression, Func, TimeUnit):
143    arg_types = {"this": True, "expression": True, "unit": False}
arg_types = {'this': True, 'expression': True, 'unit': False}
key: ClassVar[str] = 'timestampsub'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
146class TsOrDsAdd(Expression, Func, TimeUnit):
147    # return_type is used to correctly cast the arguments of this expression when transpiling it
148    arg_types = {"this": True, "expression": True, "unit": False, "return_type": False}
149
150    @property
151    def return_type(self) -> DataType:
152        return DataType.build(self.args.get("return_type") or DType.DATE)
arg_types = {'this': True, 'expression': True, 'unit': False, 'return_type': False}
return_type: sqlglot.expressions.datatypes.DataType
150    @property
151    def return_type(self) -> DataType:
152        return DataType.build(self.args.get("return_type") or DType.DATE)
key: ClassVar[str] = 'tsordsadd'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
155class TsOrDsDiff(Expression, Func, TimeUnit):
156    arg_types = {"this": True, "expression": True, "unit": False}
arg_types = {'this': True, 'expression': True, 'unit': False}
key: ClassVar[str] = 'tsordsdiff'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
162class DatetimeTrunc(Expression, Func, TimeUnit):
163    arg_types = {"this": True, "unit": True, "zone": False}
arg_types = {'this': True, 'unit': True, 'zone': False}
key: ClassVar[str] = 'datetimetrunc'
required_args: 't.ClassVar[set[str]]' = {'unit', 'this'}
166class DateTrunc(Expression, Func):
167    arg_types = {
168        "unit": True,
169        "this": True,
170        "zone": False,
171        "input_type_preserved": False,
172        "century_from_zero": False,
173    }
174
175    def __init__(self, **args):
176        # Across most dialects it's safe to unabbreviate the unit (e.g. 'Q' -> 'QUARTER') except Oracle
177        # https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ROUND-and-TRUNC-Date-Functions.html
178        unabbreviate = args.pop("unabbreviate", True)
179
180        unit = args.get("unit")
181        if isinstance(unit, TimeUnit.VAR_LIKE) and not (
182            isinstance(unit, Column) and len(unit.parts) != 1
183        ):
184            unit_name = unit.name.upper()
185            if unabbreviate and unit_name in TimeUnit.UNABBREVIATED_UNIT_NAME:
186                unit_name = TimeUnit.UNABBREVIATED_UNIT_NAME[unit_name]
187
188            args["unit"] = Literal.string(unit_name)
189
190        super().__init__(**args)
191
192    @property
193    def unit(self) -> Expr:
194        return self.args["unit"]
DateTrunc(**args)
175    def __init__(self, **args):
176        # Across most dialects it's safe to unabbreviate the unit (e.g. 'Q' -> 'QUARTER') except Oracle
177        # https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ROUND-and-TRUNC-Date-Functions.html
178        unabbreviate = args.pop("unabbreviate", True)
179
180        unit = args.get("unit")
181        if isinstance(unit, TimeUnit.VAR_LIKE) and not (
182            isinstance(unit, Column) and len(unit.parts) != 1
183        ):
184            unit_name = unit.name.upper()
185            if unabbreviate and unit_name in TimeUnit.UNABBREVIATED_UNIT_NAME:
186                unit_name = TimeUnit.UNABBREVIATED_UNIT_NAME[unit_name]
187
188            args["unit"] = Literal.string(unit_name)
189
190        super().__init__(**args)
arg_types = {'unit': True, 'this': True, 'zone': False, 'input_type_preserved': False, 'century_from_zero': False}
unit: sqlglot.expressions.core.Expr
192    @property
193    def unit(self) -> Expr:
194        return self.args["unit"]
key: ClassVar[str] = 'datetrunc'
required_args: 't.ClassVar[set[str]]' = {'unit', 'this'}
197class TimestampTrunc(Expression, Func, TimeUnit):
198    arg_types = {
199        "this": True,
200        "unit": True,
201        "zone": False,
202        "input_type_preserved": False,
203        "century_from_zero": False,
204    }
arg_types = {'this': True, 'unit': True, 'zone': False, 'input_type_preserved': False, 'century_from_zero': False}
key: ClassVar[str] = 'timestamptrunc'
required_args: 't.ClassVar[set[str]]' = {'unit', 'this'}
207class TimeSlice(Expression, Func, TimeUnit):
208    arg_types = {"this": True, "expression": True, "unit": True, "kind": False, "origin": False}
arg_types = {'this': True, 'expression': True, 'unit': True, 'kind': False, 'origin': False}
key: ClassVar[str] = 'timeslice'
required_args: 't.ClassVar[set[str]]' = {'unit', 'expression', 'this'}
211class TimeTrunc(Expression, Func, TimeUnit):
212    arg_types = {"this": True, "unit": True, "zone": False}
arg_types = {'this': True, 'unit': True, 'zone': False}
key: ClassVar[str] = 'timetrunc'
required_args: 't.ClassVar[set[str]]' = {'unit', 'this'}
218class Day(Expression, Func):
219    pass
key: ClassVar[str] = 'day'
required_args: 't.ClassVar[set[str]]' = {'this'}
222class DayOfMonth(Expression, Func):
223    _sql_names = ["DAY_OF_MONTH", "DAYOFMONTH"]
key: ClassVar[str] = 'dayofmonth'
required_args: 't.ClassVar[set[str]]' = {'this'}
226class DayOfWeek(Expression, Func):
227    """Sunday is 1 by default, or 0 when zero_based is set."""
228
229    arg_types = {"this": True, "zero_based": False}
230    _sql_names = ["DAY_OF_WEEK", "DAYOFWEEK"]

Sunday is 1 by default, or 0 when zero_based is set.

arg_types = {'this': True, 'zero_based': False}
key: ClassVar[str] = 'dayofweek'
required_args: 't.ClassVar[set[str]]' = {'this'}
233class DayOfWeekIso(Expression, Func):
234    _sql_names = ["DAYOFWEEK_ISO", "ISODOW"]
key: ClassVar[str] = 'dayofweekiso'
required_args: 't.ClassVar[set[str]]' = {'this'}
237class DayOfYear(Expression, Func):
238    _sql_names = ["DAY_OF_YEAR", "DAYOFYEAR"]
key: ClassVar[str] = 'dayofyear'
required_args: 't.ClassVar[set[str]]' = {'this'}
241class Dayname(Expression, Func):
242    arg_types = {"this": True, "abbreviated": False}
arg_types = {'this': True, 'abbreviated': False}
key: ClassVar[str] = 'dayname'
required_args: 't.ClassVar[set[str]]' = {'this'}
245class Extract(Expression, Func):
246    arg_types = {
247        "this": True,
248        "expression": True,
249        "date_part": False,
250        "zero_based_dow": False,
251        "uses_session_timezone": False,
252    }
arg_types = {'this': True, 'expression': True, 'date_part': False, 'zero_based_dow': False, 'uses_session_timezone': False}
key: ClassVar[str] = 'extract'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
255class GetExtract(Expression, Func):
256    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'getextract'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
259class Hour(Expression, Func):
260    pass
key: ClassVar[str] = 'hour'
required_args: 't.ClassVar[set[str]]' = {'this'}
263class Minute(Expression, Func):
264    pass
key: ClassVar[str] = 'minute'
required_args: 't.ClassVar[set[str]]' = {'this'}
267class Month(Expression, Func):
268    pass
key: ClassVar[str] = 'month'
required_args: 't.ClassVar[set[str]]' = {'this'}
271class Monthname(Expression, Func):
272    arg_types = {"this": True, "abbreviated": False}
arg_types = {'this': True, 'abbreviated': False}
key: ClassVar[str] = 'monthname'
required_args: 't.ClassVar[set[str]]' = {'this'}
275class Quarter(Expression, Func):
276    pass
key: ClassVar[str] = 'quarter'
required_args: 't.ClassVar[set[str]]' = {'this'}
279class Second(Expression, Func):
280    pass
key: ClassVar[str] = 'second'
required_args: 't.ClassVar[set[str]]' = {'this'}
283class ToDays(Expression, Func):
284    pass
key: ClassVar[str] = 'todays'
required_args: 't.ClassVar[set[str]]' = {'this'}
287class Week(Expression, Func):
288    arg_types = {"this": True, "mode": False}
arg_types = {'this': True, 'mode': False}
key: ClassVar[str] = 'week'
required_args: 't.ClassVar[set[str]]' = {'this'}
291class WeekOfYear(Expression, Func):
292    _sql_names = ["WEEK_OF_YEAR", "WEEKOFYEAR"]
key: ClassVar[str] = 'weekofyear'
required_args: 't.ClassVar[set[str]]' = {'this'}
295class Year(Expression, Func):
296    pass
key: ClassVar[str] = 'year'
required_args: 't.ClassVar[set[str]]' = {'this'}
299class YearOfWeek(Expression, Func):
300    _sql_names = ["YEAR_OF_WEEK", "YEAROFWEEK"]
key: ClassVar[str] = 'yearofweek'
required_args: 't.ClassVar[set[str]]' = {'this'}
303class YearOfWeekIso(Expression, Func):
304    _sql_names = ["YEAR_OF_WEEK_ISO", "YEAROFWEEKISO"]
key: ClassVar[str] = 'yearofweekiso'
required_args: 't.ClassVar[set[str]]' = {'this'}
310class Date(Expression, Func):
311    arg_types = {"this": False, "zone": False, "expressions": False}
312    is_var_len_args = True
arg_types = {'this': False, 'zone': False, 'expressions': False}
is_var_len_args = True
key: ClassVar[str] = 'date'
required_args: 't.ClassVar[set[str]]' = set()
315class DateFromParts(Expression, Func):
316    _sql_names = ["DATE_FROM_PARTS", "DATEFROMPARTS"]
317    arg_types = {"year": True, "month": False, "day": False, "allow_overflow": False}
arg_types = {'year': True, 'month': False, 'day': False, 'allow_overflow': False}
key: ClassVar[str] = 'datefromparts'
required_args: 't.ClassVar[set[str]]' = {'year'}
320class DateFromUnixDate(Expression, Func):
321    pass
key: ClassVar[str] = 'datefromunixdate'
required_args: 't.ClassVar[set[str]]' = {'this'}
324class Datetime(Expression, Func):
325    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'datetime'
required_args: 't.ClassVar[set[str]]' = {'this'}
328class GapFill(Expression, Func):
329    arg_types = {
330        "this": True,
331        "ts_column": True,
332        "bucket_width": True,
333        "partitioning_columns": False,
334        "value_columns": False,
335        "origin": False,
336        "ignore_nulls": False,
337    }
arg_types = {'this': True, 'ts_column': True, 'bucket_width': True, 'partitioning_columns': False, 'value_columns': False, 'origin': False, 'ignore_nulls': False}
key: ClassVar[str] = 'gapfill'
required_args: 't.ClassVar[set[str]]' = {'ts_column', 'bucket_width', 'this'}
340class GenerateDateArray(Expression, Func):
341    arg_types = {"start": True, "end": True, "step": False}
arg_types = {'start': True, 'end': True, 'step': False}
key: ClassVar[str] = 'generatedatearray'
required_args: 't.ClassVar[set[str]]' = {'end', 'start'}
class GenerateTimestampArray(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
344class GenerateTimestampArray(Expression, Func):
345    arg_types = {"start": True, "end": True, "step": True}
arg_types = {'start': True, 'end': True, 'step': True}
key: ClassVar[str] = 'generatetimestamparray'
required_args: 't.ClassVar[set[str]]' = {'step', 'end', 'start'}
348class JustifyDays(Expression, Func):
349    pass
key: ClassVar[str] = 'justifydays'
required_args: 't.ClassVar[set[str]]' = {'this'}
352class JustifyHours(Expression, Func):
353    pass
key: ClassVar[str] = 'justifyhours'
required_args: 't.ClassVar[set[str]]' = {'this'}
356class JustifyInterval(Expression, Func):
357    pass
key: ClassVar[str] = 'justifyinterval'
required_args: 't.ClassVar[set[str]]' = {'this'}
360class LastDay(Expression, Func, TimeUnit):
361    _sql_names = ["LAST_DAY", "LAST_DAY_OF_MONTH"]
362    arg_types = {"this": True, "unit": False}
arg_types = {'this': True, 'unit': False}
key: ClassVar[str] = 'lastday'
required_args: 't.ClassVar[set[str]]' = {'this'}
365class MakeInterval(Expression, Func):
366    arg_types = {
367        "year": False,
368        "month": False,
369        "week": False,
370        "day": False,
371        "hour": False,
372        "minute": False,
373        "second": False,
374    }
arg_types = {'year': False, 'month': False, 'week': False, 'day': False, 'hour': False, 'minute': False, 'second': False}
key: ClassVar[str] = 'makeinterval'
required_args: 't.ClassVar[set[str]]' = set()
377class NextDay(Expression, Func):
378    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'nextday'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
381class PreviousDay(Expression, Func):
382    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'previousday'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
385class Time(Expression, Func):
386    arg_types = {"this": False, "zone": False}
arg_types = {'this': False, 'zone': False}
key: ClassVar[str] = 'time'
required_args: 't.ClassVar[set[str]]' = set()
389class TimeFromParts(Expression, Func):
390    _sql_names = ["TIME_FROM_PARTS", "TIMEFROMPARTS"]
391    arg_types = {
392        "hour": True,
393        "min": True,
394        "sec": True,
395        "nano": False,
396        "fractions": False,
397        "precision": False,
398        "overflow": False,
399    }
arg_types = {'hour': True, 'min': True, 'sec': True, 'nano': False, 'fractions': False, 'precision': False, 'overflow': False}
key: ClassVar[str] = 'timefromparts'
required_args: 't.ClassVar[set[str]]' = {'hour', 'min', 'sec'}
402class Timestamp(Expression, Func):
403    arg_types = {"this": False, "zone": False, "with_tz": False}
arg_types = {'this': False, 'zone': False, 'with_tz': False}
key: ClassVar[str] = 'timestamp'
required_args: 't.ClassVar[set[str]]' = set()
class TimestampFromParts(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
406class TimestampFromParts(Expression, Func):
407    _sql_names = ["TIMESTAMP_FROM_PARTS", "TIMESTAMPFROMPARTS"]
408    arg_types = {
409        **TIMESTAMP_PARTS,
410        "zone": False,
411        "milli": False,
412        "this": False,
413        "expression": False,
414    }
arg_types = {'year': False, 'month': False, 'day': False, 'hour': False, 'min': False, 'sec': False, 'nano': False, 'zone': False, 'milli': False, 'this': False, 'expression': False}
key: ClassVar[str] = 'timestampfromparts'
required_args: 't.ClassVar[set[str]]' = set()
class TimestampLtzFromParts(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
417class TimestampLtzFromParts(Expression, Func):
418    _sql_names = ["TIMESTAMP_LTZ_FROM_PARTS", "TIMESTAMPLTZFROMPARTS"]
419    arg_types = TIMESTAMP_PARTS.copy()
arg_types = {'year': False, 'month': False, 'day': False, 'hour': False, 'min': False, 'sec': False, 'nano': False}
key: ClassVar[str] = 'timestampltzfromparts'
required_args: 't.ClassVar[set[str]]' = set()
class TimestampTzFromParts(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
422class TimestampTzFromParts(Expression, Func):
423    _sql_names = ["TIMESTAMP_TZ_FROM_PARTS", "TIMESTAMPTZFROMPARTS"]
424    arg_types = {
425        **TIMESTAMP_PARTS,
426        "zone": False,
427    }
arg_types = {'year': False, 'month': False, 'day': False, 'hour': False, 'min': False, 'sec': False, 'nano': False, 'zone': False}
key: ClassVar[str] = 'timestamptzfromparts'
required_args: 't.ClassVar[set[str]]' = set()
433class ConvertTimezone(Expression, Func):
434    arg_types = {
435        "source_tz": False,
436        "target_tz": True,
437        "timestamp": True,
438        "options": False,
439    }
arg_types = {'source_tz': False, 'target_tz': True, 'timestamp': True, 'options': False}
key: ClassVar[str] = 'converttimezone'
required_args: 't.ClassVar[set[str]]' = {'target_tz', 'timestamp'}
442class DateStrToDate(Expression, Func):
443    pass
key: ClassVar[str] = 'datestrtodate'
required_args: 't.ClassVar[set[str]]' = {'this'}
446class DateToDateStr(Expression, Func):
447    pass
key: ClassVar[str] = 'datetodatestr'
required_args: 't.ClassVar[set[str]]' = {'this'}
450class DateToDi(Expression, Func):
451    pass
key: ClassVar[str] = 'datetodi'
required_args: 't.ClassVar[set[str]]' = {'this'}
454class DiToDate(Expression, Func):
455    pass
key: ClassVar[str] = 'ditodate'
required_args: 't.ClassVar[set[str]]' = {'this'}
class FromISO8601Timestamp(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
458class FromISO8601Timestamp(Expression, Func):
459    _sql_names = ["FROM_ISO8601_TIMESTAMP"]
key: ClassVar[str] = 'fromiso8601timestamp'
required_args: 't.ClassVar[set[str]]' = {'this'}
462class FromISO8601Date(Expression, Func):
463    _sql_names = ["FROM_ISO8601_DATE"]
key: ClassVar[str] = 'fromiso8601date'
required_args: 't.ClassVar[set[str]]' = {'this'}
class FromISO8601TimestampNanos(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
466class FromISO8601TimestampNanos(Expression, Func):
467    _sql_names = ["FROM_ISO8601_TIMESTAMP_NANOS"]
key: ClassVar[str] = 'fromiso8601timestampnanos'
required_args: 't.ClassVar[set[str]]' = {'this'}
470class ParseDatetime(Expression, Func):
471    arg_types = {"this": True, "format": False, "zone": False, "default_year": False}
arg_types = {'this': True, 'format': False, 'zone': False, 'default_year': False}
key: ClassVar[str] = 'parsedatetime'
required_args: 't.ClassVar[set[str]]' = {'this'}
474class ParseTime(Expression, Func):
475    arg_types = {"this": True, "format": True}
arg_types = {'this': True, 'format': True}
key: ClassVar[str] = 'parsetime'
required_args: 't.ClassVar[set[str]]' = {'format', 'this'}
478class StrToDate(Expression, Func):
479    arg_types = {
480        "this": True,
481        "format": False,
482        "safe": False,
483        "default_year": False,
484        "nlsparam": False,
485    }
arg_types = {'this': True, 'format': False, 'safe': False, 'default_year': False, 'nlsparam': False}
key: ClassVar[str] = 'strtodate'
required_args: 't.ClassVar[set[str]]' = {'this'}
488class StrToTime(Expression, Func):
489    arg_types = {
490        "this": True,
491        "format": True,
492        "zone": False,
493        "safe": False,
494        "target_type": False,
495        "default_year": False,
496        "nlsparam": False,
497    }
arg_types = {'this': True, 'format': True, 'zone': False, 'safe': False, 'target_type': False, 'default_year': False, 'nlsparam': False}
key: ClassVar[str] = 'strtotime'
required_args: 't.ClassVar[set[str]]' = {'format', 'this'}
500class StrToUnix(Expression, Func):
501    arg_types = {"this": False, "format": False}
arg_types = {'this': False, 'format': False}
key: ClassVar[str] = 'strtounix'
required_args: 't.ClassVar[set[str]]' = set()
504class TimeStrToDate(Expression, Func):
505    pass
key: ClassVar[str] = 'timestrtodate'
required_args: 't.ClassVar[set[str]]' = {'this'}
508class TimeStrToTime(Expression, Func):
509    arg_types = {"this": True, "zone": False}
arg_types = {'this': True, 'zone': False}
key: ClassVar[str] = 'timestrtotime'
required_args: 't.ClassVar[set[str]]' = {'this'}
512class TimeStrToUnix(Expression, Func):
513    pass
key: ClassVar[str] = 'timestrtounix'
required_args: 't.ClassVar[set[str]]' = {'this'}
516class TimeToStr(Expression, Func):
517    # joda: parsed from Presto/Trino's FORMAT_DATETIME, which DATE_FORMAT can't always express
518    arg_types = {"this": True, "format": True, "culture": False, "zone": False, "joda": False}
arg_types = {'this': True, 'format': True, 'culture': False, 'zone': False, 'joda': False}
key: ClassVar[str] = 'timetostr'
required_args: 't.ClassVar[set[str]]' = {'format', 'this'}
521class TimeToTimeStr(Expression, Func):
522    pass
key: ClassVar[str] = 'timetotimestr'
required_args: 't.ClassVar[set[str]]' = {'this'}
525class TimeToUnix(Expression, Func):
526    pass
key: ClassVar[str] = 'timetounix'
required_args: 't.ClassVar[set[str]]' = {'this'}
529class TsOrDiToDi(Expression, Func):
530    pass
key: ClassVar[str] = 'tsorditodi'
required_args: 't.ClassVar[set[str]]' = {'this'}
533class TsOrDsToDate(Expression, Func):
534    arg_types = {"this": True, "format": False, "safe": False, "default_date": False}
arg_types = {'this': True, 'format': False, 'safe': False, 'default_date': False}
key: ClassVar[str] = 'tsordstodate'
required_args: 't.ClassVar[set[str]]' = {'this'}
537class TsOrDsToDateStr(Expression, Func):
538    pass
key: ClassVar[str] = 'tsordstodatestr'
required_args: 't.ClassVar[set[str]]' = {'this'}
541class TsOrDsToDatetime(Expression, Func):
542    pass
key: ClassVar[str] = 'tsordstodatetime'
required_args: 't.ClassVar[set[str]]' = {'this'}
545class TsOrDsToTime(Expression, Func):
546    arg_types = {"this": True, "format": False, "safe": False}
arg_types = {'this': True, 'format': False, 'safe': False}
key: ClassVar[str] = 'tsordstotime'
required_args: 't.ClassVar[set[str]]' = {'this'}
549class TsOrDsToTimestamp(Expression, Func):
550    pass
key: ClassVar[str] = 'tsordstotimestamp'
required_args: 't.ClassVar[set[str]]' = {'this'}
553class UnixDate(Expression, Func):
554    pass
key: ClassVar[str] = 'unixdate'
required_args: 't.ClassVar[set[str]]' = {'this'}
557class UnixMicros(Expression, Func):
558    pass
key: ClassVar[str] = 'unixmicros'
required_args: 't.ClassVar[set[str]]' = {'this'}
561class UnixMillis(Expression, Func):
562    pass
key: ClassVar[str] = 'unixmillis'
required_args: 't.ClassVar[set[str]]' = {'this'}
565class UnixSeconds(Expression, Func):
566    pass
key: ClassVar[str] = 'unixseconds'
required_args: 't.ClassVar[set[str]]' = {'this'}
569class UnixToStr(Expression, Func):
570    arg_types = {"this": True, "format": False}
arg_types = {'this': True, 'format': False}
key: ClassVar[str] = 'unixtostr'
required_args: 't.ClassVar[set[str]]' = {'this'}
573class UnixToTime(Expression, Func):
574    arg_types = {
575        "this": True,
576        "scale": False,
577        "zone": False,
578        "hours": False,
579        "minutes": False,
580        "format": False,
581        "target_type": False,
582    }
583
584    SECONDS: t.ClassVar[Literal | Neg] = Literal.number(0)
585    DECIS: t.ClassVar[Literal | Neg] = Literal.number(1)
586    CENTIS: t.ClassVar[Literal | Neg] = Literal.number(2)
587    MILLIS: t.ClassVar[Literal | Neg] = Literal.number(3)
588    DECIMILLIS: t.ClassVar[Literal | Neg] = Literal.number(4)
589    CENTIMILLIS: t.ClassVar[Literal | Neg] = Literal.number(5)
590    MICROS: t.ClassVar[Literal | Neg] = Literal.number(6)
591    DECIMICROS: t.ClassVar[Literal | Neg] = Literal.number(7)
592    CENTIMICROS: t.ClassVar[Literal | Neg] = Literal.number(8)
593    NANOS: t.ClassVar[Literal | Neg] = Literal.number(9)
arg_types = {'this': True, 'scale': False, 'zone': False, 'hours': False, 'minutes': False, 'format': False, 'target_type': False}
SECONDS: ClassVar[sqlglot.expressions.core.Literal | sqlglot.expressions.core.Neg] = Literal(this=0, is_string=False)
DECIS: ClassVar[sqlglot.expressions.core.Literal | sqlglot.expressions.core.Neg] = Literal(this=1, is_string=False)
CENTIS: ClassVar[sqlglot.expressions.core.Literal | sqlglot.expressions.core.Neg] = Literal(this=2, is_string=False)
MILLIS: ClassVar[sqlglot.expressions.core.Literal | sqlglot.expressions.core.Neg] = Literal(this=3, is_string=False)
DECIMILLIS: ClassVar[sqlglot.expressions.core.Literal | sqlglot.expressions.core.Neg] = Literal(this=4, is_string=False)
CENTIMILLIS: ClassVar[sqlglot.expressions.core.Literal | sqlglot.expressions.core.Neg] = Literal(this=5, is_string=False)
MICROS: ClassVar[sqlglot.expressions.core.Literal | sqlglot.expressions.core.Neg] = Literal(this=6, is_string=False)
DECIMICROS: ClassVar[sqlglot.expressions.core.Literal | sqlglot.expressions.core.Neg] = Literal(this=7, is_string=False)
CENTIMICROS: ClassVar[sqlglot.expressions.core.Literal | sqlglot.expressions.core.Neg] = Literal(this=8, is_string=False)
NANOS: ClassVar[sqlglot.expressions.core.Literal | sqlglot.expressions.core.Neg] = Literal(this=9, is_string=False)
key: ClassVar[str] = 'unixtotime'
required_args: 't.ClassVar[set[str]]' = {'this'}
596class UnixToTimeStr(Expression, Func):
597    pass
key: ClassVar[str] = 'unixtotimestr'
required_args: 't.ClassVar[set[str]]' = {'this'}