Skip to content

Commit

Permalink
dev: make alias final conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-nelson-uiuc committed Dec 30, 2024
1 parent 26e123e commit 04b3493
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/tidy_tools/model/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def convert_field(cls_field: attrs.Attribute, cls_field_exists: bool) -> Column:
"""
if not cls_field.default:
if not cls_field_exists:
column = F.lit(None).alias(cls_field.alias)
column = F.lit(None)
else:
column = F.col(cls_field.alias)

Expand All @@ -39,7 +39,7 @@ def convert_field(cls_field: attrs.Attribute, cls_field_exists: bool) -> Column:
assert return_type is Column, "Factory must return a pyspark.sql.Column!"
column = cls_field.default.factory()
elif not cls_field_exists:
column = F.lit(cls_field.default).alias(cls_field.alias)
column = F.lit(cls_field.default)
else:
column = F.when(
F.col(cls_field.alias).isNull(), cls_field.default
Expand Down Expand Up @@ -74,4 +74,4 @@ def convert_field(cls_field: attrs.Attribute, cls_field_exists: bool) -> Column:
if cls_field.converter:
column = cls_field.converter(column)

return column
return column.alias(cls_field.alias)

0 comments on commit 04b3493

Please sign in to comment.