資料庫中的即時試算表

BigQuery 團隊已開發出可將 Google 試算表視為資料庫中資料表的功能。也就是說,您可以在單一查詢中,將 10 億列的 BigQuery 資料表與 100 列對應表合併。

這項功能可讓您設定資料模型、建立臨時資料的資料管道,或將最新數據與最新目標和預測結果進行比較。

範例

舉例來說,您可能想在 Looker 中模擬使用 Google 表單收集到的使用者名稱。

如要在 Looker 中收集及建立資訊模型,請執行下列步驟:

  1. 使用 Google 表單將資料收集到 Google 試算表。每當出現新的提交內容時,系統就會在試算表中新增一列。
  2. 將試算表分享給您用來連線至 Looker 的服務帳戶,或透過連結 (僅限檢視) 授予使用者存取權。
  3. 請確認您的專案已啟用 Drive API 和 Sheets API
  4. 透過 BigQuery 介面建立表格,該介面會從試算表取得內容。
  5. 在 Looker 專案中產生資料模型,將試算表資料表與您可能已收集到的其他使用者資料 (例如使用者所在位置) 彙整。您也可以使用 SQL 將資料庫中的名稱標準化。您可以將資料快取到 BigQuery,避免試算表負荷過重。

以下是產生的 LookML 範例:

explore: names_sheet {
  persist_for: "60 seconds"

  join: names_facts {
    sql_on: ${names_sheet.normalized_name} = ${names_facts.normalized_name} ;;
    sql_where: ${names_facts.city} ;;
    relationship: one_to_one
  }

  view_name: names_sheet {
    derived_table: {
      persist_for: "2 minutes"
      sql:
        SELECT row_number() OVER() as id, name, UPPER(CASE WHEN REGEXP_MATCH(name, r'\,')
          THEN REGEXP_EXTRACT(name, r', (\w+)')
          ELSE REGEXP_EXTRACT(name, r'^(\w+)')
          END
          ) as normalized_name FROM namesheet.names ;;
    }

    dimension: id {
      type: number
    }

    dimension: name {
      order_by_field: id    # keep the rows in the original order
    }

    dimension: normalized_name {
    }

    measure: count {
      type: count
      drill_fields: [id, name, names_facts.city]
    }

    measure: count_from_new_york_city {
      type: count
      filters: [names_facts.city: "New York City"]
    }

    measure: percentage_from_new_york_city {
      type: number
      sql: ${count_from_new_york_city}/${count} ;;
      value_format_name: percent_2
    }

    measure: average_age_median {
      type: average
      sql: ${names_facts.age_median} ;;
      value_format: "0000"
    }
  }
}

您可以使用這個模型,根據資料建立探索,並建立外觀資訊主頁,顯示您從 Google 表單收集並輸入 Google 試算表的所有使用者名稱,以及每位使用者的其他資訊。