App脚本BigQuery标准SQL插入或更新语句 [英] App Script BigQuery Standard SQL insert or update statement

查看:150
本文介绍了App脚本BigQuery标准SQL插入或更新语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在Google App脚本中使用BigQuery标准SQL方言.取消选中"SQLVersion:使用旧版SQL"时,以下在BigQuery中起作用;

I'm looking to use the BigQuery Standard SQL dialect from within Google App Script. The following works in BigQuery when "SQLVersion : Use Legacy SQL" is unchecked;

INSERT INTO MyDataSet.MyFooBarTable (Id, Foo, Date) VALUES (1, 'bar', current_Date)

我可以使用Jobs高兴地从Google Script询问BigQuery并通过Append作业执行插入(有效地提供相同的插入结果).可以在脚本中使用标准SQL逻辑来执行插入吗?

I can happily interrogate BigQuery from Google Script using Jobs and perform inserts via an Append job (effectively giving the same insert result). Is it possible to use the Standard SQL logic within script to perform the insert?

我尝试将#standardSQL添加到语句中而没有任何高兴.

I have tried adding #standardSQL to the statement with no joy.

推荐答案

您需要将useLegacySql标志/参数设置为false,以表明您要使用标准SQL,例如:

You need to set the useLegacySql flag/parameter to false, to indicate that you want to use standard SQL, like so:

var job = {
configuration: {
  query: {
    query: 'INSERT INTO MyDataSet.MyFooBarTable (Id, Foo, Date) VALUES (1, \'bar\', current_Date);',
    useLegacySql: false
    }

}};

我在自己的GAS中对此进行了测试,并按预期工作.

I tested this in my own GAS, and worked as expected.

这篇关于App脚本BigQuery标准SQL插入或更新语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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