summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/databricks.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-10-04 12:14:45 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-10-04 12:14:45 +0000
commita34653eb21369376f0e054dd989311afcb167f5b (patch)
tree5a0280adce195af0be654f79fd99395fd2932c19 /sqlglot/dialects/databricks.py
parentReleasing debian version 18.7.0-1. (diff)
downloadsqlglot-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/databricks.py')
-rw-r--r--sqlglot/dialects/databricks.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/sqlglot/dialects/databricks.py b/sqlglot/dialects/databricks.py
index 39daad7..a044bc0 100644
--- a/sqlglot/dialects/databricks.py
+++ b/sqlglot/dialects/databricks.py
@@ -51,6 +51,26 @@ class Databricks(Spark):
exp.ToChar: lambda self, e: self.function_fallback_sql(e),
}
+ def columndef_sql(self, expression: exp.ColumnDef, sep: str = " ") -> str:
+ constraint = expression.find(exp.GeneratedAsIdentityColumnConstraint)
+ kind = expression.args.get("kind")
+ if (
+ constraint
+ and isinstance(kind, exp.DataType)
+ and kind.this in exp.DataType.INTEGER_TYPES
+ ):
+ # only BIGINT generated identity constraints are supported
+ expression = expression.copy()
+ expression.set("kind", exp.DataType.build("bigint"))
+ return super().columndef_sql(expression, sep)
+
+ def generatedasidentitycolumnconstraint_sql(
+ self, expression: exp.GeneratedAsIdentityColumnConstraint
+ ) -> str:
+ expression = expression.copy()
+ expression.set("this", True) # trigger ALWAYS in super class
+ return super().generatedasidentitycolumnconstraint_sql(expression)
+
class Tokenizer(Spark.Tokenizer):
HEX_STRINGS = []