CQL datatype for long?

470 views
Skip to first unread message

Check Peck

unread,
Dec 7, 2016, 8:36:03 PM12/7/16
to DataStax Java Driver for Apache Cassandra User Mailing List
What is the CQL data type I should use for long? I have to create a column with long data type. Cassandra version is 2.0.10.

    CREATE TABLE storage (
      key text,
      clientid int,
      deviceid long, // this is wrong I guess as I don't see long in CQL?
      PRIMARY KEY (topic, partition)
    );

I need to have "deviceid" as long data type. Bcoz I am getting deviceid as long and that's how I want to store it.

Jacques-Henri Berthemet

unread,
Dec 8, 2016, 3:41:45 AM12/8/16
to java-dri...@lists.datastax.com

The data type for long is “bigint”:

http://docs.datastax.com/en/cql/3.1/cql/cql_reference/cql_data_types_c.html

 

 

--

Jacques-Henri Berthemet

--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.

Check Peck

unread,
Dec 8, 2016, 4:08:22 PM12/8/16
to java-driver-user
Thanks. That means if I have to insert or read this field using datastax java driver, then I can use like that? Correct?

To Read:
row.getLong();

To write
boundStatement.setLong()

Am I right?


To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-user+unsubscribe@lists.datastax.com.

--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-user+unsubscribe@lists.datastax.com.

Check Peck

unread,
Dec 9, 2016, 3:07:53 PM12/9/16
to java-driver-user
can anyone confirm on this?

On Thu, Dec 8, 2016 at 1:08 PM, Check Peck <compte...@gmail.com> wrote:
Thanks. That means if I have to insert or read this field using datastax java driver, then I can use like that? Correct?

To Read:
row.getLong();

To write
boundStatement.setLong()

Am I right?

Andrew Tolbert

unread,
Dec 9, 2016, 4:21:20 PM12/9/16
to java-driver-user
You are correct.   setLong/getLong works for bigint: http://docs.datastax.com/en/drivers/java/3.1/com/datastax/driver/core/BoundStatement.html#setLong-int-long-:

This method uses the CodecRegistry to find a codec to handle the conversion to the underlying CQL type (for CQL type bigint, this will be the built-in codec).
Reply all
Reply to author
Forward
0 new messages