DataStax Graph data types

Describes the DataStax Graph data types.

DataStax Graph (DSG) uses Apache Cassandra CQL data types. For search indexes, see the relationship between DSG and Solr data types.

DSE Graph Data Type Description addV/addE example

Ascii

ASCII value

property('ascii_code', 'ascii')

Bigint

64-bit signed long

property('big_number', 23L)

Blob

Arbitrary bytes (no validation), expressed as base64 strings

property('blob_thing', [3, 4] as ByteBuffer)

Boolean

True or false

property('alive', true)

Date

Date, in the format of '1940' or '1940-01-01'.

property('review_date', '2010-10-02' as LocalDate)

Decimal

Variable-precision decimal

When dealing with currency, DataStax recommends a currency class that serializes to and from an int or use of the decimal data type.

property('book_price', 2.57)

Double

64-bit IEEE-754 floating point

property('stars', 2.4d)

Duration

Time duration in milliseconds

property('until', 'PT10H' as Duration)

Float

32-bit IEEE-754 floating point

property('precise', 8.9f)

Inet

IP address string in IPv4 or IPv6 format, used by the python-cql driver and CQL native protocols

property('website_ip', '192.168.1.2' as InetAddress) or property('website_ip', '2001:4860:4860:8888' as InetAddress)

Int

32-bit signed integer

property('age', 38)

Linestring

Used for geospatial linestrings

property('road', [1, 1, 2, 2, 3, 3] as LineString) or property('road', ['LINESTRING (30 10, 10 20, 40 40)' as LineString)

Point

Used for geospatial; note that this corresponds to longitude/latitude, in that order, for mapping geospatial points.

property('coordinates', [1.1, 2.2] as Point) or property('coordinates', ['POINT (30 10)' as Point)

Polygon

Used for geospatial and Cartesian polygons (double …​. points) a

property('block', [1, 1, 2, 2, 3, 3, 0.9, 0.9, 1.1, 1.1] as Polygon) or property('block', ['POLYGON ((30 10, 10 20, 40 40, 20 40, 10 20)' as Polygon)

Smallint

2 byte integer

property('age', 37 as short)

Text

String or UTF-8 encoded string

property('name', 'Jimmie Olsen')

Time

Time in the format of '10:00:00' or '10:00'.

property('time', '10:15:30' as LocalTime)

Timestamp

Date, or date plus time, encoded as 8 bytes since epoch. The timestamp data type must be specified as a valid DSE database timestamp: ` johnDoe.addEdge('rated', beefBourguignon, 'timestamp', '2014-01-01T00:00:00.00Z', 'stars', 5, 'comment', 'Pretty tasty!') `

property('meal_date', '2009-10-23T10:15:30.00Z' as Instant)

Timeuuid

A Time UUID

property('timehack', UUIDs.timeBased())

Tinyint

property('number', 34 as byte)

Uuid

A UUID in standard UUID format or timeuuid format

property('person_id', 'bb6d7af7-f674-4de7-8b4c-c0fdcdaa5cca' as UUID)

Varchar

Arbitrary string

property('name', 'Rosie Riveter')

Varint

Arbitrary-precision integer

property('number', 1000)

List

Ordered list collection

property('list', [1, 2, 3])

Set

Unordered list collection

property('set', [1, 2, 3] as Set)

Map

Key-value pairs collection

property('map', [k1:'v2', k2:v2])

Tuple

Defined tuple

property('tuple', [1, 2, 'mary'] as Tuple)

User-defined type (UDT)

User-defined type

property('udt', [address:'add1', address:'add2', zipcode: 12345] as address)

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

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: +1 (650) 389-6000, info@datastax.com