influxdb: influxql: handle null-cases in timeseries data (#37047)

This commit is contained in:
Gábor Farkas 2021-07-21 10:44:41 +02:00 committed by GitHub
parent 3fb80ac474
commit 14274a960e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,13 +34,16 @@ import { catchError, map } from 'rxjs/operators';
// we detect the field type based on the value-array
function getFieldType(values: unknown[]): FieldType {
if (values.length === 0) {
// if we get called with an empty value-array,
// we will assume the values are numbers
// the values-array may contain a lot of nulls.
// we need the first not-null item
const firstNotNull = values.find((v) => v !== null);
if (firstNotNull === undefined) {
// we could not find any not-null values
return FieldType.number;
}
const valueType = typeof values[0];
const valueType = typeof firstNotNull;
switch (valueType) {
case 'string':