influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

[0.9.0] Inconsistency between missing measurement and missing tag

Open vptheron opened this issue 11 years ago • 6 comments

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 avatar Jun 30 '15 20:06 vptheron

@vptheron I cannot reproduce the issue. Can you give me some more information about exactly what your issue is? Preferably with logs and commands.

desa avatar Jun 30 '15 20:06 desa

Starting with a completely empty database called my_db.

  1. The query: SELECT SUM(value) FROM my_measurement returns: {"results":[{}]}

  2. 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.

vptheron avatar Jul 01 '15 12:07 vptheron

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.

beckettsean avatar Jul 01 '15 15:07 beckettsean

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 :)

vptheron avatar Jul 01 '15 16:07 vptheron

I'll take a closer look at this during the query-engine rework.

otoolep avatar Jul 02 '15 00:07 otoolep

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.

jsternberg avatar May 17 '16 19:05 jsternberg