Rewrite
The REWRITE
Pre-hook allows one to rewrite a SQL query using regular expressions.
{
'matchRegex': <match>,
'replaceString': <replace>
}
<match>
- The regular expression to match against the SQL text.
<replace>
- The replacement string to use to replace the query. The replacement string can use backreferences (e.g. $1, $2) to reference portions of the match string.
- If the regular expression does not match, the hook has no impact on the query.
CREATE SUNDECK FLOW REPLACE_FOO_WITH_BAR
PRE HOOK CONVERT
ALWAYS
REWRITE {
'matchRegex': $$(.*)FOO(.*)$$,
'replaceString':'${1}BAR$2'
}
;
Here ${1}
is the first backreference (ie the first (.*)
) and $2
is the second. Note we add the curly braces to the first backreference to logically separate it from the BAR
that it preceeds.