influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

query 'select * from user' returns error even if there is a 'user' series

Open imlk opened this issue 11 years ago • 2 comments

Version : 0.9.0 Source: https://s3.amazonaws.com/influxdb/influxdb_0.9.0_amd64.deb OS: Ubuntu

Steps : #Create new db curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"

#Create and write to a series name 'user' curl -i -XPOST 'http://localhost:8086/write?db=mydb' -d 'user name="john"'

#Create and write to a series name 'tenant' curl -i -XPOST 'http://localhost:8086/write?db=mydb' -d 'tenant name="mike"'

#Query the series 'tenant', returns data curl -G 'http://localhost:8086/query' --data-urlencode "db=mydb" --data-urlencode "q=SELECT * FROM tenant"

{
  "results": [
    {
      "series": [
        {
          "name": "tenant",
          "columns": [
            "time",
            "name"
          ],
          "values": [
            [
              "2015-06-22T22:33:17.003586465Z",
              "mike"
            ]
          ]
        }
      ]
    }
  ]
}

#Query the series 'user', returns error: curl -G 'http://localhost:8086/query' --data-urlencode "db=mydb" --data-urlencode "q=SELECT * FROM user"

"error parsing query: found USER, expected identifier at line 1, char 15" 

I know that "USER" is kind of a keyword in InfluxDB 0.9, is that the reason why the SELECT query fails ? If so, are there any other ways we can operate a series named "user" ?

imlk avatar Jun 22 '15 22:06 imlk

@imlk you need to surround the measurement name in double-quotes so that the parser knows it's an identifier and not the reserved word, USER.

SELECT * FROM "user"

beckettsean avatar Jun 22 '15 23:06 beckettsean

@beckettsean Thanks

imlk avatar Jun 22 '15 23:06 imlk