Reference documentation and code samples for the BigQuery API class Google::Cloud::Bigquery::Table::AsyncInserter::Result.
AsyncInserter::Result
Represents the result from BigQuery, including any error encountered, when data is asynchronously inserted into a table for near-immediate querying. See Dataset#insert_async and Google::Cloud::Bigquery::Table#insert_async.
Inherits
- Object
Example
require "google/cloud/bigquery" bigquery = Google::Cloud::Bigquery.new dataset = bigquery.dataset "my_dataset" table = dataset.table "my_table" inserter = table.insert_async do |result| if result.error? log_error result.error else log_insert "inserted #{result.insert_count} rows " \ "with #{result.error_count} errors" end end rows = [ { "first_name" => "Alice", "age" => 21 }, { "first_name" => "Bob", "age" => 22 } ] inserter.insert rows inserter.stop.wait!
Methods
#error
def error() -> Error, nilThe error from the insert operation
if any error was encountered, otherwise nil.
- (Error, nil) — the current value of error
#error?
def error?() -> BooleanChecks if an error is present, meaning that the insert operation encountered an error. Use #error to access the error. For row-level errors, see #success? and #insert_errors.
-
(Boolean) —
truewhen an error is present,falseotherwise.
#error_count
def error_count() -> Integer, nilThe count of errors for rows that were not inserted.
-
(Integer, nil) — The number of errors, or
nilif the insert operation encountered an error.
#error_rows
def error_rows() -> Array<Hash>, nilThe rows that were not inserted.
-
(Array<Hash>, nil) — An array of hash objects containing the
row data, or
nilif the insert operation encountered an error.
#errors_for
def errors_for(row) -> Array<Hash>, nilReturns the error hashes for a row that was not inserted. Each
error hash contains the following keys: reason, location,
debugInfo, and message.
- row (Hash, nil) — A hash containing the data for a row.
-
(Array<Hash>, nil) — An array of error hashes,
nilif no errors are found in the response for the row, ornilif the insert operation encountered an error.
#index_for
def index_for(row) -> Integer, nilReturns the index for a row that was not inserted.
- row (Hash, nil) — A hash containing the data for a row.
-
(Integer, nil) — An error object,
nilif no error is found in the response for the row, ornilif the insert operation encountered an error.
#insert_count
def insert_count() -> Integer, nilThe count of rows in the response, minus the count of errors for rows that were not inserted.
-
(Integer, nil) — The number of rows inserted, or
nilif the insert operation encountered an error.
#insert_error_for
def insert_error_for(row) -> InsertError, nilReturns the error object for a row that was not inserted.
- row (Hash) — A hash containing the data for a row.
-
(InsertError, nil) — An error object,
nilif no error is found in the response for the row, ornilif the insert operation encountered an error.
#insert_errors
def insert_errors() -> Array<InsertError>, nilThe error objects for rows that were not inserted.
-
(Array<InsertError>, nil) — An array containing error
objects, or
nilif the insert operation encountered an error.
#insert_response
def insert_response() -> Google::Cloud::Bigquery::InsertResponse, nilThe response from the insert operation if no
error was encountered, or nil if the insert operation
encountered an error.
- (Google::Cloud::Bigquery::InsertResponse, nil) — the current value of insert_response
#success?
def success?() -> Boolean, nilChecks if the error count for row-level errors is zero, meaning that all of the rows were inserted. Use #insert_errors to access the row-level errors. To check for and access any operation-level error, use #error? and #error.
-
(Boolean, nil) —
truewhen the error count is zero,falsewhen the error count is positive, ornilif the insert operation encountered an error.