Skip to content

Support 128-bit integers using int_as_string_bitcount #306

Closed

Description

@Triangulum9r

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)

Activity

  1. etrepum commented on Jan 5, 2023

    @etrepum
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions