influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

Return an error for any queries that can't complete due to invalid data types

Open corylanou opened this issue 11 years ago • 3 comments

Currently, you can get into a scenario where you have the same field in multiple shards with different underlying data types. This is due to how shards are created. This is NOT a recommended strategy, and hopefully one users only end up in by accident.

There are two things that can happen.

  1. When issuing a query that requires math against the specified field, if at least one of the shards has the correct data type, we can return just the data we can do arithmetic on.
  2. If none of the shards have an underlying data type that is usable (such as string when the sum aggregate function is used), then we should return an error to the user stating that the query they asked for is invalid against the fields they specified.

Example:

select sum(bytes) from usage

If all of the data written to bytes was a string, an error should be returned. However, if it was a float or an int then it would be fine. If it was mixed, with both string and int, then only the ints would be added and returned, ignoring the non-valid data types.

corylanou avatar Aug 24 '15 21:08 corylanou

@corylanou in the event of mixed types, how would the user know that only partial results had been returned? Can we put an error in the return as well?

beckettsean avatar Aug 24 '15 22:08 beckettsean

I got bitten by this today and it took quite some time to figure out that the datatype of the field I was trying to SUM() over was actually stored as string.

I would very much like SUM or any other arithmetic function to fail hard in case there are any shards with data type that is not applicable to the operation that is being performed. I found getting 0 as a result of SUM very confusing, but clearly an error somewhere. On the other hand, if I would get only partial results, that would be both very confusing and extremely hard to spot.

legendary-jarppi avatar Sep 17 '15 13:09 legendary-jarppi

In the latest version, we fail if you are trying to use a field that doesn't work with an aggregate. We also now have #6529 for selecting a specific type and better support for casting types from different shards to the appropriate type.

I'm going to close this since I think the issue is outdated. Please reopen if I am mistaken.

jsternberg avatar May 16 '16 22:05 jsternberg