Number types

In Data API requests, the limit on maximum number length applies to the literal number of characters sent in the command’s JSON payload. A numeric literal in the JSON payload cannot exceed 100 characters, such as a number with 100 digits. However, you can use exponents to pass values that represent more than 100 digits, such as 1e120000. The exponent itself, not the expanded value, counts toward the 100-character limit. In Data API responses, the Data API may return the fully-expressed number, beyond 100 characters.

int

Use the int type for 32-bit signed integers, including optional - and exponent.

Only numbers that can be converted to a 4-byte integer without loss of information are valid. Exponents must express a whole number.

Client behavior:

  • Python: Accepts and returns int.

  • TypeScript: Accepts and returns JavaScript numbers.

  • Java: Accepts and returns java.lang.Integer.

bigint

Use the bigint type for integers ranging from -9223372036854775808 to 9223372036854775807 (-2^63 to 2^63-1). Only numbers that can be converted to an integer value without loss of information are valid.

Client behavior:

  • Python: Accepts and returns int.

  • TypeScript: Accepts and returns JavaScript numbers. You can store numbers outside of JavaScript Number.MAX_SAFE_INTEGER, but TypeScript may round the values since TypeScript uses numbers, not BigInt.

  • Java: Accepts and returns java.lang.Long.

smallint

Use the smallint type for 2-byte integers, including optional - and exponent. Only numbers that can be converted to a 2-byte integer without loss of information are valid. Exponents must express a whole number.

Client behavior:

  • Python: Accepts and returns int.

  • TypeScript: Accepts and returns JavaScript numbers.

  • Java: Accepts and returns java.lang.Short.

tinyint

Use the tinyint type for 1-byte integers, including optional - and exponent. Only numbers that can be converted to a 1-byte integer without loss of information are valid. Exponents must express a whole number.

Client behavior:

  • Python: Accepts and returns int.

  • TypeScript: Accepts and returns JavaScript numbers.

  • Java: Accepts and returns java.lang.Byte.

varint

Use the varint type for arbitrary-precision integers of Java type, including optional - and exponent.

Client behavior:

  • Python: Accepts and returns int.

  • TypeScript: Accepts numbers or strings. Returns strings.

  • Java: Accepts and returns java.math.BigInteger.

decimal

Use the decimal type for variable-precision decimals, including optional - and exponent.

Integers are valid decimal values, and may be returned without a decimal point. For example, 23 is a valid decimal, and it can be returned as 23 or 23.0.

decimal does not support NaN, Infinity, or -Infinity values.

Client behavior:

  • Python: Accepts decimal.DECIMAL, int, and float. Returns decimal.DECIMAL.

  • TypeScript: Accepts numbers or strings. Returns strings.

  • Java: Accepts and returns java.math.BigDecimal.

double

Use the double type for 64-bit IEEE-754 floating point values that can be a number (including an exponent and +/- 0) or a quoted string containing NaN, Infinity, or -Infinity.

Client behavior:

  • Python: Accepts int and float, including float("NaN"), float("Infinity"), and float("-Infinity"). Returns float unless you customize the serialization/deserialization.

  • TypeScript: Accepts and returns JavaScript numbers.

  • Java: Accepts and returns java.lang.Double.

float

Use the float type for 32-bit IEEE-754 floating point values that can be a number (including E and +/- 0) or a quoted string containing NaN, Infinity, or -Infinity.

Client behavior:

  • Python: Accepts int and float, including float("NaN"), float("Infinity"), and float("-Infinity"). Returns float unless you customize the serialization/deserialization.

  • TypeScript: Accepts and returns JavaScript numbers.

  • Java: Accepts and returns java.lang.Float.

counter (partial support)

The Data API can’t create columns of counter type or insert or update a row with a counter column. You must use CQL directly instead of the Data API.

The Data API can only read and filter values in existing counter columns.

Use the counter type for 64-bit signed integers intended for incrementing and decrementing.

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2025 | Privacy policy | Terms of use Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM