Skip to content

Commit

Permalink
improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyyid committed Sep 26, 2024
1 parent f91219a commit 5afeacc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gluestick/etl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,7 @@ def get(self, stream, default=None, catalog_types=False, **kwargs):
'datetime64[ns]': pa.timestamp('ns'),
'bool': pa.bool_(),
'boolean': pa.bool_(),
'category': pa.dictionary(pa.int32(), pa.string()), # Example for categorical data
# Add more mappings as needed
# TODO: Add more mappings as needed
}

if dtype_dict:
Expand All @@ -584,10 +583,13 @@ def get(self, stream, default=None, catalog_types=False, **kwargs):
schema = pa.schema(fields)
df = pq.read_table(filepath, schema=schema).to_pandas(safe=False)
for col, dtype in dtype_dict.items():
# NOTE: bools require explicit conversion at the end because if there are empty values (NaN)
# pyarrow/pd defaults to convert to string
if str(dtype).lower() in ["bool", "boolean"]:
df[col] = df[col].astype('boolean')
return df
except:
# NOTE: silencing errors to avoid breaking existing workflow
print(f"Failed to parse catalog_types for {stream}. Ignoring.")
pass

Expand Down

0 comments on commit 5afeacc

Please sign in to comment.