Astyanax and Java Driver

96 views
Skip to first unread message

Luis Ángel Vicente Sánchez

unread,
Sep 16, 2014, 12:23:46 PM9/16/14
to astyanax-cas...@googlegroups.com
I'm trying to query some time series I have stored in cassandra and I'm getting this exception:

[error] Exception in thread "main" com.datastax.driver.core.exceptions.InvalidTypeException: Invalid type for value 1 of CQL type timestamp, expecting class java.util.Date but class java.lang.Long provided
[error] at com.datastax.driver.core.BoundStatement.bind(BoundStatement.java:190)
[error] at com.datastax.driver.core.DefaultPreparedStatement.bind(DefaultPreparedStatement.java:103)
[error] at com.netflix.astyanax.cql.direct.DirectCqlPreparedStatement.execute(DirectCqlPreparedStatement.java:43)
[error] at CqlTest$.delayedEndpoint$CqlTest$1(CqlTest.scala:58)
[error] at CqlTest$delayedInit$body.apply(CqlTest.scala:16)
[error] at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
[error] at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
[error] at scala.App$$anonfun$main$1.apply(App.scala:76)
[error] at scala.App$$anonfun$main$1.apply(App.scala:76)
[error] at scala.collection.immutable.List.foreach(List.scala:381)
[error] at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
[error] at scala.App$class.main(App.scala:76)
[error] at CqlTest$.main(CqlTest.scala:16)
[error] at CqlTest.main(CqlTest.scala)

De column family looks like this:

CREATE TABLE concurrent_users (
  game TEXT,
  time TIMESTAMP,
  counter BLOB,
  PRIMARY KEY (game,  time)
) WITH DEFAULT_TIME_TO_LIVE = 2678400;

And I querying it like this:

  val result: Rows[String, String] =
    keyspace
      .prepareQuery(CF_CONCURRENT_USERS)
      .withCql("SELECT * FROM concurrent_users WHERE game = ? and time > ? and time < ? ALLOW FILTERING;")
      .asPreparedStatement()
      .withStringValue("warriors")
      .withLongValue(1409920500000L)
      .withLongValue(1409927700000L)
      .execute()
      .getResult
      .getRows

There is no withDate method so... is there a way I can use a Date instead of a Long to set the filter?
 

Nate McCall

unread,
Sep 16, 2014, 1:13:46 PM9/16/14
to Luis Ángel Vicente Sánchez, astyanax-cas...@googlegroups.com
There is a withTimestamp on MutationBatch and related wrappers, so it should be there. 

Just checked, looks like it got left out on c.n.a.cql.reads.DirectCqlQueryImpl which is where that construction occurs. 

--
You received this message because you are subscribed to the Google Groups "Astyanax Cassandra Client" group.
To unsubscribe from this group and stop receiving emails from it, send an email to astyanax-cassandra...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-----------------
Nate McCall
Austin, TX
@zznate

Co-Founder & Sr. Technical Consultant
Apache Cassandra Consulting
http://www.thelastpickle.com

Nate McCall

unread,
Sep 17, 2014, 3:10:37 AM9/17/14
to Luis Ángel Vicente Sánchez, astyanax-cas...@googlegroups.com
Sent a PR just now adding this in. 
Reply all
Reply to author
Forward
0 new messages