TypeError when using Enum columns with the Databricks dialect (all 2.0.x releases)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 70/100
Research direction
Start with DatabricksStringType and follow SQLAlchemy's Enum.adapt() path described in the issue. Run the provided DeclarativeBase reproduction against a Databricks engine, then verify that creating metadata with the Enum column completes without the _enums TypeError.
Written by the indexing model from the issue text.
Description
Description
Any SQLAlchemy operation that involves an Enum-typed column with the Databricks dialect raises:
TypeError: String.__init__() got an unexpected keyword argument '_enums'
Steps to reproduce
from sqlalchemy import create_engine, Column, Enum
from sqlalchemy.orm import DeclarativeBase
class Base(DeclarativeBase):
pass
class MyTable(Base):
__tablename__ = "my_table"
status = Column(Enum("A", "B", "C"), nullable=False)
engine = create_engine("databricks://...")
Base.metadata.create_all(engine)
Root cause
databricks-sqlalchemy registers DatabricksStringType as the colspec for sqlalchemy.String in the Databricks dialect. When SQLAlchemy adapts an Enum column (via Enum.adapt()), it internally passes _enums as a keyword argument to the target type's constructor. DatabricksStringType.__init__() does not accept **kwargs or _enums, causing the crash.
Environment
Affected versions: 2.0.1 – 2.0.9
SQLAlchemy: 2.0.x
Related issues
- #32 - No JSON colspec, CompileError at DDL compile time
- #37 - No INTERVAL colspec, Silent missing feature
- This issue - Enum colspec exists but target class rejects _enums kwarg
- Dominant language
- Python
- Stars
- 24
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from databricks/databricks-sqlalchemy
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
databricks/databricks-sqlalchemy#73 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
All issues in databricks/databricks-sqlalchemy
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
stephrobert/dsoxlab#238 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
sublimehq/package_control#1780 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
nwg-piotr/nwg-displays#145 ·