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/policy.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/routine.rb,
lib/google/cloud/bigquery/service.rb,
lib/google/cloud/bigquery/version.rb,
lib/google/cloud/bigquery/argument.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/dataset/tag.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/routine/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/external/csv_source.rb,
lib/google/cloud/bigquery/external/avro_source.rb,
lib/google/cloud/bigquery/external/data_source.rb,
lib/google/cloud/bigquery/external/json_source.rb,
lib/google/cloud/bigquery/table/async_inserter.rb,
lib/google/cloud/bigquery/external/sheets_source.rb,
lib/google/cloud/bigquery/external/parquet_source.rb,
lib/google/cloud/bigquery/encryption_configuration.rb,
lib/google/cloud/bigquery/external/bigtable_source.rb,
lib/google/cloud/bigquery/external/bigtable_source/column.rb,
lib/google/cloud/bigquery/external/bigtable_source/column_family.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, OperationType, StandardSql Classes: Argument, CopyJob, Credentials, Data, Dataset, EncryptionConfiguration, ExtractJob, InsertResponse, Job, LoadJob, Model, Policy, Project, QueryJob, Routine, Schema, Table, Time

Constant Summary collapse

VERSION =
"1.50.0".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.



116
117
118
119
120
# File 'lib/google/cloud/bigquery.rb', line 116

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, universe_domain: 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) (defaults to: nil)

    Identifier for a BigQuery project. If not present, the default project for the credentials is used.

  • credentials (String, Hash, Google::Auth::Credentials) (defaults to: nil)

    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>) (defaults to: nil)

    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) (defaults to: nil)

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

  • timeout (Integer) (defaults to: nil)

    Default timeout to use in requests. Optional.

  • endpoint (String) (defaults to: nil)

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

  • project (String) (defaults to: nil)

    Alias for the project_id argument. Deprecated.

  • keyfile (String) (defaults to: nil)

    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
91
92
# 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, universe_domain: nil
  scope       ||= configure.scope
  retries     ||= configure.retries
  timeout     ||= configure.timeout
  endpoint    ||= configure.endpoint
  credentials ||= keyfile || default_credentials(scope: scope)
  universe_domain ||= configure.universe_domain

  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,
      quota_project: configure.quota_project, universe_domain: universe_domain
    )
  )
end