1
0
Fork 0

Adding upstream version 23.10.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 21:31:00 +01:00
parent 27c061b7af
commit efe1f986ea
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
91 changed files with 52881 additions and 50396 deletions

View file

@ -90,8 +90,10 @@ def _str_to_time_sql(
def _ts_or_ds_to_date_sql(self: Presto.Generator, expression: exp.TsOrDsToDate) -> str:
time_format = self.format_time(expression)
if time_format and time_format not in (Presto.TIME_FORMAT, Presto.DATE_FORMAT):
return self.sql(exp.cast(_str_to_time_sql(self, expression), "DATE"))
return self.sql(exp.cast(exp.cast(expression.this, "TIMESTAMP"), "DATE"))
return self.sql(exp.cast(_str_to_time_sql(self, expression), exp.DataType.Type.DATE))
return self.sql(
exp.cast(exp.cast(expression.this, exp.DataType.Type.TIMESTAMP), exp.DataType.Type.DATE)
)
def _ts_or_ds_add_sql(self: Presto.Generator, expression: exp.TsOrDsAdd) -> str:
@ -101,8 +103,8 @@ def _ts_or_ds_add_sql(self: Presto.Generator, expression: exp.TsOrDsAdd) -> str:
def _ts_or_ds_diff_sql(self: Presto.Generator, expression: exp.TsOrDsDiff) -> str:
this = exp.cast(expression.this, "TIMESTAMP")
expr = exp.cast(expression.expression, "TIMESTAMP")
this = exp.cast(expression.this, exp.DataType.Type.TIMESTAMP)
expr = exp.cast(expression.expression, exp.DataType.Type.TIMESTAMP)
unit = unit_to_str(expression)
return self.func("DATE_DIFF", unit, expr, this)
@ -222,6 +224,8 @@ class Presto(Dialect):
"IPPREFIX": TokenType.IPPREFIX,
}
KEYWORDS.pop("QUALIFY")
class Parser(parser.Parser):
VALUES_FOLLOWED_BY_PAREN = False
@ -445,7 +449,7 @@ class Presto(Dialect):
# timezone involved, we wrap it in a `TRY` call and use `PARSE_DATETIME` as a fallback,
# which seems to be using the same time mapping as Hive, as per:
# https://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html
value_as_text = exp.cast(expression.this, "text")
value_as_text = exp.cast(expression.this, exp.DataType.Type.TEXT)
parse_without_tz = self.func("DATE_PARSE", value_as_text, self.format_time(expression))
parse_with_tz = self.func(
"PARSE_DATETIME",