cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexandre Dutra <alexandre.du...@datastax.com>
Subject Re: SELECT JSON timestamp lacks timezone information
Date Mon, 08 Feb 2016 11:06:08 GMT
Hello Ralf,

First of all, Cassandra stores timestamps without timezone information, so
it's not possible to retrieve the original timezone used when inserting the
value.

CQLSH uses the python driver behind the scenes, and my guess is that the
timestamp formatting is being done driver-side – hence the timezone – while
when you call toJson(), the formatting has to be done server-side.

That said, it does seem that Cassandra is using a format without timezone
when converting timestamps to JSON format:
https://github.com/apache/cassandra/blob/cassandra-3.0/src/java/org/apache/cassandra/serializers/TimestampSerializer.java#L52

I agree with you that a date format that would include the timezone would
be preferable here, but that is a question you should ask in the Cassandra
Users mailing list instead.

Hope that helps,

Alexandre




On Mon, Feb 8, 2016 at 11:09 AM Ralf Steppacher <ralf.vivates@gmail.com>
wrote:

> Hello all,
>
> When I select a timestamp as JSON from Cassandra, the string
> representation lacks the timezone information, both via CQLSH and the Java
> Driver:
>
> cqlsh:events> select toJson(created_at) AS created_at from
> event_by_patient_timestamp ;
>
>  created_at
> ---------------------------
>  "2016-01-04 16:05:47.123"
>
> (1 rows)
>
> vs.
>
> cqlsh:events> select created_at FROM event_by_user_timestamp ;
>
>  created_at
> --------------------------
>  2016-01-04 15:05:47+0000
>
> (1 rows)
> cqlsh:events>
>
> To make things even more complicated the JSON timestamp is not returned in
> UTC. Is there a way to either tell the driver/C* to return the JSON date in
> UTC or add the timezone information (much preferred) to the text
> representation of the timestamp?
>
>
> Thanks!
> Ralf

-- 
Alexandre Dutra
Driver & Tools Engineer @ DataStax

Mime
View raw message