Skip to content

Commit 943b8ba

Browse files
author
remi Taylor
committed
BigQuery sample: create client
1 parent 2db310c commit 943b8ba

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

bigquery/datasets.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
def create_bigquery_client project_id:
16+
# [START create_bigquery_client]
17+
require "google/cloud"
18+
19+
gcloud = Google::Cloud.new project_id
20+
bigquery = gcloud.bigquery
21+
# [END create_bigquery_client]
22+
end
23+
1524
def create_dataset project_id:, dataset_id:
1625
# [START create_dataset]
1726
# project_id = "Your Google Cloud project ID"

bigquery/spec/bigquery_sample_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ def capture &block
8888
end
8989
attr_reader :captured_output
9090

91+
example "create BigQuery client" do
92+
client = create_bigquery_client project_id: @project_id
93+
94+
expect(client).to be_a Google::Cloud::Bigquery::Project
95+
end
96+
9197
describe "Managing Datasets" do
9298
example "create dataset" do
9399
delete_test_dataset!

0 commit comments

Comments
 (0)