Skip to content

Commit

Permalink
Fix bug some dtypes didn't return the reconstructed field, but only t…
Browse files Browse the repository at this point in the history
…he last field
  • Loading branch information
ion-elgreco committed Aug 4, 2023
1 parent f94ee52 commit 0003c2c
Showing 1 changed file with 33 additions and 16 deletions.
49 changes: 33 additions & 16 deletions py-polars/polars/io/delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,21 +359,6 @@ def _reconstruct_field_type(
name=field_head.name,
type=reduce(lambda x, y: y(x), reversed(reconstructed_field)),
)
elif isinstance(field.type, pa.DataType) and not isinstance(
field.type, (pa.LargeListType, pa.StructType)
):
for uint_type, int_type in integer_mapping.items():
if field.type.equals(uint_type):
if reconstructed_field is None:
return pa.field(name=field.name, type=int_type)
else:
reconstructed_field.append(int_type)
return pa.field(
name=field_head.name,
type=reduce(lambda x, y: y(x), reversed(reconstructed_field)),
)
else:
return field
elif isinstance(field.type, pa.LargeListType):
if reconstructed_field is None:
reconstructed_field = [pa.large_list]
Expand All @@ -399,8 +384,40 @@ def _reconstruct_field_type(
name=field_head.name,
type=reduce(lambda x, y: y(x), reversed(reconstructed_field)),
)

elif isinstance(field.type, pa.DataType) and not isinstance(
field.type, (pa.LargeListType, pa.StructType)
):
for uint_type, int_type in integer_mapping.items():
if field.type.equals(uint_type):
if reconstructed_field is None:
return pa.field(name=field.name, type=int_type)
else:
reconstructed_field.append(int_type)
return pa.field(
name=field_head.name,
type=reduce(lambda x, y: y(x), reversed(reconstructed_field)),
)
else:
if reconstructed_field is None:
return field
else:
reconstructed_field.append(field.type)
return pa.field(
name=field_head.name,
type=reduce(lambda x, y: y(x), reversed(reconstructed_field)),
)

else:
return field
if reconstructed_field is None:
return field
else:
reconstructed_field.append(field.type)
return pa.field(
name=field_head.name,
type=reduce(lambda x, y: y(x), reversed(reconstructed_field)),
)



def _create_delta_compatible_schema(schema: pa.schema) -> pa.Schema:
Expand Down

0 comments on commit 0003c2c

Please sign in to comment.