Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Dump properties with multi byte characters #18690

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def assert_events_in_redshift(connection, schema, table_name, events, excl
"elements": json.dumps(elements_chain) if elements_chain else None,
"event": event_name,
"ip": properties.get("$ip", None) if properties else None,
"properties": json.dumps(properties) if properties else None,
"properties": json.dumps(properties, ensure_ascii=False) if properties else None,
"set": properties.get("$set", None) if properties else None,
"set_once": properties.get("$set_once", None) if properties else None,
# Kept for backwards compatibility, but not exported anymore.
Expand Down Expand Up @@ -185,9 +185,10 @@ async def test_insert_into_redshift_activity_inserts_data_into_redshift_table(
properties={
"$browser": "Chrome",
"$os": "Mac OS X",
"newline": "\n\n",
"nested_newline": {"newline": "\n\n"},
"sequence": {"mucho_whitespace": ["\n\n", "\t\t", "\f\f"]},
"whitespace": "hi\t\n\r\f\bhi",
"nested_whitespace": {"whitespace": "hi\t\n\r\f\bhi"},
"sequence": {"mucho_whitespace": ["hi", "hi\t\n\r\f\bhi", "hi\t\n\r\f\bhi", "hi"]},
"multi-byte": "é",
},
person_properties={"utm_medium": "referral", "$initial_os": "Linux"},
)
Expand Down
2 changes: 1 addition & 1 deletion posthog/temporal/workflows/redshift_batch_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ async def insert_into_redshift_activity(inputs: RedshiftInsertInputs):
def map_to_record(row: dict) -> dict:
"""Map row to a record to insert to Redshift."""
return {
key: json.dumps(remove_escaped_whitespace_recursive(row[key]))
key: json.dumps(remove_escaped_whitespace_recursive(row[key]), ensure_ascii=False)
if key in json_columns and row[key] is not None
else row[key]
for key in schema_columns
Expand Down
Loading