Documentation
Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Rewrite

The REWRITE Pre-hook allows one to rewrite a SQL query using regular expressions.

Configuration Syntax

  {
      'matchRegex': <match>,
      'replaceString': <replace>
  }

Arguments

<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.

Usage Notes

  • If the regular expression does not match, the hook has no impact on the query.

Examples

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.