User Defined
The USER_DEFINED
Pre-hook allows a user to write an arbitrary snippet of JavaScript that can modify the SQL text before submitting it to Snowflake.
{
'body': <function_body>,
'errorBehavior': <error_behavior>
}
<body>
- A JavaScript body that exposes a single function called
doAction()
. Input and output of function are objects, each with a single field calledsql
. <errorBehavior>
- How the hook should behave in the case that the JavaScript function throws an exception. Options are
BYPASS
which causes the query to skip execution of this hook and continue down the flow andREJECT
which causes the query to be rejected with information about the JavaScript failure. Typically set toREJECT
during development and then run in production inBYPASS
mode.
- The JavaScript function is bound by script size, memory and time executing.
- The JavaScript is not executed in a browser and thus browser specific JavaScript objects (like window & document) are not available.
- The body can include multiple separate variable and/or function declarations (to ease development modularity). Sundeck will only invoke the
doAction()
function.
CREATE SUNDECK FLOW ALWAYS_SELECT_1
PRE HOOK CONVERT
ALWAYS
USER_DEFINED {
'errorBehavior': 'BYPASS',
'body':$$ function doAction(obj){
return {"sql":"select 1"};
} $$
}
;