Class: Google::Cloud::Bigquery::InsertResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/bigquery/insert_response.rb

Overview

InsertResponse

Defined Under Namespace

Classes: InsertError

Instance Method Summary collapse

Instance Method Details

#error_countObject



38
39
40
# File 'lib/google/cloud/bigquery/insert_response.rb', line 38

def error_count
  Array(@gapi.insert_errors).count
end

#error_rowsObject



50
51
52
53
54
# File 'lib/google/cloud/bigquery/insert_response.rb', line 50

def error_rows
  Array(@gapi.insert_errors).map do |ie|
    @rows[ie.index]
  end
end

#errors_for(row) ⇒ Object



56
57
58
59
60
# File 'lib/google/cloud/bigquery/insert_response.rb', line 56

def errors_for row
  ie = insert_errors.detect { |e| e.row == row }
  return ie.errors if ie
  []
end

#insert_countObject



34
35
36
# File 'lib/google/cloud/bigquery/insert_response.rb', line 34

def insert_count
  @rows.count - error_count
end

#insert_errorsObject



42
43
44
45
46
47
48
# File 'lib/google/cloud/bigquery/insert_response.rb', line 42

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

Returns:

  • (Boolean)


30
31
32
# File 'lib/google/cloud/bigquery/insert_response.rb', line 30

def success?
  error_count.zero?
end