本文介绍了雪花-如何检索当前正在执行的过程的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在javascript过程本身中访问Snowflake中当前正在执行的过程的名称,并将其存储在一个变量中。
当我询问"this"对象时,我可以看到Variant返回中的名称,但就JSON而言,我相信它是名称而不是值,我不确定如何检索JSON对象中的名字。
需要使用哪些代码来获取过程名称?
procName=?此对象的此处包含什么代码?;
我们是否知道"this"中的第一个名称/值对始终是过程名称?
CREATE OR REPLACE PROCEDURE EDW_ADMIN.DAG_TEST()
RETURNS VARIANT
LANGUAGE JAVASCRIPT
AS
$$
var procName = "";
// procName = this.??? WHAT DO I PUT HERE ???
return this;
$$
;
this的返回/内容为:
{
"DAG_TEST": {},
"ResultSet": {},
"SfTimestamp": {},
"Snowflake": {},
"Statement": {},
"Status": {
"EOF": "eof",
"ERROR": "error",
"INITIALIZED": "initialized",
"SUCCESS": "success"
},
"_c_snowflake": {
"createExecError": {},
"createStatement": {}
},
"createError": {},
"extractValue": {},
"getColSqlTypeFromIdx": {},
"nativeTypes": {
"values": {
"BOOLEAN": "boolean",
"BUFFER": "buffer",
"DATE": "date",
"INVALID": "invalid",
"JSON": "json",
"NUMBER": "number",
"STRING": "string"
}
},
"noSuchColumnIdxErrorMessage": "Given column name/index does not exist: ",
"snowflake": {
"createStatement": {},
"execute": {}
},
"sqlTypeFromLibSfDbTypeVal": {},
"sqlTypes": {
"isArray": {},
"isBinary": {},
"isBoolean": {},
"isDate": {},
"isNumber": {},
"isObject": {},
"isText": {},
"isTime": {},
"isTimestamp": {},
"isTimestampLtz": {},
"isTimestampNtz": {},
"isTimestampTz": {},
"isVariant": {},
"values": {
"ARRAY": {
"libSfDbType": 9,
"name": "ARRAY"
},
"BINARY": {
"libSfDbType": 10,
"name": "BINARY"
},
"BOOLEAN": {
"libSfDbType": 12,
"name": "BOOLEAN"
},
"DATE": {
"libSfDbType": 3,
"name": "DATE"
},
"FIXED": {
"libSfDbType": 0,
"name": "FIXED"
},
"INVALID_SQL_TYPE": {
"libSfDbType": -1,
"name": "INVALID_SQL_TYPE"
},
"OBJECT": {
"libSfDbType": 8,
"name": "OBJECT"
},
"REAL": {
"libSfDbType": 1,
"name": "REAL"
},
"TEXT": {
"libSfDbType": 2,
"name": "TEXT"
},
"TIME": {
"libSfDbType": 11,
"name": "TIME"
},
"TIMESTAMP_LTZ": {
"libSfDbType": 4,
"name": "TIMESTAMP_LTZ"
},
"TIMESTAMP_NTZ": {
"libSfDbType": 5,
"name": "TIMESTAMP_NTZ"
},
"TIMESTAMP_TZ": {
"libSfDbType": 6,
"name": "TIMESTAMP_TZ"
},
"VARIANT": {
"libSfDbType": 7,
"name": "VARIANT"
}
}
},
"testFunc": {},
"typeFromLibSfDbTypeVal": {},
"validateBinds": {},
"validateColumnExists": {}
}
推荐答案
在您的进程中尝试此操作:
const procName = Object.keys(this)[0];
假设procName始终是字典中的第一个键!此外,在可能的情况下使用const也是一种良好的做法。
这篇关于雪花-如何检索当前正在执行的过程的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!