Reference documentation and code samples for the BigQuery API class Google::Cloud::Bigquery::InsertResponse.
InsertResponse
Represents the response from BigQuery when data is inserted into a table
for near-immediate querying, without the need to complete a load
operation before the data can appear in query results. See
Dataset#insert and Table#insert.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 UTC."],[],[],null,["Version 1.45.0keyboard_arrow_down\n\n- [1.57.0 (latest)](/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-InsertResponse)\n- [1.56.0](/ruby/docs/reference/google-cloud-bigquery/1.56.0/Google-Cloud-Bigquery-InsertResponse)\n- [1.55.0](/ruby/docs/reference/google-cloud-bigquery/1.55.0/Google-Cloud-Bigquery-InsertResponse)\n- [1.54.0](/ruby/docs/reference/google-cloud-bigquery/1.54.0/Google-Cloud-Bigquery-InsertResponse)\n- [1.53.0](/ruby/docs/reference/google-cloud-bigquery/1.53.0/Google-Cloud-Bigquery-InsertResponse)\n- [1.52.1](/ruby/docs/reference/google-cloud-bigquery/1.52.1/Google-Cloud-Bigquery-InsertResponse)\n- [1.51.1](/ruby/docs/reference/google-cloud-bigquery/1.51.1/Google-Cloud-Bigquery-InsertResponse)\n- [1.50.0](/ruby/docs/reference/google-cloud-bigquery/1.50.0/Google-Cloud-Bigquery-InsertResponse)\n- [1.49.1](/ruby/docs/reference/google-cloud-bigquery/1.49.1/Google-Cloud-Bigquery-InsertResponse)\n- [1.48.1](/ruby/docs/reference/google-cloud-bigquery/1.48.1/Google-Cloud-Bigquery-InsertResponse)\n- [1.47.0](/ruby/docs/reference/google-cloud-bigquery/1.47.0/Google-Cloud-Bigquery-InsertResponse)\n- [1.46.1](/ruby/docs/reference/google-cloud-bigquery/1.46.1/Google-Cloud-Bigquery-InsertResponse)\n- [1.45.0](/ruby/docs/reference/google-cloud-bigquery/1.45.0/Google-Cloud-Bigquery-InsertResponse)\n- [1.44.2](/ruby/docs/reference/google-cloud-bigquery/1.44.2/Google-Cloud-Bigquery-InsertResponse)\n- [1.43.1](/ruby/docs/reference/google-cloud-bigquery/1.43.1/Google-Cloud-Bigquery-InsertResponse)\n- [1.42.0](/ruby/docs/reference/google-cloud-bigquery/1.42.0/Google-Cloud-Bigquery-InsertResponse)\n- [1.41.0](/ruby/docs/reference/google-cloud-bigquery/1.41.0/Google-Cloud-Bigquery-InsertResponse)\n- [1.40.0](/ruby/docs/reference/google-cloud-bigquery/1.40.0/Google-Cloud-Bigquery-InsertResponse)\n- [1.39.0](/ruby/docs/reference/google-cloud-bigquery/1.39.0/Google-Cloud-Bigquery-InsertResponse)\n- [1.38.1](/ruby/docs/reference/google-cloud-bigquery/1.38.1/Google-Cloud-Bigquery-InsertResponse) \nReference documentation and code samples for the BigQuery API class Google::Cloud::Bigquery::InsertResponse.\n\nInsertResponse\n\n\n\u003cbr /\u003e\n\nRepresents the response from BigQuery when data is inserted into a table\nfor near-immediate querying, without the need to complete a load\noperation before the data can appear in query results. See\n[Dataset#insert](/ruby/docs/reference/google-cloud-bigquery/1.45.0/Google-Cloud-Bigquery-Dataset#Google__Cloud__Bigquery__Dataset_insert_instance_ \"Google::Cloud::Bigquery::Dataset#insert (method)\") and [Table#insert](/ruby/docs/reference/google-cloud-bigquery/1.45.0/Google-Cloud-Bigquery-Table#Google__Cloud__Bigquery__Table_insert_instance_ \"Google::Cloud::Bigquery::Table#insert (method)\"). \n\nInherits\n\n- Object\n\nExample \n\n```ruby\nrequire \"google/cloud/bigquery\"\n\nbigquery = Google::Cloud::Bigquery.new\ndataset = bigquery.dataset \"my_dataset\"\n\nrows = [\n { \"first_name\" =\u003e \"Alice\", \"age\" =\u003e 21 },\n { \"first_name\" =\u003e \"Bob\", \"age\" =\u003e 22 }\n]\n\ninsert_response = dataset.insert \"my_table\", rows\n```\n\nMethods\n\n#error_count \n\n def error_count() -\u003e Integer\n\nThe count of errors for rows that were not inserted. \n**Returns**\n\n- (Integer) --- The number of errors.\n\n#error_rows \n\n def error_rows() -\u003e Array\u003cHash\u003e\n\nThe rows that were not inserted. \n**Returns**\n\n- (Array\\\u003cHash\\\u003e) --- An array of hash objects containing the row data.\n\n#errors_for \n\n def errors_for(row) -\u003e Array\u003cHash\u003e, nil\n\nReturns the error hashes for a row that was not inserted. Each error\nhash contains the following keys: `reason`, `location`, `debugInfo`,\nand `message`. \n**Parameter**\n\n- **row** (Hash) --- A hash containing the data for a row. \n**Returns**\n\n- (Array\\\u003cHash\\\u003e, nil) --- An array of error hashes, or `nil` if no errors are found in the response for the row.\n\n#index_for \n\n def index_for(row) -\u003e Integer, nil\n\nReturns the index for a row that was not inserted. \n**Parameter**\n\n- **row** (Hash) --- A hash containing the data for a row. \n**Returns**\n\n- (Integer, nil) --- An error object, or `nil` if no error is found in the response for the row.\n\n#insert_count \n\n def insert_count() -\u003e Integer\n\nThe count of rows in the response, minus the count of errors for rows\nthat were not inserted. \n**Returns**\n\n- (Integer) --- The number of rows inserted.\n\n#insert_error_for \n\n def insert_error_for(row) -\u003e InsertError, nil\n\nReturns the error object for a row that was not inserted. \n**Parameter**\n\n- **row** (Hash) --- A hash containing the data for a row. \n**Returns**\n\n- ([InsertError](./Google-Cloud-Bigquery-InsertResponse-InsertError), nil) --- An error object, or `nil` if no error is found in the response for the row.\n\n#insert_errors \n\n def insert_errors() -\u003e Array\u003cInsertError\u003e\n\nThe error objects for rows that were not inserted. \n**Returns**\n\n- (Array\\\u003c[InsertError](./Google-Cloud-Bigquery-InsertResponse-InsertError)\\\u003e) --- An array containing error objects.\n\n#success? \n\n def success?() -\u003e Boolean\n\nChecks if the error count is zero, meaning that all of the rows were\ninserted. Use [#insert_errors](/ruby/docs/reference/google-cloud-bigquery/1.45.0/Google-Cloud-Bigquery-InsertResponse#Google__Cloud__Bigquery__InsertResponse_insert_errors_instance_ \"Google::Cloud::Bigquery::InsertResponse#insert_errors (method)\") to access the errors. \n**Returns**\n\n- (Boolean) --- `true` when the error count is zero, `false` otherwise."]]