获取大查询脚本以输出表 [英] Get a Big Query script to output a table

查看:45
本文介绍了获取大查询脚本以输出表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Big Query的新脚本功能来声明一个变量,然后在标准SQL查询中使用该变量.

I am using the new scripting feature of Big Query to declare a variable and then am using that variable in a standard SQL query.

查询的结构是:

DECLARE {变量名} {数据类型};

DECLARE {name of variable} {data type};

SET {变量名} = {}'

SET {name of variable} = {Value}'

(然后使用上述变量进行SQL查询)

(A SQL QUERY THEN FOLLOWS USING THE ABOVE VARIABLE)

我知道现在这已不再是一个典型的查询脚本,因此,当我运行它时,它将作为一系列可执行任务运行.但是,无论如何,脚本中是否有明确声明我只想输出SQL查询的结果表,而不是声明变量和SQL查询的结果的表?

I understand that this is now a script a no longer a typical query, and thus when I run it, it runs as a sequence of executable tasks. But is there anyway in the script to explicitly state that I only want to output the resulting table of the SQL query as opposed to both the result of declaring the variable and SQL query?

什么是BQ输出

推荐答案

取决于您如何捕获"输出,如果要从Python/Java/CLI发送查询,则脚本中的最后一个SELECT语句是您通过API收到的唯一输出.

Depending on how you "capture" the output, if you are sending a query from Python/Java/CLI, then the last SELECT statement in script is the only output that you receive with the API.

还请注意,您看到的每个输出"都有一个费用/字节计费,这是它们始终可见的另一个原因.

Please also note that each "output" that you see come with a cost/bytes-billed, which is another reason for them to be visible at all time.

更新:如果您需要根据表的意图将SELECT语句的输出捕获到表中,则可以使用:

Update: If you need to capture the output of SELECT statement to a table, depending on your intention, you may use:

CREATE OR REPLACE TABLE <your_destination_table> AS SELECT ...

INSERT INTO TABLE <your_destination_table> SELECT ...

这篇关于获取大查询脚本以输出表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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