You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/02/15 09:23:44 UTC

[GitHub] [airflow] eladkal commented on a change in pull request #21551: Add ability to pass config parameters to postgres operator

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




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org