Google Cloud コンソールを使用して一般公開データセットにクエリを実行する
Google Cloud コンソールを使用して、BigQuery で一般公開データセットを検索してクエリを実行する方法について説明します。
このタスクを Google Cloud コンソールで直接行う際の順を追ったガイダンスについては、「ガイドを表示」をクリックしてください。
始める前に
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that you have the following role or roles on the project: BigQuery Job User, Service Usage Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
IAM に移動 - プロジェクトを選択します。
- [ アクセスを許可] をクリックします。
-
[新しいプリンシパル] フィールドに、ユーザー ID を入力します。 これは通常、Google アカウントのメールアドレスです。
- [ロールを選択] リストでロールを選択します。
- 追加のロールを付与するには、 [別のロールを追加] をクリックして各ロールを追加します。
- [保存] をクリックします。
-
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that you have the following role or roles on the project: BigQuery Job User, Service Usage Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
IAM に移動 - プロジェクトを選択します。
- [ アクセスを許可] をクリックします。
-
[新しいプリンシパル] フィールドに、ユーザー ID を入力します。 これは通常、Google アカウントのメールアドレスです。
- [ロールを選択] リストでロールを選択します。
- 追加のロールを付与するには、 [別のロールを追加] をクリックして各ロールを追加します。
- [保存] をクリックします。
-
-
Verify that billing is enabled for your Google Cloud project.
BigQuery API が有効になっていることを確認します。
新しいプロジェクトを作成している場合は、BigQuery API が自動的に有効になっています。
Google Cloud コンソールで、[BigQuery] ページに移動します。
[エクスプローラ] ペインで、[
+ データを追加 ] をクリックします。[データを追加] ダイアログの [フィルタ条件] ペインで、
一般公開データセットをクリックします。
[マーケットプレイスを検索] 欄またはフィルタを使用して、検索結果を絞り込むことができます。
データセットを選択し、[データセットを表示] をクリックします。
[エクスプローラ] ペインでデータセットが選択され、その詳細が表示されます。
省略可: データセットの横にある
[アクションを表示] をクリックして、その他のオプションを表示します。各データセットにはテーブルがあります。テーブルを表示するには、データセットの横にある
「ノードを切り替える」をクリックします。Google Cloud コンソールで、[BigQuery] ページに移動します。
[
SQL クエリ ] をクリックします。クエリエディタ で、次のクエリをコピーします。SELECT name, SUM(number) AS total FROM `bigquery-public-data.usa_names.usa_1910_2013` GROUP BY name ORDER BY total DESC LIMIT 10;
クエリが有効な場合は、クエリによって処理されるデータの量とともにチェックマークが表示されます。クエリが無効な場合は、感嘆符がエラー メッセージとともに表示されます。
[実行] をクリックします。最も一般的な名前が [クエリ結果] セクションに表示されます。テーブルのヘッダー行には、クエリで選択した列名が含まれています。
省略可: クエリで処理された期間とデータの量を表示するには、
[クエリ結果] セクションの [ジョブ情報] タブをクリックします。- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
- BigQuery サンドボックスについて学習する。
- Google Cloud コンソールでデータセットを作成し、テーブルをクエリする方法を学習する。
- BigQuery に関する最新情報を確認する。
- BigQuery の料金を確認する。
- BigQuery の割り当てと上限について学習する。
このチュートリアルで使用する Google Cloud プロジェクトの課金を有効にしない場合は、BigQuery サンドボックスにデータをアップロードして操作します。BigQuery サンドボックスを使用すると、一部の BigQuery 機能を無料で使用して、BigQuery を試すことができます。
一般公開データセットを開く
BigQuery の一般公開データセットは、デフォルトでGoogle Cloud コンソールに表示されます。
次の例では、一般公開プロジェクト bigquery-public-data
のデータセットにアクセスします。
一般公開データセットに対してクエリを実行する
次の手順では、一般公開データセットの「USA Name」に対してクエリを実行し、1910 年から 2013 年までの米国で最も一般的な名前を調べます。
クリーンアップ
このページで使用したリソースについて、 Google Cloud アカウントに課金されないようにするには、次の手順を実施します。
プロジェクトの削除
BigQuery サンドボックスを使用して一般公開データセットにクエリを実行した場合、プロジェクトに対する課金は有効になりません。
課金をなくす最も簡単な方法は、チュートリアル用に作成したプロジェクトを削除することです。
プロジェクトを削除するには、次の操作を行います。