diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-10-04 12:14:45 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-10-04 12:14:45 +0000 |
commit | a34653eb21369376f0e054dd989311afcb167f5b (patch) | |
tree | 5a0280adce195af0be654f79fd99395fd2932c19 /sqlglot/dialects/spark.py | |
parent | Releasing debian version 18.7.0-1. (diff) | |
download | sqlglot-a34653eb21369376f0e054dd989311afcb167f5b.tar.xz sqlglot-a34653eb21369376f0e054dd989311afcb167f5b.zip |
Merging upstream version 18.11.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/spark.py')
-rw-r--r-- | sqlglot/dialects/spark.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sqlglot/dialects/spark.py b/sqlglot/dialects/spark.py index 9d4a1ab..2eaa2ae 100644 --- a/sqlglot/dialects/spark.py +++ b/sqlglot/dialects/spark.py @@ -54,6 +54,14 @@ class Spark(Spark2): FUNCTION_PARSERS = Spark2.Parser.FUNCTION_PARSERS.copy() FUNCTION_PARSERS.pop("ANY_VALUE") + def _parse_generated_as_identity( + self, + ) -> exp.GeneratedAsIdentityColumnConstraint | exp.ComputedColumnConstraint: + this = super()._parse_generated_as_identity() + if this.expression: + return self.expression(exp.ComputedColumnConstraint, this=this.expression) + return this + class Generator(Spark2.Generator): TYPE_MAPPING = { **Spark2.Generator.TYPE_MAPPING, @@ -73,6 +81,9 @@ class Spark(Spark2): TRANSFORMS.pop(exp.DateDiff) TRANSFORMS.pop(exp.Group) + def computedcolumnconstraint_sql(self, expression: exp.ComputedColumnConstraint) -> str: + return f"GENERATED ALWAYS AS ({self.sql(expression, 'this')})" + def anyvalue_sql(self, expression: exp.AnyValue) -> str: return self.function_fallback_sql(expression) |