Skip to content

Commit 6bf5c12

Browse files
author
Enric Sala
committed
Ignore empty series in a query result instead of throwing an error
1 parent 1b8e82f commit 6bf5c12

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

influxdb-client/QueryResult.m

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@
5050
methods(Static)
5151
% Convert a response to objects
5252
function objs = from(response)
53-
assert(~isempty(response.results), 'the response contains no results');
54-
objs = arrayfun(@(x) QueryResult.wrap(x), response.results);
53+
assert(~isempty(response.results), ...
54+
'from:empty', 'the response contains no results');
55+
objs = arrayfun(@(x) QueryResult.wrap(x), ...
56+
response.results, 'UniformOutput', false);
57+
nonempty = cellfun(@(x) ~isempty(x), objs);
58+
objs = cellfun(@(x) x, objs(nonempty));
5559
end
5660
end
5761

@@ -61,9 +65,12 @@
6165
if isfield(result, 'error')
6266
error('query:error', 'query error: %s', result.error);
6367
end
64-
assert(isfield(result, 'series'), 'the result contains no series');
65-
series = arrayfun(@(x) SeriesResult.from(x), result.series);
66-
obj = QueryResult(series);
68+
if isfield(result, 'series')
69+
series = arrayfun(@(x) SeriesResult.from(x), result.series);
70+
obj = QueryResult(series);
71+
else
72+
obj = [];
73+
end
6774
end
6875

6976
% Filter series by matching tags

0 commit comments

Comments
 (0)