在 SnowFlake 中,是否有任何选项可以在存储过程中并行执行 sql 语句。我有一个存储过程(如下所示),其中有 35 个 sql 语句,它们按顺序运行。我们计划减少时间,考虑并行执行所有这些。
实现这一目标的最佳方法是什么?(我能想到的就是创建 35 个存储过程并同时从调度程序中调用它们)。想检查一下 SnowFlake 功能是否有更好的方法来实现这一目标?
create or replace procedure SP_TEST()
returns string
language javascript
execute as CALLER
as
$$
try {
var step_num = 0
step_num = 0
step_num++ //--#1
var sql_statement1 = snowflake.createStatement( {sqlText: `INSERT INTO TGT_TBL select * from TBL_A`} )
var sql_statement1_execute = sql_statement1.execute()
step_num++ //--#1
var sql_statement2 = snowflake.createStatement( {sqlText: `INSERT INTO TGT_TBL select * from TBL_B`} )
var sql_statement2_execute = sql_statement2.execute()
return "Completed "+step_num+" steps to …Run Code Online (Sandbox Code Playgroud) 我尝试从 nodeJs 连接到 rds postgresql版本 12,如下所述。它工作完全正常,没有任何问题。
const config = {
user: process.env.PG_DB_USERNAME,
password: process.env.PG_DB_PASSWORD,
database: process.env.PG_DB_NAME,
host: process.env.PG_DB_HOST,
port: process.env.PG_DB_PORT,
}
const pool = new Pool(config)
Run Code Online (Sandbox Code Playgroud)
当我们使用 postgresql 15.2 版 从节点 Js 连接时,我们最终遇到了以下错误。
错误
{"length":181,"name":"error","severity":"FATAL","code":"28000","file":"auth.c","line":"543","routine":"ClientAuthentication","level":"error","timestamp":"2023-06-19T14:13:33.294Z"}
[ERROR] error: no pg_hba.conf entry for host "XXXXX", user "test", database "testdb", no encryption
at Parser.parseErrorMessage (/usr/src/app/node_modules/pg-protocol/dist/parser.js:287:98)
at Parser.handlePacket (/usr/src/app/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/usr/src/app/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.<anonymous> (/usr/src/app/node_modules/pg-protocol/dist/index.js:11:42)
at Socket.emit (node:events:526:28)
at Socket.emit (node:domain:475:12)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead …Run Code Online (Sandbox Code Playgroud) 在我的 Perl 代码中,我最终得到了如下所示的哈希引用。我想从中访问单个元素。我尝试了多种方法,但我无法获取它。
#!/usr/bin/perl
#use strict;
use Data::Dumper;
my %h={'one'=>1,'two'=>2};
print Dumper($h{'one'});
Run Code Online (Sandbox Code Playgroud)
输出
$VAR1 = undef;
Run Code Online (Sandbox Code Playgroud) 我在CPP中有以下代码.
//My code
#include<iostream>
using namespace std;
int main()
{
int a;
int display();
int printfun(display());// Function prototype
printfun(9);//Function calling
return 0;
}
int printfun(int x)
{
cout<<"Welcome inside the function-"<<x<<endl;
}
int display()
{
cout<<"Welcome inside the Display"<<endl;
return 5;
}
Run Code Online (Sandbox Code Playgroud)
编译时会抛出错误"Line8:'printfun'不能用作函数".
但是当我在显示功能中进行printfun调用时,相同的代码工作正常.
#include<iostream>
using namespace std;
int main()
{
int a;
int display();
int printfun(display());// Function prototype
return 0;
}
int printfun(int x)
{
cout<<"Welcome inside the function-"<<x<<endl;
}
int display()
{
printfun(9); // Function call
cout<<"Welcome inside …Run Code Online (Sandbox Code Playgroud) 我有以下输入和预期输出。
Input : [undef,[0,1],2]
Expected Output : [0,1,2]
Run Code Online (Sandbox Code Playgroud)
我写的代码:
use Data::Dumper;
my $input=[undef,[0,1],2];
my @arr=@{$input};
@arr = grep {defined} @arr;
my @arrnew;
foreach my $value (@arr){
if (ref $value eq 'ARRAY') {
push @arrnew,@{$value};
} else {
push @arrnew,$value;
}
}
print Dumper(@arrnew);
Run Code Online (Sandbox Code Playgroud)
问题: 虽然,这给了我正确的输出,但我想知道在 perl 中是否有更简单的方法。
我需要运行一个名为pg.sh的程序.它报告stdout输出日志.如何将stdout以及stderr和stdout保存到2个单独的日志文件中?
我搜索并得到以下代码
(pg.sh 2>&1 1>&3 ) 3>&1 1>&2 | tee output.log) > final.log 2>&1
Run Code Online (Sandbox Code Playgroud)
我理解1和2是指向stdout和stderr的文件描述符.3是另一个指向stdout的文件描述符.
上面的代码工作正常,但我不明白这是如何实现的.有人可以帮我写代码吗?
perl ×2
amazon-rds ×1
bash ×1
c++ ×1
hashref ×1
ksh ×1
node.js ×1
perl-hash ×1
pg ×1
postgresql ×1
snowflake-cloud-data-platform ×1
unix ×1