{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Google Bigquery インポート連携 CLI","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"google-bigquery-インポート連携-cli","__idx":0},"children":["Google Bigquery インポート連携 CLI"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["お好みに応じて、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://toolbelt.treasuredata.com/"},"children":["TD Toolbelt"]}," を使用してコネクタを利用できます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["CLI 上で TD Toolbelt をセットアップします。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"設定ファイルの作成","__idx":1},"children":["設定ファイルの作成"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ここでは「config.yml」として参照される設定 YAML ファイルを作成します。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"例-configyml","__idx":2},"children":["例 (config.yml)"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"in:\n  type: bigquery\n  project_id: my-project\n  auth_method: json_key\n  json_keyfile:\n    content: |\n      {\n        \"type\": \"service_account\",\n        \"project_id\": \"xxxxxx\",\n        ...\n       }\n  import_type: table\n  dataset: my_dataset\n  table: my_table\n  incremental: true\n  incremental_columns: [id]\n  export_to_gcs: true\n  temp_dataset: temp\n  temp_table: temp_table\n  gcs_bucket: my-bucket\n  gcs_path_prefix: data-connector/result-\nout:\n  type: td\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"gcp-の認証","__idx":3},"children":["GCP の認証"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"json-キー","__idx":4},"children":["JSON キー"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["「auth_method: json_key」を指定し、サービスアカウントキーの JSON コンテンツを「json_keyfile**.**content」に入力します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"auth_method: json_key\njson_keyfile:\n  content: |\n    {\n      \"type\": \"service_account\",\n      \"project_id\": \"xxxxxx\",\n      ...\n     }\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"oauth","__idx":5},"children":["OAuth"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["OAuth 2 アプリケーションで認証されたアカウントを使用する場合は、「auth_method: oauth2」、「client_id」、「client_secret」、「refresh_token」を指定します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"auth_method: oauth2\nclient_id: 000000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\nclient_secret: yyyyyyyyyyyyyyyyyyyyyyyy\nrefresh_token: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"インポートタイプ","__idx":6},"children":["インポートタイプ"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"テーブル読み込み","__idx":7},"children":["テーブル読み込み"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["テーブル読み込みでは、「import_type: table」、「dataset」、「table」を指定します。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"import_type-table--dataset-my_dataset--table-my_table","__idx":8},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["import_type: table"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["dataset: my_dataset"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["table: my_table"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"クエリ読み込み","__idx":9},"children":["クエリ読み込み"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["クエリ読み込みでは、「import_type: query」と「query」を指定します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"import_type: query\nquery: |-\n  SELECT\n    id, first_name, last_name, created_at\n  FROM\n    my_dataset.my_table\n  WHERE first_name = \"Treasure\"\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["オプションで「query_option」を指定できます。「use_leagacy_sql」はデフォルトで ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["false"]}," であり、「use_query_cache」はデフォルトで ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["true"]}," です。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"query: SELECT ...\nquery_option:\n  use_legacy_sql: false\n  use_query_cache: true\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"データロケーション","__idx":10},"children":["データロケーション"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["必要に応じて「",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["location"]},"」でロケーションを指定できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"location: asia-northeast1\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"増分読み込み","__idx":11},"children":["増分読み込み"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["有効にするには、「incremental: true」と「incremental_columns」を指定します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"incremental: true\nincremental_columns: [id]\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"大規模データセットのインポート","__idx":12},"children":["大規模データセットのインポート"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["有効にするには、「",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["export_to_gcs: true"]},"」を指定し、「temp_dataset」、「temp_table」、「gcs_bucket」、「gcs_path_prefix」を追加します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"export_to_gcs: true\ntemp_dataset: temp\ntemp_table: temp_table\ngcs_bucket: my-bucket\ngcs_path_prefix: data-connector/result-\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"オプション-プレビュー","__idx":13},"children":["(オプション) プレビュー"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["td ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/tools/cli-and-sdks/td-toolbelt"},"children":["connector:preview"]}," コマンドを実行して、設定ファイルを検証します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:preview config.yml\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"新規コネクタセッションの作成","__idx":14},"children":["新規コネクタセッションの作成"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/tools/cli-and-sdks/td-toolbelt"},"children":["td connector:create"]}," を実行します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下の例では、BigQuery コネクタを使用した日次インポートセッションが作成されます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:create daily_bigquery_import \\\n    \"10 0 * * *\" td_sample_db td_sample_table config.yml\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"データパーティションキー","__idx":15},"children":["データパーティションキー"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["コネクタセッションでは、結果データ内に少なくとも 1 つのタイムスタンプカラムがデータパーティションキーとして使用される必要があり、デフォルトでは最初のタイムスタンプカラムがキーとして選択されます。特定のカラムを明示的に指定する場合は、「",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["--time-column"]},"」オプションを使用します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:create --time-column created_at \\\n    daily_bigquery_import ...\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["結果データにタイムスタンプカラムがない場合は、次のようにフィルタ設定を追加して「",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["time"]},"」カラムを追加します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"in:\n  type: bigquery\n  ...\nfilters:\n- type: add_time\n  from_value:\n    mode: upload_time\n  to_column:\n    name: time\nout:\n  type: td\n"},"children":[]}]},"headings":[{"value":"Google Bigquery インポート連携 CLI","id":"google-bigquery-インポート連携-cli","depth":1},{"value":"設定ファイルの作成","id":"設定ファイルの作成","depth":2},{"value":"例 (config.yml)","id":"例-configyml","depth":3},{"value":"GCP の認証","id":"gcp-の認証","depth":3},{"value":"JSON キー","id":"json-キー","depth":4},{"value":"OAuth","id":"oauth","depth":4},{"value":"インポートタイプ","id":"インポートタイプ","depth":3},{"value":"テーブル読み込み","id":"テーブル読み込み","depth":4},{"value":"import_type: table  dataset: my_dataset  table: my_table","id":"import_type-table--dataset-my_dataset--table-my_table","depth":4},{"value":"クエリ読み込み","id":"クエリ読み込み","depth":4},{"value":"データロケーション","id":"データロケーション","depth":3},{"value":"増分読み込み","id":"増分読み込み","depth":3},{"value":"大規模データセットのインポート","id":"大規模データセットのインポート","depth":3},{"value":"(オプション) プレビュー","id":"オプション-プレビュー","depth":2},{"value":"新規コネクタセッションの作成","id":"新規コネクタセッションの作成","depth":2},{"value":"データパーティションキー","id":"データパーティションキー","depth":3}],"frontmatter":{"seo":{"title":"Google Bigquery インポート連携 CLI"}},"lastModified":"2026-01-09T05:58:30.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/int/google-bigquery-import-integration-cli","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}