[英]How to store the results from a stored procedure into a temp table or a view in BigQuery?
I have a stored procedure in BQ where the results i want to be stored inside a temp table for further analysis.我在 BQ 中有一个存储过程,我想将结果存储在临时表中以供进一步分析。
How can we do it inside BQ?我们如何在 BQ 中执行?
Temporary tables are session based, ie they only live within a Begin
and an End
block.临时表基于 session,即它们仅存在于
Begin
和End
块中。 Temp tables can be created inside a Stored procedure but are not accessible outside it.临时表可以在存储过程内部创建,但不能在存储过程外部访问。
You can create a temp table using following syntax - Reference您可以使用以下语法创建临时表 - 参考
CREATE TEMP TABLE <ANALYTICS_TABLE> ...
You can use this Temp Table throughout the procedure to perform Data transformations, cleansing etc.您可以在整个过程中使用此临时表来执行数据转换、清理等。
Temp tables are recommended when you have multiple transformations which refer to a common Transformation, which can be saved as a Temp table for intermediate use.当您有多个引用公共转换的转换时,建议使用临时表,可以将其保存为临时表以供中间使用。
Consider Transformation 1 & Transformation 2 to be heavy operations.
将转换 1 和转换 2 视为繁重的操作。 Transformation 3 & 4 both utilise common Transformation 2, Hence to avoid re-computations of Transformation 2, it's better to save it as a
temp table
to be referred multiple times. Transformation 3 & 4 都使用了 common Transformation 2,因此为了避免 Transformation 2 重新计算,最好将其保存为
temp table
以供多次引用。
But in order to save the results, you must save them to a Permanent Table in order to persist it.但是为了保存结果,您必须将它们保存到一个永久表中才能持久保存。 Permanent table then can be queries in other procedures and you can Create Views on top of them.
然后永久表可以在其他过程中查询,您可以在它们之上创建视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.