[英]BigQuery SQL use description of table for a description of a view
我正在創建我在 BigQuery 中的表的視圖。
如何獲取表的描述並使其成為視圖的描述?
您可以使用INFORMATION_SCHEMA.TABLE_OPTIONS
獲取表描述並將其設置為變量來執行此操作。
工作示例:
-- declare variable where we will later write the table description to
DECLARE view_description STRING;
-- create an example table that has a description
CREATE OR REPLACE TABLE `your_project.your_dataset.test_table_descriptions`
OPTIONS(description="Interesting table description")
AS SELECT 1 test_column;
-- get the table description and write it to the view_description variable
SET view_description = (
SELECT option_value
FROM `your_project.your_dataset.INFORMATION_SCHEMA.TABLE_OPTIONS`
WHERE table_name = 'test_table_descriptions' and option_name = 'description');
-- create the view you want and within options use the view_description variable
CREATE OR REPLACE VIEW `your_project.your_dataset.test_table_descriptions2`
OPTIONS(description=(view_description))
AS SELECT 1 test_column_of_view;
有關INFORMATION_SCHEMA.TABLE_OPTIONS
的更多信息:
https://cloud.google.com/bigquery/docs/information-schema-tables#table_options_view
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.