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



61
62
63
64
65
# File 'lib/google/cloud/bigquery/insert_response.rb', line 61

def errors_for row
  ie = insert_error_for row
  return ie.errors if ie
  []
end

#index_for(row) ⇒ Object



67
68
69
70
71
# File 'lib/google/cloud/bigquery/insert_response.rb', line 67

def index_for row
  ie = insert_error_for row
  return ie.index if ie
  nil
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_error_for(row) ⇒ Object



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

def insert_error_for row
  json_row = Convert.to_json_row(row)
  insert_errors.detect { |e| e.row == json_row }
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 ie.index, 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