Skip to content

Add support for negative integers to CQL (at least version 3) #81

merged 3 commits into from Oct 26, 2012

2 participants


According to the CQL datatypes documentation, the types int, bigint and varint refer to signed integers.

Helenus incorrectly interprets them as unsigned integers, at least from CQL.

The first commit contains tests to test number parsing in CQL3. This test fails on negative integers.

The second commit fixes the test.

This works for positive integers up to 53 bits (which is the 64-bit float javascript limit). For negative integers, with this patch the maximum negative value is the most negative 32 bit signed integer. There is room for improvement here, possibly by introducing a big integer library for the long values, or by trying to parse 53-bit negative numbers instead of 32. These limits apply both to bigint/long and varint above 32 bits.

SimpleReach member

This is great. What are the issues with CQL2 and Thrift?


This has no issues with CQL2, as they have the same integer datatypes as CQL3, so it fixes the same issue with CQL2.

I do not know what impact this does have on thrift, as i currently do not use it. helenus-thrift does include its own binary parser (which has even more trouble with large negative numbers as my solution, but does work fine for 32 bit negative numbers). I do not if the one in helenus-thrift is used, or if helenus parses the actual results back to numbers.

The same datatypes for CQL apply for the thrift protocol, as the same java classes are used by cassandra internally. So this might be a fix for thrift as well. All current tests still pass. If anyone wants to write a thrift test with negative numbers, we know for sure :)

@devdazed devdazed merged commit cc6c5e7 into simplereach:master Oct 26, 2012

1 check was pending

Details default The Travis build is in progress
SimpleReach member

This is published in version 0.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.