I am using Java and querying InfluxDb as shown below,
queryResult1 = influxDB.query(new Query("SELECT last(timestamp) FROM vale" , eachDatabase));
This statement is working fine, but when the name have any of the special character for e.g. if measurement name is "vale-ab" instead of vale, it won't work.
Error i am getting is:
java.lang.RuntimeException: {"error":"error parsing query: found -, expected ; at line 1, char 34"}
Any idea how can i escape measurement name inside the queries.
You need to wrap your measurement with double quotes "
.
Bad:
select * from a-b
ERR: error parsing query: found -, expected ; at line 1, char 16
Good:
select * from "a-b"
name: a-b
time tag1 value
---- ---- -----
1434089562000000000 10i 5
I don't have Java
installed on this machine but the code below should solve your problem.
queryResult1 = influxDB.query(new Query("SELECT last(timestamp) FROM \"vale-vale\"" , eachDatabase));