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

查看:15
本文介绍了在 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天全站免登陆