[0.9.0] Inconsistency between missing measurement and missing tag
When querying a measurement that does not exist the DB returns a json object with neither results nor error, but when querying for a tag that doesn't exist the DB returns a top-level error. This behavior seems inconsistent and makes it difficult to handle querying of an "empty" database.
@vptheron I cannot reproduce the issue. Can you give me some more information about exactly what your issue is? Preferably with logs and commands.
Starting with a completely empty database called my_db.
-
The query:
SELECT SUM(value) FROM my_measurementreturns:{"results":[{}]} -
The query:
SELECT SUM(value) FROM my_measurement WHERE foo = 'hello'returns:{"results":[{"error":"unknown field or tag name in where clause: foo"}]}
This may be an edge case due to the aggregation.
Note: I'm using the REST API directly, not the influx client.
This is currently expected behavior I think. In the first instance, the statement is syntactically valid and parseable, but there are no results to return. In the second, the statement is syntactically valid but fails on parsing because the referenced tag does not exist.
Because SELECT statements can operate against a collection of measurements via regular expressions, e.g. SELECT * FROM /cpu.*/ the parser intentionally does not fail if the referenced measurement(s) do not exist.
However, since the tags are part of the WHERE clause a referenced tag that doesn't exist is a parser error. If foo existed but had no values equal to hello it would return the empty result set again.
I understand. I personally think that it makes it difficult to start using a fresh database. One may have a client querying the DB before all kinds of data have been inserted, so until a point is inserted with the tag 'foo' the client needs to handle an error and know that this error is part of the normal flow.
It makes sense for a relational DB with a defined schema, but for a schema-less storage it may be better to loosen the failure cases, returning empty results for non-existent measurements/tags may be a good option.
Just my two cents :)
I'll take a closer look at this during the query-engine rework.
This was originally filed with a much older version of the software. Please try upgrading and tell us if this is still a problem. Thanks.