Permalink
Browse files

Fix a nullpointer exception on empty result set

  • Loading branch information...
1 parent 350972b commit 34f1dd390949dddc5dbaeedffe0097355abc8b62 @sixtus sixtus committed Apr 5, 2013
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/druid/console.rb
@@ -12,8 +12,10 @@ def format_query_result(result, query)
include_timestamp = query.properties[:granularity] != 'all'
+ keys = result.empty? ? [] : result.last.keys
+
Terminal::Table.new({
- headings: (include_timestamp ? ["timestamp"] : []) + result.last.keys,
+ headings: (include_timestamp ? ["timestamp"] : []) + keys,
rows: result.map { |row| (include_timestamp ? [row.timestamp] : []) + row.values }
})
end

0 comments on commit 34f1dd3

Please sign in to comment.