Parcourir la source

Configurable BigQuery timeout

Andrew Kane il y a 7 ans
Parent
commit
9bdb67205e
1 fichiers modifiés avec 9 ajouts et 3 suppressions
  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