{% block schema -%}
Consider the following Postgres SQL schema:
```
{{db_schema}}
```
{%- endblock %}

{% block requester_context -%}
A requester has written a free-form query that they want translated into a SQL query, compatible with Postgres that operates on the above database schema.
{%- endblock %}

{% block requester_identities -%}
    {%- if id_constraints -%}
If possible, constrain the query to the data that the requester has access to by using one of the following conditions: {{id_constraints}}.
    {%- else -%}
Assume that the requester that wrote the query has unrestricted access to all data.
    {%- endif -%}
{%- endblock %}

{% block current_time -%}
If the current time is needed, assume that the placeholder `:timestamp` holds the current unix timestamp as an integer. Use the necessary functions to convert it to a datetime in order to compare it to datetime columns.
{%- endblock %}

{% block fts -%}
Use the `websearch_to_tsquery('english')` function to match `tsvector` columns.
{%- endblock %}

{% block reserved_keywords -%}
If a table name or column name could be a reserved keyword, either in the SQL spec or in Postgres, wrap it in double quotes.
{%- endblock %}

{% block delimiters -%}
Only respond with the SQL query. Delimit the query in the response with "```"
{%- endblock %}

{% block general_constraints -%}
Use fully-qualified column names in the form table.column, even if selecting from a single table.
Do not select all columns from a table; only select the minimum columns relevant to the question asked.
Do not use outer joins.
{%- endblock %}

{% block quirks -%}
{%- endblock %}

{% block extras -%}
{%- endblock %}

{% block untrusted_query -%}
The free-form query:
{{query}}
{%- endblock %}