Search code examples
cassandracqldatastax-java-driver

How do I select token value using com.datastax.oss.driver.api.querybuilder.QueryBuilder?


How to rewrite

select  token(id) as t, id  from example

using com.datastax.oss.driver.api.querybuilder.QueryBuilder class?


Solution

  • TOKEN() is a native CQL function which you cannot call with the QueryBuilder. It also doesn't make sense to do so.

    If you already have a static CQL query, you should just execute it. The general proposition for the Query builder in the Java driver is to generate dynamic CQL queries. It isn't a replacement for static statements. Cheers!