Google BigQuery 擴充功能

您正在查看 Apigee Edge 說明文件。
查看 Apigee X 說明文件
資訊

1.2.1 版

在 BigQuery 資料表中插入資料列。列出資料表中的資料列。

必要條件

本文提供設定和使用這個擴充功能的參考資料。透過 Extension callout 政策透過 API Proxy 使用擴充功能前,您必須:

  1. 確認您已為帳戶啟用 BigQuery API。

  2. 請務必先建立 BigQuery 資料集資料表 (含結構定義),再嘗試插入資料列。

  3. 使用 GCP 控制台產生服務帳戶的金鑰

  4. 透過設定參考資料新增及設定擴充功能時,使用產生的金鑰 JSON 檔案內容。

關於 Google BigQuery

Google BigQuery 是可擴充的無伺服器企業資料倉儲,運用 Google 基礎架構的處理能力,以飛快的速度執行 SQL 查詢。由於 Google 沒有基礎架構需要管理,因此您可以專心分析資料,使用熟悉的 SQL,找出有意義的深入分析結果。

如需實作簡介,請嘗試其中一個 Google BigQuery 快速入門導覽課程

動作

insert

直接將一組記錄以資料集的形式插入 BigQuery,並插入資料列和資料集/資料表 ID。

語法

<Action>insert</Action>
<Input><![CDATA[{
  "dataset" : dataset-to-insert,
  "table" : table-to-receive-data,
  "rows" : array-of-rows-to-insert
}]]></Input>

範例

<Action>insert</Action>
<Input><![CDATA[{
  "dataset" : "TestData",
  "table" : "TestTable",
  "rows" : [
    {"technology":"CRISPR","inventorFirstName":"Jennifer","inventorLastName":"Doudna"},
    {"technology":"World Wide Web","inventorFirstName":"Tim","inventorLastName":"Berners-Lee"}
    {"technology":"Alternating current","inventorFirstName":"Nikola","inventorLastName":"Tesla"}
  ]
}]]></Input>

要求參數

參數 說明 類型 預設 需要
資料集 要插入 BigQuery 的資料集 ID。 字串 無。 可以。
資料列 要插入資料表的列數。 陣列 無。 可以。
資料表 要接收資料的資料表名稱。 字串 無。 可以。

回應

無。

listRows

列出由資料表 ID 和資料集 ID 指定的資料表中的資料列。

語法

<Action>listRows</Action>
<Input><![CDATA[{
  "dataset" : ID-of-dataset-to-examine,
  "limit" : maximum-rows-to-list,
  "startIndex" : row-index-at-which-to-start-list
  "table" : ID-of-table-to-examine
}]]></Input>

範例

<Action>listRows</Action>
<Input><![CDATA[{
  "dataset" : "TestData",
  "limit" : 2,
  "startIndex" : 1,
  "table" : "TestTable"
}]]></Input>

要求參數

參數 說明 類型 預設 需要
資料集 要列出其中資料列的資料集 ID。 字串 無。 可以。
限制 要列出的列數上限。 整數 無。 不會。
startIndex 清單起始處的資料列索引。 整數 無。 不會。
資料表 要列出其中資料列的資料表 ID。 字串 無。 可以。

回應

rows 陣列。

{
  "rows": [
    {"technology":"World Wide Web","inventorFirstName":"Tim","inventorLastName":"Berners-Lee"}
    {"technology":"Alternating current","inventorFirstName":"Nikola","inventorLastName":"Tesla"}
  ]
}
參數 說明 類型 預設 需要
資料列 要求傳回的資料列陣列。 陣列 無。 可以。

設定參考資料

如果您要設定及部署這個擴充功能,以便用於 API Proxy,請按照下列指示操作。如需使用 Apigee 控制台設定擴充功能的相關步驟,請參閱「新增及設定擴充功能」。

常見擴充功能屬性

每個擴充功能都有下列屬性。

屬性 說明 預設 必要
name 您要為這項擴充功能設定的名稱。 相容
packageName Apigee Edge 指定的擴充功能套件名稱。 相容
version 擴充功能的擴充功能套件版本號碼。 相容
configuration 您要新增的擴充功能專屬的設定值。請參閱「這個擴充功能套件的屬性」一文 相容

這個擴充功能套件的屬性

指定這個擴充功能的下列設定屬性值。

屬性 說明 預設 需要
projectId 含有資料的 GCP 專案 ID。 無。 可以。
憑證 在 Apigee Edge 控制台中輸入時,服務帳戶金鑰檔案的內容即為。透過 Management API 傳送時,是由服務帳戶金鑰檔案產生的 Base64 編碼值。 無。 可以。