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/condition.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/remote_function_options.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: DatasetView, External, OperationType, StandardSql, UpdateMode Classes: Argument, Condition, CopyJob, Credentials, Data, Dataset, EncryptionConfiguration, ExtractJob, InsertResponse, Job, LoadJob, Model, Policy, Project, QueryJob, RemoteFunctionOptions, Routine, Schema, Table, Time

Constant Summary collapse

VERSION =
"1.62.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 - (Google::Auth::Credentials) A Google::Auth::Credentials object. (See Credentials) @note Warning: Passing a String to a keyfile path or a Hash of credentials is deprecated. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data.
  • 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.


132
133
134
135
136
# File 'lib/google/cloud/bigquery.rb', line 132

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"

Raises:

  • (ArgumentError)


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/google/cloud/bigquery.rb', line 86

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