Skip to content

Commit 56b030e

Browse files
committed
fix unknown field format in events shovel
1 parent e835899 commit 56b030e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

scraper_service/shovel_events/utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
from functools import lru_cache
23
from substrateinterface.base import is_valid_ss58_address
34
from shared.clickhouse.utils import (
@@ -10,9 +11,17 @@
1011
def format_value(value):
1112
"""
1213
SQL requires strings to be wrapped in single quotes
14+
Complex types like lists with dictionaries are serialized to JSON
1315
"""
14-
if isinstance(value, str):
16+
if value is None:
17+
return "NULL"
18+
elif isinstance(value, str):
1519
return f"'{value}'"
20+
elif isinstance(value, list):
21+
if len(value) > 0 and all(isinstance(x, (str, int, float)) for x in value):
22+
return value
23+
else:
24+
return f"'{json.dumps(value)}'"
1625
else:
1726
return value
1827

0 commit comments

Comments
 (0)