diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-11-01 05:12:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-11-01 05:12:42 +0000 |
commit | c51a9844b869fd7cd69e5cc7658d34f61a865185 (patch) | |
tree | 55706c65ce7e19626aabf7ff4dde0e1a51b739db /sqlglot/dialects/hive.py | |
parent | Releasing debian version 18.17.0-1. (diff) | |
download | sqlglot-c51a9844b869fd7cd69e5cc7658d34f61a865185.tar.xz sqlglot-c51a9844b869fd7cd69e5cc7658d34f61a865185.zip |
Merging upstream version 19.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/hive.py')
-rw-r--r-- | sqlglot/dialects/hive.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sqlglot/dialects/hive.py b/sqlglot/dialects/hive.py index 7bff553..3b1c8de 100644 --- a/sqlglot/dialects/hive.py +++ b/sqlglot/dialects/hive.py @@ -53,8 +53,6 @@ DIFF_MONTH_SWITCH = ("YEAR", "QUARTER", "MONTH") def _create_sql(self, expression: exp.Create) -> str: - expression = expression.copy() - # remove UNIQUE column constraints for constraint in expression.find_all(exp.UniqueColumnConstraint): if constraint.parent: @@ -88,7 +86,7 @@ def _add_date_sql(self: Hive.Generator, expression: exp.DateAdd | exp.DateSub) - if expression.expression.is_number: modified_increment = exp.Literal.number(int(expression.text("expression")) * multiplier) else: - modified_increment = expression.expression.copy() + modified_increment = expression.expression if multiplier != 1: modified_increment = exp.Mul( # type: ignore this=modified_increment, expression=exp.Literal.number(multiplier) @@ -229,6 +227,11 @@ class Hive(Dialect): STRING_ESCAPES = ["\\"] ENCODE = "utf-8" + SINGLE_TOKENS = { + **tokens.Tokenizer.SINGLE_TOKENS, + "$": TokenType.PARAMETER, + } + KEYWORDS = { **tokens.Tokenizer.KEYWORDS, "ADD ARCHIVE": TokenType.COMMAND, @@ -408,6 +411,7 @@ class Hive(Dialect): INDEX_ON = "ON TABLE" EXTRACT_ALLOWS_QUOTES = False NVL2_SUPPORTED = False + SUPPORTS_NESTED_CTES = False TYPE_MAPPING = { **generator.Generator.TYPE_MAPPING, @@ -521,7 +525,10 @@ class Hive(Dialect): def parameter_sql(self, expression: exp.Parameter) -> str: this = self.sql(expression, "this") + expression_sql = self.sql(expression, "expression") + parent = expression.parent + this = f"{this}:{expression_sql}" if expression_sql else this if isinstance(parent, exp.EQ) and isinstance(parent.parent, exp.SetItem): # We need to produce SET key = value instead of SET ${key} = value @@ -530,8 +537,6 @@ class Hive(Dialect): return f"${{{this}}}" def schema_sql(self, expression: exp.Schema) -> str: - expression = expression.copy() - for ordered in expression.find_all(exp.Ordered): if ordered.args.get("desc") is False: ordered.set("desc", None) @@ -539,8 +544,6 @@ class Hive(Dialect): return super().schema_sql(expression) def constraint_sql(self, expression: exp.Constraint) -> str: - expression = expression.copy() - for prop in list(expression.find_all(exp.Properties)): prop.pop() |