eladkal commented on a change in pull request #21551:
URL: https://github.com/apache/airflow/pull/21551#discussion_r806617382
##########
File path:
docs/apache-airflow-providers-postgres/operators/postgres_operator_howto_guide.rst
##########
@@ -134,6 +134,22 @@ To find the owner of the pet called 'Lester':
parameters={"begin_date": "2020-01-01", "end_date": "2020-12-31"},
)
+Passing Connection Parameters into PostgresOperator
+----------------------------------------
+
+PostgresOperator provides the optional ``runtime_parameters`` attribute which
makes it possible to set
+the `server configuration parameter values
<https://www.postgresql.org/docs/14/runtime-config-client.html>`_ for the SQL
request during runtime.
Review comment:
```suggestion
the `server configuration parameter values
<https://www.postgresql.org/docs/current/runtime-config-client.html>`_ for the
SQL request during runtime.
```
so we will always direct to the updated docs of postgres
##########
File path:
docs/apache-airflow-providers-postgres/operators/postgres_operator_howto_guide.rst
##########
@@ -134,6 +134,22 @@ To find the owner of the pet called 'Lester':
parameters={"begin_date": "2020-01-01", "end_date": "2020-12-31"},
)
+Passing Connection Parameters into PostgresOperator
+----------------------------------------
+
+PostgresOperator provides the optional ``runtime_parameters`` attribute which
makes it possible to set
+the `server configuration parameter values
<https://www.postgresql.org/docs/14/runtime-config-client.html>`_ for the SQL
request during runtime.
+
+.. code-block:: python
+
+ get_birth_date = PostgresOperator(
+ task_id="get_birth_date",
+ postgres_conn_id="postgres_default",
+ sql="SELECT * FROM pet WHERE birth_date BETWEEN SYMMETRIC %(begin_date)s
AND %(end_date)s",
+ parameters={"begin_date": "2020-01-01", "end_date": "2020-12-31"},
+ runtime_parameters={"statement_timeout": "30ms"},
+ )
Review comment:
We prefer code examples to be in examples dag and reference these
examples from the rst file
check:
https://github.com/apache/airflow/blob/main/airflow/providers/postgres/example_dags/example_postgres.py
You can simply add another operator to the example and reference to it in
the rst file (just make sure the timeout you set is reasonable to we won't have
failures if/when system test are actually running the query
##########
File path: airflow/providers/postgres/example_dags/example_postgres.py
##########
@@ -70,8 +70,9 @@
BETWEEN SYMMETRIC DATE '{{ params.begin_date }}' AND DATE '{{
params.end_date }}';
""",
params={'begin_date': '2020-01-01', 'end_date': '2020-12-31'},
Review comment:
I don't think it's wrong. The code references to params by
`params.begin_date`,` params.end_date`
`parameters` is to pass the assignment to sqlalchemy engine (which means you
will not see the full rendered query in render tab)
##########
File path: airflow/providers/postgres/example_dags/example_postgres.py
##########
@@ -70,8 +70,9 @@
BETWEEN SYMMETRIC DATE '{{ params.begin_date }}' AND DATE '{{
params.end_date }}';
""",
params={'begin_date': '2020-01-01', 'end_date': '2020-12-31'},
Review comment:
I don't think it's wrong. The code references to params by
`params.begin_date`,` params.end_date`
`parameters` is to pass the assignment to sqlalchemy engine (which means you
will not see the full rendered query in render tab)
Though I would say that params are not really needed here as the dates are
static... so they can be just placed in the SQL directly
##########
File path: airflow/providers/postgres/example_dags/example_postgres.py
##########
@@ -70,8 +70,9 @@
BETWEEN SYMMETRIC DATE '{{ params.begin_date }}' AND DATE '{{
params.end_date }}';
""",
params={'begin_date': '2020-01-01', 'end_date': '2020-12-31'},
Review comment:
I don't think it's wrong. The code references to params by
`params.begin_date`,` params.end_date`
`parameters` is to pass the assignment to sqlalchemy engine (which means you
will not see the full rendered query in render tab)
Though I would say that params/parameters are not really needed here anyway
as the dates are static... so they can be just placed in the SQL directly
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]