You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: get_columns() incorrectly reports all column types due to a late-binding closure bug #82
BUG: get_columns() incorrectly reports all column types due to a late-binding closure bug
Summary
The get_columns() implementation in the e6data SQLAlchemy dialect incorrectly reports the data type of every reflected column. Instead of returning each column's actual SQL type, all columns are assigned the data type of the last column in the table.
This breaks SQLAlchemy schema reflection and affects downstream tools such as Great Expectations that rely on accurate column metadata.
Root Cause
The issue is caused by a Python late-binding closure bug:
for column in columns:
row = {}
row["name"] = column.get("fieldName")
row["type"] = lambda: column.get("fieldType")
rows.append(row)
Since the lambda captures the column variable by reference, all lambdas eventually point to the last element in the loop. As a result, every reflected column is assigned the type of the last column.
Example
Given the following table:
Column | Actual Type
-- | --
id | INTEGER
name | VARCHAR
salary | DOUBLE
created_at | TIMESTAMP
Expected reflection:
id -> INTEGER
name -> VARCHAR
salary -> DOUBLE
created_at -> TIMESTAMP
Actual reflection:
id -> TIMESTAMP
name -> TIMESTAMP
salary -> TIMESTAMP
created_at -> TIMESTAMP
Impact
Because all columns are reflected with the same type, downstream tools such as Great Expectations are unable to correctly infer the schema. This prevents schema creation and causes several type-based validations and other reflection-based features to fail.
Additionally, the current implementation bypasses the existing _type_map, returning raw e6data type strings instead of mapping them to the corresponding SQLAlchemy types.* objects.
Proposed Fix
I've identified the root cause and implemented a fix that:
Resolves the late-binding closure issue.
Uses the existing _type_map to return the appropriate SQLAlchemy type objects.
The proposed fix has already been submitted for review in Pull Request #81.
Fixed in #83, now merged into main and released as 2.3.14.
The fix resolves the late-binding closure in get_columns() — each reflected column now resolves its type independently and maps through the existing _type_map to the correct SQLAlchemy types.* object (falling back to types.String for unknown types). A regression test (test/test_dialect_columns.py) guards against this recurring.
Note: the original PR #81 referenced here has been closed in favor of #83, which carries the same fix plus the regression test and SQLAlchemy version-compatibility shims.
Activity
vishale6x commentedon Jun 29, 2026
Fixed in #83, now merged into
mainand released as2.3.14.The fix resolves the late-binding closure in
get_columns()— each reflected column now resolves its type independently and maps through the existing_type_mapto the correct SQLAlchemytypes.*object (falling back totypes.Stringfor unknown types). A regression test (test/test_dialect_columns.py) guards against this recurring.Note: the original PR #81 referenced here has been closed in favor of #83, which carries the same fix plus the regression test and SQLAlchemy version-compatibility shims.