Module: Google::Cloud::Bigquery

Defined in:
lib/google/cloud/bigquery.rb,
lib/google/cloud/bigquery/job.rb,
lib/google/cloud/bigquery/data.rb,
lib/google/cloud/bigquery/time.rb,
lib/google/cloud/bigquery/model.rb,
lib/google/cloud/bigquery/table.rb,
lib/google/cloud/bigquery/schema.rb,
lib/google/cloud/bigquery/convert.rb,
lib/google/cloud/bigquery/dataset.rb,
lib/google/cloud/bigquery/project.rb,
lib/google/cloud/bigquery/service.rb,
lib/google/cloud/bigquery/version.rb,
lib/google/cloud/bigquery/copy_job.rb,
lib/google/cloud/bigquery/external.rb,
lib/google/cloud/bigquery/job/list.rb,
lib/google/cloud/bigquery/load_job.rb,
lib/google/cloud/bigquery/query_job.rb,
lib/google/cloud/bigquery/model/list.rb,
lib/google/cloud/bigquery/table/list.rb,
lib/google/cloud/bigquery/credentials.rb,
lib/google/cloud/bigquery/extract_job.rb,
lib/google/cloud/bigquery/dataset/list.rb,
lib/google/cloud/bigquery/project/list.rb,
lib/google/cloud/bigquery/schema/field.rb,
lib/google/cloud/bigquery/standard_sql.rb,
lib/google/cloud/bigquery/dataset/access.rb,
lib/google/cloud/bigquery/insert_response.rb,
lib/google/cloud/bigquery/table/async_inserter.rb,
lib/google/cloud/bigquery/encryption_configuration.rb

Overview

Google Cloud BigQuery

Google BigQuery enables super-fast, SQL-like queries against massive datasets, using the processing power of Google's infrastructure.

See BigQuery Overview.

Defined Under Namespace

Modules: External, StandardSql Classes: CopyJob, Credentials, Data, Dataset, EncryptionConfiguration, ExtractJob, InsertResponse, Job, LoadJob, Model, Project, QueryJob, Schema, Table, Time

Constant Summary collapse

VERSION =
"1.14.1".freeze

Class Method Summary collapse

Class Method Details

.configure {|Google::Cloud.configure.bigquery| ... } ⇒ Google::Cloud::Config

Configure the Google Cloud BigQuery library.

The following BigQuery configuration parameters are supported:

  • project_id - (String) Identifier for a BigQuery project. (The parameter project is considered deprecated, but may also be 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. (See Credentials) (The parameter keyfile is considered deprecated, but may also be used.)
  • endpoint - (String) Override of the endpoint host name, or nil to use the default endpoint.
  • scope - (String, Array) The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access.
  • retries - (Integer) Number of times to retry requests on server error.
  • timeout - (Integer) Default timeout to use in requests.

Yields:

Returns:

  • (Google::Cloud::Config)

    The configuration object the Google::Cloud::Bigquery library uses.



114
115
116
117
118
# File 'lib/google/cloud/bigquery.rb', line 114

def self.configure
  yield Google::Cloud.configure.bigquery if block_given?

  Google::Cloud.configure.bigquery
end

.new(project_id: nil, credentials: nil, scope: nil, retries: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil) ⇒ Google::Cloud::Bigquery::Project

Creates a new Project instance connected to the BigQuery service. Each call creates a new connection.

For more information on connecting to Google Cloud see the Authentication Guide.

Examples:

require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"
table = dataset.table "my_table"

Parameters:

  • 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. (See Credentials)

  • scope (String, Array<String>)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See # Using OAuth 2.0 to Access Google # APIs.

    The default scope is:

    • https://www.googleapis.com/auth/bigquery
  • retries (Integer)

    Number of times to retry requests on server error. The default value is 5. Optional.

  • timeout (Integer)

    Default timeout to use in requests. Optional.

  • endpoint (String)

    Override of the endpoint host name. Optional. If the param is nil, uses the default endpoint.

  • project (String)

    Alias for the project_id argument. Deprecated.

  • keyfile (String)

    Alias for the credentials argument. Deprecated.

Returns:

Raises:

  • (ArgumentError)


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/google/cloud/bigquery.rb', line 69

def self.new project_id: nil, credentials: nil, scope: nil, retries: nil,
             timeout: nil, endpoint: nil, project: nil, keyfile: nil
  scope       ||= configure.scope
  retries     ||= configure.retries
  timeout     ||= configure.timeout
  endpoint    ||= configure.endpoint
  credentials ||= (keyfile || default_credentials(scope: scope))

  unless credentials.is_a? Google::Auth::Credentials
    credentials = Bigquery::Credentials.new credentials, scope: scope
  end

  project_id = resolve_project_id(project_id || project, credentials)
  raise ArgumentError, "project_id is missing" if project_id.empty?

  Bigquery::Project.new(
    Bigquery::Service.new(
      project_id, credentials,
      retries: retries, timeout: timeout, host: endpoint
    )
  )
end