project_id(String) — Identifier for a BigQuery project. If not
present, the default project for the credentials is used.
credentials(String, Hash, Google::Auth::Credentials) — The path to
the keyfile as a String, the contents of the keyfile as a Hash, or a
Google::Auth::Credentials object. (SeeBigquery::Credentials)
require"google/cloud"gcloud=Google::Cloud.newbigquery=gcloud.bigquerydataset=bigquery.dataset"my_dataset"table=dataset.table"my_table"data=table.data# Iterate over the first page of resultsdata.eachdo|row|putsrow[:name]end# Retrieve the next page of resultsdata=data.nextifdata.next?
The default scope can be overridden with thescopeoption:
[[["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-09-04 UTC."],[],[],null,["Version 1.43.1keyboard_arrow_down\n\n- [1.57.0 (latest)](/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud)\n- [1.56.0](/ruby/docs/reference/google-cloud-bigquery/1.56.0/Google-Cloud)\n- [1.55.0](/ruby/docs/reference/google-cloud-bigquery/1.55.0/Google-Cloud)\n- [1.54.0](/ruby/docs/reference/google-cloud-bigquery/1.54.0/Google-Cloud)\n- [1.53.0](/ruby/docs/reference/google-cloud-bigquery/1.53.0/Google-Cloud)\n- [1.52.1](/ruby/docs/reference/google-cloud-bigquery/1.52.1/Google-Cloud)\n- [1.51.1](/ruby/docs/reference/google-cloud-bigquery/1.51.1/Google-Cloud)\n- [1.50.0](/ruby/docs/reference/google-cloud-bigquery/1.50.0/Google-Cloud)\n- [1.49.1](/ruby/docs/reference/google-cloud-bigquery/1.49.1/Google-Cloud)\n- [1.48.1](/ruby/docs/reference/google-cloud-bigquery/1.48.1/Google-Cloud)\n- [1.47.0](/ruby/docs/reference/google-cloud-bigquery/1.47.0/Google-Cloud)\n- [1.46.1](/ruby/docs/reference/google-cloud-bigquery/1.46.1/Google-Cloud)\n- [1.45.0](/ruby/docs/reference/google-cloud-bigquery/1.45.0/Google-Cloud)\n- [1.44.2](/ruby/docs/reference/google-cloud-bigquery/1.44.2/Google-Cloud)\n- [1.43.1](/ruby/docs/reference/google-cloud-bigquery/1.43.1/Google-Cloud)\n- [1.42.0](/ruby/docs/reference/google-cloud-bigquery/1.42.0/Google-Cloud)\n- [1.41.0](/ruby/docs/reference/google-cloud-bigquery/1.41.0/Google-Cloud)\n- [1.40.0](/ruby/docs/reference/google-cloud-bigquery/1.40.0/Google-Cloud)\n- [1.39.0](/ruby/docs/reference/google-cloud-bigquery/1.39.0/Google-Cloud)\n- [1.38.1](/ruby/docs/reference/google-cloud-bigquery/1.38.1/Google-Cloud) \nReference documentation and code samples for the BigQuery API module Google::Cloud.\n\nMethods\n\n.bigquery \n\n def self.bigquery(project_id = nil, credentials = nil, scope: nil, retries: nil, timeout: nil) -\u003e Google::Cloud::Bigquery::Project\n\nCreates a new `Project` instance connected to the BigQuery service.\nEach call creates a new connection.\n\n\n\u003cbr /\u003e\n\nFor more information on connecting to Google Cloud see the\n[Authentication Guide](./AUTHENTICATION \"Authentication Guide\"). \n**Parameters**\n\n- **project_id** (String) --- Identifier for a BigQuery project. If not present, the default project for the credentials is used.\n- **credentials** (String, Hash, Google::Auth::Credentials) --- The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See [Bigquery::Credentials](/ruby/docs/reference/google-cloud-bigquery/1.43.1/Google-Cloud-Bigquery-Credentials \"Google::Cloud::Bigquery::Credentials (class)\"))\n- **scope** (String, Array\\\u003cString\\\u003e) *(defaults to: nil)* ---\n\n The OAuth 2.0 scopes controlling the\n set of resources and operations that the connection can access. See\n [Using OAuth 2.0 to Access Google\n APIs](https://developers.google.com/identity/protocols/OAuth2).\n\n The default scope is:\n - `https://www.googleapis.com/auth/bigquery`\n- **retries** (Integer) *(defaults to: nil)* --- Number of times to retry requests on server error. The default value is `5`. Optional.\n- **timeout** (Integer) *(defaults to: nil)* --- Default timeout to use in requests. Optional. \n**Returns**\n\n- ([Google::Cloud::Bigquery::Project](./Google-Cloud-Bigquery-Project))\n**Example** \n\n```ruby\nrequire \"google/cloud\"\n\nbigquery = Google::Cloud.bigquery\ndataset = bigquery.dataset \"my_dataset\"\ntable = dataset.table \"my_table\"\n```\n\n#bigquery \n\n def bigquery(scope: nil, retries: nil, timeout: nil) -\u003e Google::Cloud::Bigquery::Project\n\nCreates a new object for connecting to the BigQuery service.\nEach call creates a new connection.\n\n\n\u003cbr /\u003e\n\nFor more information on connecting to Google Cloud see the\n[Authentication Guide](./AUTHENTICATION \"Authentication Guide\"). \n**Parameters**\n\n- **scope** (String, Array\\\u003cString\\\u003e) *(defaults to: nil)* ---\n\n The OAuth 2.0 scopes controlling the\n set of resources and operations that the connection can access. See\n [Using OAuth 2.0 to Access Google\n APIs](https://developers.google.com/identity/protocols/OAuth2).\n\n The default scope is:\n - `https://www.googleapis.com/auth/bigquery`\n- **retries** (Integer) *(defaults to: nil)* --- Number of times to retry requests on server error. The default value is `5`. Optional.\n- **timeout** (Integer) *(defaults to: nil)* --- Default request timeout in seconds. Optional. \n**Returns**\n\n- ([Google::Cloud::Bigquery::Project](./Google-Cloud-Bigquery-Project))\n**Examples** \n\n```ruby\nrequire \"google/cloud\"\n\ngcloud = Google::Cloud.new\nbigquery = gcloud.bigquery\ndataset = bigquery.dataset \"my_dataset\"\ntable = dataset.table \"my_table\"\n\ndata = table.data\n\n# Iterate over the first page of results\ndata.each do |row|\n puts row[:name]\nend\n# Retrieve the next page of results\ndata = data.next if data.next?\n```\n\nThe default scope can be overridden with the `scope` option: \n\n```ruby\nrequire \"google/cloud\"\n\ngcloud = Google::Cloud.new\nplatform_scope = \"https://www.googleapis.com/auth/cloud-platform\"\nbigquery = gcloud.bigquery scope: platform_scope\n```"]]