檢視區塊代表 Looker 中的資料表,無論該資料表是資料庫原生資料表,還是使用 Looker 的衍生資料表功能建立,檢視畫面通常會在檢視畫面檔案中宣告,每個檔案包含一個檢視畫面。
每個檢視區塊內都有欄位定義,通常會對應至基礎資料表中的資料欄,或是 Looker 中的計算。這些欄位說明請參閱欄位參考資料、維度類型參考資料和測量指標類型參考資料。
此外,還有許多檢視層級設定,本頁面會說明這些設定。
應用實例
將滑鼠游標懸停在參數名稱上,即可查看簡短說明。按一下參數即可前往參照頁面。 如果參數可設為多個特定選項之一,預設值會列在最前面。
## STRUCTURAL PARAMETERS include:"filename_or_pattern" ## Possibly more include declarations test: test_name{ explore_source: explore_name { # Desired subparameters (described ontestpage) } assert: assert_statement { expression:Looker expression ;; } # Possibly more assert declarations } ## Possibly more test declarations view: view_name { extension: required extends: [view_name, view_name, ...] (dimension | dimension_group | measure | filter):field_name{ # Desired field parameters (described on Field Parameters page) } # Possibly more field declarations set: set_name{ fields:[field_or_set, field_or_set, ...] } # Possibly more set declarations drill_fields: [field_or_set, field_or_set, ...] # DISPLAY PARAMETERS label: "desired label" fields_hidden_by_default: yes | no # FILTER PARAMETERS suggestions: yes | no # QUERY PARAMETERS autogenerate_primary_keys: yes | no required_access_grants: [access_grant_name, access_grant_name, ...] sql_table_name: table_name ;; # DERIVED TABLE PARAMETERS derived_table: { cluster_keys: ["column_name", "column_name", ...] create_process: { sql_step:SQL query ;; } datagroup_trigger: datagroup_name distribution: "column_name" distribution_style: all | even explore_source: explore_name { # Desired subparameters (described onexplore_sourcepage) } increment_key: "column_name" increment_offset: N indexes: ["column_name", "column_name", ...] interval_trigger: "N (seconds | minutes | hours)" materialized_view: yes | no partition_keys: ["column_name", "column_name", ...] persist_for: "N (seconds | minutes | hours)" publish_as_db_view: yes | no sortkeys: ["column_name","column_name", ...] sql: SQL query ;; sql_create: { SQL query ;; } sql_trigger_value: SQL query ;; table_compression: GZIP | SNAPPY table_format: PARQUET | ORC | AVRO | JSON | TEXTFILE } } ## REFINEMENT PARAMETERS view: +view_name { final: yes }
參數定義
| 參數名稱 | 說明 |
|---|---|
| 結構參數 | |
drill_fields (適用於觀看) |
指定深入查看檢視畫面中定義的指標時,顯示的預設欄位清單 |
extends (適用於觀看) |
指定這個檢視區塊要擴充的檢視區塊 |
extension (適用於觀看) |
指定檢視畫面需要擴充功能,且本身無法向使用者公開 |
include |
將檔案新增至檢視畫面 |
test |
建立資料測試,驗證模型的邏輯。專案設定包含「需要資料測試」選項。為專案啟用這項功能後,專案開發人員必須先執行資料測試,才能將變更部署至正式環境。這個參數包含 explore_source 和 assert 子參數。 |
set |
定義一組維度和測量指標,供其他參數使用 |
view |
建立檢視畫面 |
| 顯示參數 | |
label (適用於觀看) |
指定檢視區塊名稱在欄位挑選器中的顯示方式 |
fields_hidden_by_default |
新增 21.12
設為 yes 時,系統預設會隱藏檢視畫面中的所有欄位。在欄位上使用 hidden: no 參數,即可顯示該欄位。 |
| 篩選參數 | |
suggestions (適用於觀看) |
啟用或停用這個檢視中所有維度的建議 |
| 查詢參數 | |
autogenerate_primary_keys (適用於觀看) |
啟用或停用自動產生主鍵的功能 |
required_access_grants (適用於觀看) |
限制只有使用者屬性值符合存取權授予條件的使用者,才能存取資料檢視 |
sql_table_name (適用於觀看) |
變更檢視表所依據的 SQL 資料表 |
| 衍生資料表參數 | |
cluster_keys |
指定 PDT 要依據 BigQuery 中的一或多個欄位叢集化
在 Snowflake 上新增 cluster_keys 的支援 |
create_process |
指定在需要自訂 DDL 指令的資料庫方言上建立 PDT 的步驟順序。這個參數含有子參數 sql_step。
|
datagroup_trigger |
指定用於 PDT 重建政策的資料群組 |
derived_table |
以衍生資料表為基礎建立檢視區塊 |
distribution |
設定在 Redshift 或 Aster 中建構的 PDT 分布鍵 |
distribution_style |
設定在 Redshift 中建構的 PDT 分布樣式 |
explore_source |
根據探索定義原生衍生資料表 |
increment_key |
已在 21.4 版中新增
將衍生資料表設為增量 PDT。increment_key 會指定時間增量,系統應查詢並將最新資料附加至 PDT。 |
increment_offset |
新增 21.4
與 increment_key 參數搭配使用,適用於增量 PDT。increment_offset 會指定要重建的先前時間間隔數量 (以遞增鍵的精細程度為準),以納入延遲抵達的資料。 |
interval_trigger |
Added 21.20
interval_trigger 會指定永久衍生資料表的重建排程,格式為 "N (seconds | minutes | hours)" |
materialized_view |
已在 21.10 中新增
陳述式 materialized_view: yes 會在資料庫中為衍生資料表建立具體化檢視區塊。 |
indexes |
設定在傳統資料庫 (例如 MySQL、Postgres) 中建構的 PDT 索引,或 Redshift 中的交錯排序鍵 |
partition_keys |
指定要依據 Presto 中的一或多個欄位,或 BigQuery 中的單一日期/時間欄位,將 PDT 分區 |
persist_for (適用於衍生資料表) |
設定 PDT 的最長有效時間,超過這個時間就會重新產生 |
publish_as_db_view |
陳述式 publish_as_db_view: yes 會為 PDT 建立穩定的資料庫檢視區塊,以便在 Looker 外部查詢資料表 |
sortkeys |
設定在 Redshift 中建構的 PDT 排序鍵 |
sql (適用於衍生資料表) |
宣告衍生資料表的 SQL 查詢 |
sql_create |
定義 SQL CREATE 陳述式,在需要自訂 DDL 指令的資料庫方言上建立 PDT |
sql_trigger_value |
指定導致 PDT 重新產生的條件 |
table_compression |
指定要在 Amazon Athena 中用於 PDT 的資料表壓縮 |
table_format |
指定要在 Amazon Athena 中用於 PDT 的資料表格式 |
| 修正參數 | |
view: +view_name |
在現有檢視區塊名稱前面加上加號 (+),即可在現有檢視區塊中新增精細調整。如要瞭解詳情和使用案例,請參閱「LookML 修訂」說明文件頁面。 |
final |
表示目前的精修是檢視畫面允許的最終精修。如要瞭解詳情和使用案例,請參閱「LookML 修訂」說明文件頁面。 |
| 應避免使用的參數 | |
distkey |
已移除 3.26
已替換為 distribution |
view_label |
避免使用 4.4
已替換為 label |