1. Home
  2. Docs
  3. Models
  4. Pre select with hook

Pre select with hook

Defintion #

With a pre select hook you can run code a WITH statement before the select block.

{{ block "PRE_SELECT_WITH_HOOKS" . }}
with abc as (SELECT 'a' as column_a, NOW()::date as date)
{{end}}

The defined “temporary tables” cold the be used in the main SELECT block:

{{ block "SELECT" . }}
SELECT
  "column_a" as column_aaa,
  NOW()::date as date)
FROM
  abc
{{end}}

Complete example #

{{ block "CONFIG" . }}
{{end}}

{{ block "SELECT" . }}
SELECT
  "column_a" as column_aaa,
  NOW()::date as date)
FROM
  abc
{{end}}

{{ block "PRE_SELECT_WITH_HOOKS" . }}
with abc as (SELECT 'a' as column_a, NOW()::date as date)
{{end}}