Class: Gcloud::Bigquery::InsertResponse
- Inherits:
-
Object
- Object
- Gcloud::Bigquery::InsertResponse
- Defined in:
- lib/gcloud/bigquery/insert_response.rb
Overview
InsertResponse
Defined Under Namespace
Classes: InsertError
Class Method Summary collapse
-
.from_gapi(rows, gapi) ⇒ Object
Google::Apis::BigqueryV2::InsertAllTableDataResponse object.
Instance Method Summary collapse
- #error_count ⇒ Object
- #error_rows ⇒ Object
- #errors_for(row) ⇒ Object
-
#initialize(rows, gapi) ⇒ InsertResponse
constructor
A new instance of InsertResponse.
- #insert_count ⇒ Object
- #insert_errors ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(rows, gapi) ⇒ InsertResponse
Returns a new instance of InsertResponse.
24 25 26 27 |
# File 'lib/gcloud/bigquery/insert_response.rb', line 24 def initialize rows, gapi @rows = rows @gapi = gapi end |
Class Method Details
.from_gapi(rows, gapi) ⇒ Object
Google::Apis::BigqueryV2::InsertAllTableDataResponse object.
63 64 65 |
# File 'lib/gcloud/bigquery/insert_response.rb', line 63 def self.from_gapi rows, gapi new rows, gapi end |
Instance Method Details
#error_count ⇒ Object
37 38 39 |
# File 'lib/gcloud/bigquery/insert_response.rb', line 37 def error_count Array(@gapi.insert_errors).count end |
#error_rows ⇒ Object
49 50 51 52 53 |
# File 'lib/gcloud/bigquery/insert_response.rb', line 49 def error_rows Array(@gapi.insert_errors).map do |ie| @rows[ie.index] end end |
#errors_for(row) ⇒ Object
55 56 57 58 59 |
# File 'lib/gcloud/bigquery/insert_response.rb', line 55 def errors_for row ie = insert_errors.detect { |e| e.row == row } return ie.errors if ie [] end |
#insert_count ⇒ Object
33 34 35 |
# File 'lib/gcloud/bigquery/insert_response.rb', line 33 def insert_count @rows.count - error_count end |
#insert_errors ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/gcloud/bigquery/insert_response.rb', line 41 def insert_errors Array(@gapi.insert_errors).map do |ie| row = @rows[ie.index] errors = ie.errors.map { |e| JSON.parse e.to_json } InsertError.new row, errors end end |
#success? ⇒ Boolean
29 30 31 |
# File 'lib/gcloud/bigquery/insert_response.rb', line 29 def success? error_count.zero? end |