Class: Gcloud::Bigquery::InsertResponse

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

Overview

InsertResponse

Defined Under Namespace

Classes: InsertError

Instance Method Summary collapse

Instance Method Details

#error_countObject


35
36
37
# File 'lib/gcloud/bigquery/insert_response.rb', line 35

def error_count
  @error_count ||= Array(@gapi["insertErrors"]).count
end

#error_rowsObject


49
50
51
52
53
54
55
# File 'lib/gcloud/bigquery/insert_response.rb', line 49

def error_rows
  @error_rows ||= begin
    Array(@gapi["insertErrors"]).map do |ie|
      @rows[ie["index"]]
    end
  end
end

#errors_for(row) ⇒ Object


57
58
59
60
61
# File 'lib/gcloud/bigquery/insert_response.rb', line 57

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

#insert_countObject


31
32
33
# File 'lib/gcloud/bigquery/insert_response.rb', line 31

def insert_count
  @insert_count ||= @rows.count - error_count
end

#insert_errorsObject


39
40
41
42
43
44
45
46
47
# File 'lib/gcloud/bigquery/insert_response.rb', line 39

def insert_errors
  @insert_errors ||= begin
    Array(@gapi["insertErrors"]).map do |ie|
      row = @rows[ie["index"]]
      errors = ie["errors"]
      InsertError.new row, errors
    end
  end
end

#success?Boolean

Returns:

  • (Boolean)

27
28
29
# File 'lib/gcloud/bigquery/insert_response.rb', line 27

def success?
  error_count.zero?
end