lib/google/cloud/bigquery/project.rb in google-cloud-bigquery-1.16.0 vs lib/google/cloud/bigquery/project.rb in google-cloud-bigquery-1.17.0
- old
+ new
@@ -89,12 +89,11 @@
# connect to BigQuery. (See also {#project_id}.)
#
# @return [String] The service account email address.
#
def service_account_email
- @service_account_email ||= \
- service.project_service_account.email
+ @service_account_email ||= service.project_service_account.email
end
##
# Copies the data from the source table to the destination table using
# an asynchronous method. In this method, a {CopyJob} is immediately
@@ -180,15 +179,13 @@
# copy_job.wait_until_done!
# copy_job.done? #=> true
#
# @!group Data
#
- def copy_job source_table, destination_table, create: nil, write: nil,
- job_id: nil, prefix: nil, labels: nil
+ def copy_job source_table, destination_table, create: nil, write: nil, job_id: nil, prefix: nil, labels: nil
ensure_service!
- options = { create: create, write: write, labels: labels,
- job_id: job_id, prefix: prefix }
+ options = { create: create, write: write, labels: labels, job_id: job_id, prefix: prefix }
updater = CopyJob::Updater.from_options(
service,
Service.get_table_ref(source_table, default_ref: project_ref),
Service.get_table_ref(destination_table, default_ref: project_ref),
@@ -259,17 +256,12 @@
# bigquery.copy "bigquery-public-data.samples.shakespeare",
# destination_table
#
# @!group Data
#
- def copy source_table, destination_table, create: nil, write: nil,
- &block
- job = copy_job source_table,
- destination_table,
- create: create,
- write: write,
- &block
+ def copy source_table, destination_table, create: nil, write: nil, &block
+ job = copy_job source_table, destination_table, create: create, write: write, &block
job.wait_until_done!
ensure_job_succeeded! job
true
end
@@ -536,27 +528,20 @@
# job.data.each do |row|
# puts row[:name]
# end
# end
#
- def query_job query, params: nil, external: nil,
- priority: "INTERACTIVE", cache: true, table: nil,
- create: nil, write: nil, dryrun: nil, dataset: nil,
- project: nil, standard_sql: nil, legacy_sql: nil,
- large_results: nil, flatten: nil,
- maximum_billing_tier: nil, maximum_bytes_billed: nil,
+ def query_job query, params: nil, external: nil, priority: "INTERACTIVE", cache: true, table: nil, create: nil,
+ write: nil, dryrun: nil, dataset: nil, project: nil, standard_sql: nil, legacy_sql: nil,
+ large_results: nil, flatten: nil, maximum_billing_tier: nil, maximum_bytes_billed: nil,
job_id: nil, prefix: nil, labels: nil, udfs: nil
ensure_service!
- options = { priority: priority, cache: cache, table: table,
- create: create, write: write, dryrun: dryrun,
- large_results: large_results, flatten: flatten,
- dataset: dataset, project: (project || self.project),
- legacy_sql: legacy_sql, standard_sql: standard_sql,
- maximum_billing_tier: maximum_billing_tier,
- maximum_bytes_billed: maximum_bytes_billed,
- external: external, job_id: job_id, prefix: prefix,
- labels: labels, udfs: udfs, params: params }
+ options = { priority: priority, cache: cache, table: table, create: create, write: write, dryrun: dryrun,
+ large_results: large_results, flatten: flatten, dataset: dataset,
+ project: (project || self.project), legacy_sql: legacy_sql, standard_sql: standard_sql,
+ maximum_billing_tier: maximum_billing_tier, maximum_bytes_billed: maximum_bytes_billed,
+ external: external, job_id: job_id, prefix: prefix, labels: labels, udfs: udfs, params: params }
updater = QueryJob::Updater.from_options service, query, options
yield updater if block_given?
@@ -757,17 +742,14 @@
#
# data.each do |row|
# puts row[:name]
# end
#
- def query query, params: nil, external: nil, max: nil, cache: true,
- dataset: nil, project: nil, standard_sql: nil,
- legacy_sql: nil, &block
- job = query_job query, params: params, external: external,
- cache: cache, dataset: dataset,
- project: project, standard_sql: standard_sql,
- legacy_sql: legacy_sql, &block
+ def query query, params: nil, external: nil, max: nil, cache: true, dataset: nil, project: nil,
+ standard_sql: nil, legacy_sql: nil, &block
+ job = query_job query, params: params, external: external, cache: cache, dataset: dataset, project: project,
+ standard_sql: standard_sql, legacy_sql: legacy_sql, &block
job.wait_until_done!
if job.failed?
begin
# raise to activate ruby exception cause handling
@@ -859,13 +841,11 @@
#
# dataset = bigquery.dataset "my_dataset", skip_lookup: true
#
def dataset dataset_id, skip_lookup: nil
ensure_service!
- if skip_lookup
- return Dataset.new_reference project, dataset_id, service
- end
+ return Dataset.new_reference project, dataset_id, service if skip_lookup
gapi = service.get_dataset dataset_id
Dataset.from_gapi gapi, service
rescue Google::Cloud::NotFoundError
nil
end
@@ -1090,14 +1070,12 @@
# end
#
def jobs all: nil, token: nil, max: nil, filter: nil,
min_created_at: nil, max_created_at: nil
ensure_service!
- options = {
- all: all, token: token, max: max, filter: filter,
- min_created_at: min_created_at, max_created_at: max_created_at
- }
+ options = { all: all, token: token, max: max, filter: filter, min_created_at: min_created_at,
+ max_created_at: max_created_at }
gapi = service.list_jobs options
Job::List.from_gapi gapi, service, options
end
##
@@ -1384,21 +1362,18 @@
# extract_job.wait_until_done!
# extract_job.done? #=> true
#
# @!group Data
#
- def extract_job table, extract_url, format: nil, compression: nil,
- delimiter: nil, header: nil, job_id: nil, prefix: nil,
- labels: nil
+ def extract_job table, extract_url, format: nil, compression: nil, delimiter: nil, header: nil, job_id: nil,
+ prefix: nil, labels: nil
ensure_service!
- options = { format: format, compression: compression,
- delimiter: delimiter, header: header, job_id: job_id,
+ options = { format: format, compression: compression, delimiter: delimiter, header: header, job_id: job_id,
prefix: prefix, labels: labels }
table_ref = Service.get_table_ref table, default_ref: project_ref
- updater = ExtractJob::Updater.from_options service, table_ref,
- extract_url, options
+ updater = ExtractJob::Updater.from_options service, table_ref, extract_url, options
yield updater if block_given?
job_gapi = updater.to_gapi
gapi = service.extract_table job_gapi
@@ -1458,14 +1433,12 @@
# bigquery.extract "bigquery-public-data.samples.shakespeare",
# "gs://my-bucket/shakespeare.csv"
#
# @!group Data
#
- def extract table, extract_url, format: nil, compression: nil,
- delimiter: nil, header: nil, &block
- job = extract_job table,
- extract_url,
+ def extract table, extract_url, format: nil, compression: nil, delimiter: nil, header: nil, &block
+ job = extract_job table, extract_url,
format: format,
compression: compression,
delimiter: delimiter,
header: header,
&block
@@ -1485,12 +1458,10 @@
new(project_service).tap do |p|
p.instance_variable_set :@name, gapi.friendly_name
# TODO: remove `Integer` and set normally after migrating to Gax or
# to google-api-client 0.10 (See google/google-api-ruby-client#439)
- if gapi.numeric_id
- p.instance_variable_set :@numeric_id, Integer(gapi.numeric_id)
- end
+ p.instance_variable_set :@numeric_id, Integer(gapi.numeric_id) if gapi.numeric_id
end
end
protected