diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:02:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:02:18 +0000 |
commit | 41f1f5740d2140bfd3b2a282ca1087a4b576679a (patch) | |
tree | 0b1eb5ba5c759d08b05d56e50675784b6170f955 /sqlglot/dialects/presto.py | |
parent | Releasing debian version 23.7.0-1. (diff) | |
download | sqlglot-41f1f5740d2140bfd3b2a282ca1087a4b576679a.tar.xz sqlglot-41f1f5740d2140bfd3b2a282ca1087a4b576679a.zip |
Merging upstream version 23.10.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/presto.py')
-rw-r--r-- | sqlglot/dialects/presto.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sqlglot/dialects/presto.py b/sqlglot/dialects/presto.py index 25bba96..6c23bdf 100644 --- a/sqlglot/dialects/presto.py +++ b/sqlglot/dialects/presto.py @@ -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", |