lib/google/cloud/bigquery/dataset.rb in google-cloud-bigquery-0.30.0 vs lib/google/cloud/bigquery/dataset.rb in google-cloud-bigquery-1.0.0
- old
+ new
@@ -1,12 +1,12 @@
-# Copyright 2015 Google Inc. All rights reserved.
+# Copyright 2015 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
-# http://www.apache.org/licenses/LICENSE-2.0
+# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
@@ -666,12 +666,12 @@
gapi = service.list_tables dataset_id, options
Table::List.from_gapi gapi, service, dataset_id, max
end
##
- # Queries data using the [asynchronous
- # method](https://cloud.google.com/bigquery/querying-data).
+ # Queries data by creating a [query
+ # job](https://cloud.google.com/bigquery/docs/query-overview#query_jobs).
#
# Sets the current dataset as the default dataset in the query. Useful
# for using unqualified table names.
#
# When using standard SQL and passing arguments using `params`, Ruby
@@ -906,14 +906,14 @@
gapi = service.query_job query, options
Job.from_gapi gapi, service
end
##
- # Queries data using a synchronous method that blocks for a response. In
- # this method, a {QueryJob} is created and its results are saved
- # to a temporary table, then read from the table. Timeouts and transient
- # errors are generally handled as needed to complete the query.
+ # Queries data and waits for the results. In this method, a {QueryJob}
+ # is created and its results are saved to a temporary table, then read
+ # from the table. Timeouts and transient errors are generally handled
+ # as needed to complete the query.
#
# Sets the current dataset as the default dataset in the query. Useful
# for using unqualified table names.
#
# When using standard SQL and passing arguments using `params`, Ruby
@@ -1144,13 +1144,13 @@
# path or a google-cloud-storage `File` instance. Or, you can upload a
# file directly. See [Loading Data with a POST
# Request](https://cloud.google.com/bigquery/loading-data-post-request#multipart).
#
# @param [String] table_id The destination table to load the data into.
- # @param [File, Google::Cloud::Storage::File, String] file A file or the
- # URI of a Google Cloud Storage file containing data to load into the
- # table.
+ # @param [File, Google::Cloud::Storage::File, String, URI] file A file
+ # or the URI of a Google Cloud Storage file containing data to load
+ # into the table.
# @param [String] format The exported file format. The default value is
# `csv`.
#
# The following values are supported:
#
@@ -1376,13 +1376,13 @@
# path or a google-cloud-storage `File` instance. Or, you can upload a
# file directly. See [Loading Data with a POST
# Request](https://cloud.google.com/bigquery/loading-data-post-request#multipart).
#
# @param [String] table_id The destination table to load the data into.
- # @param [File, Google::Cloud::Storage::File, String] file A file or the
- # URI of a Google Cloud Storage file containing data to load into the
- # table.
+ # @param [File, Google::Cloud::Storage::File, String, URI] file A file
+ # or the URI of a Google Cloud Storage file containing data to load
+ # into the table.
# @param [String] format The exported file format. The default value is
# `csv`.
#
# The following values are supported:
#
@@ -1946,10 +1946,11 @@
end
def load_storage table_id, url, options = {}
# Convert to storage URL
url = url.to_gs_url if url.respond_to? :to_gs_url
+ url = url.to_s if url.is_a? URI
gapi = service.load_table_gs_url dataset_id, table_id, url, options
Job.from_gapi gapi, service
end
@@ -1962,10 +1963,12 @@
end
def storage_url? file
file.respond_to?(:to_gs_url) ||
(file.respond_to?(:to_str) &&
- file.to_str.downcase.start_with?("gs://"))
+ file.to_str.downcase.start_with?("gs://")) ||
+ (file.is_a?(URI) &&
+ file.to_s.downcase.start_with?("gs://"))
end
def local_file? file
::File.file? file
rescue