summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/databricks.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-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 = []