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

Support 128-bit integers using int_as_string_bitcount #306

Open
juls858 opened this issue Jan 5, 2023 · 1 comment
Open

Support 128-bit integers using int_as_string_bitcount #306

juls858 opened this issue Jan 5, 2023 · 1 comment

Comments

@juls858
Copy link

juls858 commented Jan 5, 2023

Currently int_as_string_bitcount supports only up to 63bits. Please add support for any bitlength or at least 127(128) bits. Snowflake supports 128bit integers, currently any bigints that I load have to be converted to a string if they are less than 64bits.

ideally all of the following should be stored as a number given the following code:

test = {
    "max_int": 99999999999999999999999999999999999999,
    "63 bits": 999999999999999999,
    "53 bits": 999999999999999,
    "overflow": 999999999999999999999999999999999999991,
}
result = simplejson.dumps(test, int_as_string_bitcount=128)

print(result)
@etrepum
Copy link
Member

etrepum commented Jan 5, 2023

A patch with tests that implements this would be reviewed and likely accepted.

Depending on how Snowflake's parser handles overflow, you might be able to get away without using int_as_string_bitcount at all. By default any sized integer will be encoded as a number.

>>> print(simplejson.dumps(test, indent=2))
{
  "max_int": 99999999999999999999999999999999999999,
  "63 bits": 999999999999999999,
  "53 bits": 999999999999999,
  "overflow": 999999999999999999999999999999999999991
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants