Browse Source

Configurable BigQuery timeout

Andrew Kane 7 years ago
parent
commit
9bdb67205e
1 changed files with 9 additions and 3 deletions
  1. 9 3
      lib/blazer/adapters/bigquery_adapter.rb

+ 9 - 3
lib/blazer/adapters/bigquery_adapter.rb

@@ -7,9 +7,15 @@ module Blazer
         error = nil
 
         begin
-          results = bigquery.query(statement, timeout: 30000) # ms
-          columns = results.first.keys.map(&:to_s) if results.size > 0
-          rows = results.map(&:values)
+          options = {}
+          options[:timeout] = data_source.timeout.to_i * 1000 if data_source.timeout
+          results = bigquery.query(statement, options) # ms
+          if results.complete?
+            columns = results.first.keys.map(&:to_s) if results.size > 0
+            rows = results.map(&:values)
+          else
+            error = "Timed out"
+          end
         rescue => e
           error = e.message
         end