Skip to content

Commit 7af013f

Browse files
author
Jesse Whitehouse
committed
Introduce basic primitives for alembic support:
- Reflection works at a basic level but upgrades/downgrades fail to read the expected data from alembic_versions table - It's not clear how to make reflection capture the scale and precision of DECIMAL() column types. Signed-off-by: Jesse Whitehouse <[email protected]>
1 parent 60d466d commit 7af013f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/databricks/sqlalchemy/dialect/__init__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414
)
1515
from databricks.sqlalchemy.dialect.compiler import DatabricksTypeCompiler
1616

17+
try:
18+
import alembic
19+
except ImportError:
20+
pass
21+
else:
22+
from alembic.ddl import DefaultImpl
23+
class DatabricksImpl(DefaultImpl):
24+
__dialect__ = 'databricks'
25+
1726

1827
class DatabricksDialect(default.DefaultDialect):
1928
"""This dialect implements only those methods required to pass our e2e tests"""
@@ -111,9 +120,14 @@ def get_columns(self, connection, table_name, schema=None, **kwargs):
111120

112121
for col in resp:
113122

123+
if "DECIMAL(" in col.TYPE_NAME:
124+
_this_type = types.DECIMAL
125+
else:
126+
_this_type = _type_map.get(col.TYPE_NAME.lower())
127+
114128
this_column = {
115129
"name": col.COLUMN_NAME,
116-
"type": _type_map.get(col.TYPE_NAME.lower()),
130+
"type": _this_type,
117131
"nullable": bool(col.NULLABLE),
118132
"default": col.COLUMN_DEF,
119133
"autoincrement": False if col.IS_AUTO_INCREMENT == "NO" else True,

0 commit comments

Comments
 (0)