Google BigQuery 擴充功能

您正在查看 Apigee Edge 說明文件。
前往 Apigee X 說明文件
info

2.0.0 版

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

必要條件

本內容提供設定和使用此擴充功能的參考資訊。使用 ExtensionCallout 政策從 API proxy 使用擴充功能前,您必須:

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

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

  3. 使用 GCP 主控台為服務帳戶產生金鑰

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

關於 Google BigQuery

Google BigQuery 是具備高擴充性的無伺服器企業資料倉儲,能夠利用 Google 基礎架構的強大處理能力,以超高效率執行 SQL 查詢。您不需要管理 BigQuery 的基礎架構,因此可以專注於透過慣用的 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 代理程式中使用,請使用下列說明。如要瞭解如何使用 Apigee 控制台設定擴充功能,請參閱「新增及設定擴充功能」。

常見的擴充功能屬性

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

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

這個擴充功能套件的屬性

請為下列專屬於此擴充功能的設定屬性指定值。

屬性 說明 預設 必填
專案 ID 資料所在 GCP 專案的 ID。 無。 是。
憑證 輸入 Apigee Edge 主控台時,這是服務帳戶金鑰檔案的內容。透過管理 API 傳送時,這會是從服務帳戶金鑰檔案產生的 base64 編碼值。 無。 是。