From f1678c2559516519bb74df887cd8738cd5a03147 Mon Sep 17 00:00:00 2001 From: Ken Payne <5585874+kgpayne@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:37:59 +0100 Subject: [PATCH] fix column ddl bug Signed-off-by: Ken Payne <5585874+kgpayne@users.noreply.github.com> --- src/databricks/sqlalchemy/_ddl.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/databricks/sqlalchemy/_ddl.py b/src/databricks/sqlalchemy/_ddl.py index d5d0bf8..d559dc4 100644 --- a/src/databricks/sqlalchemy/_ddl.py +++ b/src/databricks/sqlalchemy/_ddl.py @@ -1,6 +1,7 @@ +import logging import re + from sqlalchemy.sql import compiler, sqltypes -import logging logger = logging.getLogger(__name__) @@ -68,7 +69,15 @@ def get_column_specification(self, column, **kwargs): See comments in test_suite.py. We may implement implicit IDENTITY using this feature in the future, similar to the Microsoft SQL Server dialect. """ - if column is column.table._autoincrement_column or column.autoincrement is True: + is_autoincrement = bool(column.autoincrement) + if ( + column.table is not None # column.table can be None + and not is_autoincrement + ): + if column is column.table._autoincrement_column: + is_autoincrement = True + + if is_autoincrement: logger.warning( "Databricks dialect ignores SQLAlchemy's autoincrement semantics. Use explicit Identity() instead." )