{% for table, details in tables_sql_schemas.items() %}

The data for table '{{ table }}' follows the following JSON schema:
```json
{{ details.schema }}
```
{% endfor %}

{% if not join_required %}
It was already determined that no join is required, so only use the existing
table '{{ table }}' to calculate the result.
{% else %}
If the join's values do not align based on the min/max lowest common denominator, then perform a join based on the
closest match, or resample and aggregate the data to align the values.
{% endif %}

Checklist
- Quote column names to ensure they do not clash with valid identifiers.
- If it's a date column (excluding individual year/month/day integers) date, cast to date using appropriate syntax, e.g. CAST or TO_DATE
- Use only `{{ dialect }}` syntax
{% if dialect == 'duckdb' %}
- If the table name originally did not have `read_*` prefix, use the original table name
- Use table names verbatim; e.g. if table is read_csv('table.csv') then use read_csv('table.csv') and not 'table'
- If `read_*` is used, use with alias, e.g. read_parquet('table.parq') as table_parq
- String literals are delimited using single quotes (', apostrophe) and result in STRING_LITERAL values. Note that double quotes (") cannot be used as string delimiter character: instead, double quotes are used to delimit quoted identifiers.
{% endif %}
