### Apache Airflow Provider(s)

common-sql

### Versions of Apache Airflow Providers

apache-airflow-providers-common-sql==1.3.1

### Apache Airflow version

2.5.0

### Operating System

Debian GNU/Linux 11 (bullseye)

### Deployment

Other Docker-based deployment

### Deployment details

Docker image based on the official image (couple of tools added) deployed on AWS ECS Fargate

### What happened

I have a task which uses the table check operator to run some table stakes data validation.  But I don't want it failing every time it runs in our test environments which do not get records every day.  So there's a templated switch in the sql:

```python
    test_data_changed_yesterday = SQLTableCheckOperator(
        task_id="test_data_changed_yesterday",
        table="reporting.events",
        conn_id="pg_conn",
        checks={"changed_record_count": {"check_statement": "count(*) > 0"}},
        partition_clause="""
        {% if var.value.get('is_test_env', False) %}
        modifieddate >= '2015-12-01T01:01:01.000Z'
        {% else %}
        modifieddate >= '{{ data_interval_start.isoformat() }}' and
            modifieddate < '{{ data_interval_end.isoformat() }}'
        {% endif %}
        """,
    )
```

This shows correctly in the rendered field for the task. Not pretty, but it works:

```
('\n'
 '        \n'
 "        modifieddate >= '2015-12-01T01:01:01.000Z'\n"
 '        \n'
 '        ')
```

However, in the logs I see it's running this query:

```
[2022-12-07, 11:49:34 UTC] {sql.py:364} INFO - Running statement: SELECT check_name, check_result FROM (
    SELECT 'changed_record_count' AS check_name, MIN(changed_record_count) AS check_result
    FROM (SELECT CASE WHEN count(*) > 0 THEN 1 ELSE 0 END AS changed_record_count
          FROM reporting.events WHERE 
        {% if var.value.get('is_test_env', False) %}
        modifieddate >= '2015-12-01T01:01:01.000Z'
        {% else %}
        modifieddate >= '{{ data_interval_start.isoformat() }}' and
            modifieddate < '{{ data_interval_end.isoformat() }}'
        {% endif %}
        ) AS sq
    ) AS check_table, parameters: None
```

Which unsurprisingly the DB rejects as invalid sql!

### What you think should happen instead

The rendered code should be used in the sql which is run!

I think this error comes about through this line: https://github.com/apache/airflow/blob/main/airflow/providers/common/sql/operators/sql.py#L576 which is run in the `__init__` method of the operator. i.e. before templating is applied in the build up to calling `execute(context)`.

### How to reproduce

Use the operator with a templated `partition_clause`

### Anything else

Happens every time

### Are you willing to submit PR?

- [X] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

"""
    Performs checks against a db. The ``SQLCheckOperator`` expects
    a sql query that will return a single row. Each value on that
    first row is evaluated using python ``bool`` casting. If any of the
    values return ``False`` the check is failed and errors out.
    Note that Python bool casting evals the following as ``False``:
    * ``False``
    * ``0``
    * Empty string (``""``)
    * Empty list (``[]``)
    * Empty dictionary or set (``{}``)
    Given a query like ``SELECT COUNT(*) FROM foo``, it will fail only if
    the count ``== 0``. You can craft much more complex query that could,
    for instance, check that the table has the same number of rows as
    the source table upstream, or that the count of today's partition is
    greater than yesterday's partition, or that a set of metrics are less
    than 3 standard deviation for the 7 day average.
    This operator can be used as a data quality check in your pipeline, and
    depending on where you put it in your DAG, you have the choice to
    stop the critical path, preventing from
    publishing dubious data, or on the side and receive email alerts
    without stopping the progress of the DAG.
    :param sql: the sql to be executed. (templated)
    :param conn_id: the connection ID used to connect to the database.
    :param database: name of database which overwrite the defined one in connection
    :param parameters: (optional) the parameters to render the SQL query with.