0
votes

I'm trying to get a few columns from cassandra table with just one column as Json string using datastax queryBuilder. I tried to construct the query in folloing ways and didnt work.

Select.Where selectByKey = QueryBuilder.select().fcall("fromJson", "columnX") .column("columnX") .from("keyspaceName", "tableName") .where(QueryBuilder.eq(key, QueryBuilder.bindMarker()));

Select.Where selectByKey = QueryBuilder.select().fcall("fromJson", "columnX") .all() .from("keyspaceName", "tableName") .where(QueryBuilder.eq(key, QueryBuilder.bindMarker()));

Select.Where selectByKey = QueryBuilder.select().fcall("fromJson", "columnX") .column("[json]") .from("keyspaceName", "tableName") .where(QueryBuilder.eq(key, QueryBuilder.bindMarker()));

Errors are like, no viable alternative at input 'columnX' (SELECT "[json]",fromJson[(]'columnX...)

All the columns are basically text except columnX which has a text in a Json format. I need some solution to get a single column as json, or whole record as json using Query Builder. Thanks

1

1 Answers

1
votes

From what I understand from here, you need to use, QueryBuilder.column("columnX") instead of "columnX" as a parameter to fcall.

Hope it helps!