Text Fragment Aliases
The TEXT_FRAGMENT_ALIASES
Pre-hook enables the definition of custom aliases for commonly-used SQL fragments.
Once defined in Sundeck, aliases can be used anywhere in SQL statements by enclosing them in double curly braces ({{
and }}
), which will be replaced with their corresponding full text before the query is submitted to Snowflake.
TEXT_FRAGMENT_ALIASES {
'mapping':[
{
'alias' : <alias-string>,
'queryFragment': <query-fragment-string>
}
]
}
<alias-string>
- string to match in the query
<query-fragment-string>
- string to replace the alias with
CREATE OR REPLACE SUNDECK FLOW "Return results of the last executed query"
PRE HOOK results_hook
ALWAYS
TEXT_FRAGMENT_ALIASES {'mapping': [{'alias': '$?', 'queryFragment': 'TABLE(RESULT_SCAN(LAST_QUERY_ID()))'}]}
ENABLED = TRUE;
Connect to the flow “Return results of the last executed query”:
test#COMPUTE_WH@SNOWFLAKE_SAMPLE_DATA.TPCH_SF1>select count(*) from nation;
+----------+
| COUNT(*) |
|----------|
| 25 |
+----------+
1 Row(s) produced.
test#COMPUTE_WH@SNOWFLAKE_SAMPLE_DATA.TPCH_SF1>select * from {{$?}};
+----------+
| COUNT(*) |
|----------|
| 25 |
+----------+
1 Row(s) produced.