在BigQuery用户界面中使用变量名称创建表 [英] Create table using a variable name in the BigQuery UI

查看:62
本文介绍了在BigQuery用户界面中使用变量名称创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个可以存储为过程的BigQuery脚本,我希望将传递的参数之一用在脚本写出的表名中,例如:

I am trying to write a BigQuery script that I can store as a procedure, I would like one of the arguments I pass to be used in the table name that is written out by the script, for example:

DECLARE id STRING;
SET id = '123';

CREATE OR REPLACE TABLE test.id AS(
SELECT * FROM dataset.table
)

但是,在本示例中,该表是用名称id创建的,而不是"id"变量123的值创建的.有什么方法可以使用BigQuery UI中声明的变量的值动态创建表吗?

However, in this example the table is created with the name id rather than the value of the "id" variable, 123. Is there any way I can dynamically create a table using the value of a declared variable in the BigQuery UI?

推荐答案

到目前为止,我们已经正式宣布 BigQuery脚本文档(仍处于Beta阶段),利用动态参数(变量)作为SQL查询中的值的占位符.但是,根据 BigQuery中的参数化查询文档,查询参数不能用于SQL对象标识符:

So far we have officially announced BigQuery scripting document, which is still in Beta phase, leveraging usage of dynamic parameters (variables) as a placeholders for values in SQL queries . However, according to Parameterized queries in BigQuery documentation, query parameters can't be used for SQL object identifiers:

参数不能用作标识符,列的替代 名称,表名或查询的其他部分.

Parameters cannot be used as substitutes for identifiers, column names, table names, or other parts of the query.

这篇关于在BigQuery用户界面中使用变量名称创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆