Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/databricks/labs/lsql/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ def _schema_for(cls, klass: Dataclass):
fields = []
for f in dataclasses.fields(klass):
field_type = f.type
# workaround rare (Python?) issue where f.type is the type name instead of the type itself
# this seems to happen when the dataclass is first used from a file importing it
if isinstance(field_type, str):
try:
field_type = __builtins__[field_type]
except TypeError as e:
logger.warning(f"Could not load type {field_type}", exc_info=e)
if isinstance(field_type, UnionType):
field_type = field_type.__args__[0]
if field_type not in cls._builtin_type_mapping:
Expand Down