Skip to content

Business intelligence made simple

Fixed error with empty results with InfluxDB [skip ci]

Andrew Kanebf2aec1c039e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 867d2494..ca54e23f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
## 2.5.1 (unreleased)
- Added experimental support for Propshaft
+- Fixed error with empty results with InfluxDB
## 2.5.0 (2022-01-04)
diff --git a/lib/blazer/adapters/influxdb_adapter.rb b/lib/blazer/adapters/influxdb_adapter.rb
index fe28e2df..ab59aa9b 100644
--- a/lib/blazer/adapters/influxdb_adapter.rb
+++ b/lib/blazer/adapters/influxdb_adapter.rb
@@ -8,16 +8,19 @@ module Blazer
begin
result = client.query(statement, denormalize: false).first
- columns = result["columns"]
- rows = result["values"]
-
- # parse time columns
- # current approach isn't ideal, but result doesn't include types
- # another approach would be to check the format
- time_index = columns.index("time")
- if time_index
- rows.each do |row|
- row[time_index] = Time.parse(row[time_index]) if row[time_index]
+
+ if result
+ columns = result["columns"]
+ rows = result["values"]
+
+ # parse time columns
+ # current approach isn't ideal, but result doesn't include types
+ # another approach would be to check the format
+ time_index = columns.index("time")
+ if time_index
+ rows.each do |row|
+ row[time_index] = Time.parse(row[time_index]) if row[time_index]
+ end
end
end
rescue => e