-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(data-import): handle large integers in json (#27141)
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
posthog/temporal/data_imports/pipelines/sql_database_v2/test/test_arrow_helpers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pytest | ||
import pyarrow as pa | ||
from posthog.temporal.data_imports.pipelines.sql_database_v2.arrow_helpers import json_dumps | ||
from dlt.common.json import json | ||
|
||
|
||
def test_handle_large_integers(): | ||
# Test that orjson raises TypeError for integers outside 64-bit range | ||
with pytest.raises(TypeError, match="Integer exceeds 64-bit range"): | ||
json.dumps({"a": 2**64}) | ||
|
||
with pytest.raises(TypeError, match="Integer exceeds 64-bit range"): | ||
json.dumps({"a": -(2**64)}) | ||
|
||
json_str_array = pa.array([None if s is None else json_dumps(s) for s in [{"a": 2**64}]]) | ||
|
||
loaded = json.loads(json_str_array[0].as_py()) | ||
assert loaded["a"] == float(2**64) | ||
|
||
json_str_array = pa.array([None if s is None else json_dumps(s) for s in [{"a": -(2**64)}]]) | ||
loaded = json.loads(json_str_array[0].as_py()) | ||
assert loaded["a"] == float(-(2**64)) |