Skip to content

Commit 38ad46f

Browse files
committed
stringify lists in event shovel
1 parent ebb9585 commit 38ad46f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

scraper_service/shovel_events/utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ def get_column_type(value):
2424
return "Int64"
2525
elif isinstance(value, float):
2626
return "Float64"
27+
elif isinstance(value, list):
28+
if len(value) > 0:
29+
inner = value[0]
30+
# Only use Array if the inner value will have a proper type, otherwise, just
31+
# stringify it.
32+
if (
33+
isinstance(inner, str)
34+
or isinstance(inner, int)
35+
or isinstance(inner, float)
36+
):
37+
return f"Array({get_column_type(inner)})"
38+
else:
39+
return "String"
40+
else:
41+
return "String"
2742
elif value is None:
2843
return None
2944
else:

0 commit comments

Comments
 (0)