用量
explore: explore_name {
view_name: view_name
}
|
階層
view_name |
預設值
名稱與探索名稱相符的檢視區塊
接受
現有檢視畫面的名稱
|
定義
view_name 會決定要定義探索欄位的檢視畫面。如果省略 view_name,Looker 會假設基礎檢視區塊名稱與探索名稱相同。通常 view_name 只用於從同一個資料檢視建立多個探索。
範例
根據名為 users 的檢視畫面,在「探索」選單中新增名為「客戶」的選項:
explore: customer {
view_name: users
}
常見挑戰
view_name、from 和 label 經常會混淆,但行為不同
view_name、from 和 label 參數的效果類似,但有所不同。
正在使用 view_name
使用 view_name 從相同檢視區塊建立多個「探索」,並以相同方式參照每個「探索」的欄位:
explore: customer {
view_name: users
}
# Would appear in the Explore menu as 'Customer'
# Fields would appear like 'User Name'
# You would reference fields like ${users.name}
explore: buyer {
view_name: users
}
# Would appear in the Explore menu as 'Buyer'
# Fields would appear like 'Users Name'
# You would reference fields like ${users.name}
使用 view_name: users 時,生成的 SQL 會使用原始資料表名稱,例如:FROM schema.users AS users。
正在使用 from
使用 from 從同一個資料檢視建立多個探索,並為每個探索以不同方式參照欄位:
explore: customer {
from: users
}
# Would appear in the Explore menu as 'Customer'
# Fields would appear like 'Customer Name'
# You would reference fields like ${customer.name}
explore: buyer {
from: users
}
# Would appear in the Explore menu as 'Buyer'
# Fields would appear like 'Buyer Name'
# You would reference fields like ${buyer.name}
使用 from: users 時,生成的 SQL 會別名原始資料表名稱,如下所示:FROM schema.users AS customer。
正在使用 label
如果不需要從同一個檢視區塊建立多個探索,且希望探索的名稱在「探索」選單中以不同方式顯示,請使用 label:
explore: users {
label: "Customer"
}
# Would appear in the Explore menu as 'Customer'
# Fields would appear like 'Users Name'
# You would reference fields like ${users.name}
注意事項
view_name 很少用於重新命名探索
除非您要建立擴充模型,並需要從同一個檢視區塊建立多個探索,否則一般不會使用 view_name 重新命名探索。
建議重新命名基礎檢視區塊,或使用 label 變更「探索」在欄位挑選器中的顯示方式。