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/10/01 09:47:38 UTC

[GitHub] [airflow] eladkal commented on a diff in pull request #25717: Add SQLExecuteQueryOperator

eladkal commented on code in PR #25717:
URL: https://github.com/apache/airflow/pull/25717#discussion_r985078769


##########
airflow/providers/common/sql/operators/sql.py:
##########
@@ -162,6 +164,68 @@ def get_db_hook(self) -> DbApiHook:
         return self._hook
 
 
+class SQLExecuteQueryOperator(BaseSQLOperator):
+    """
+    Executes SQL code in a specific database
+    :param sql: the SQL code or string pointing to a template file to be executed (templated).
+    File must have a '.sql' extensions.
+    :param autocommit: (optional) if True, each command is automatically committed (default: False).
+    :param parameters: (optional) the parameters to render the SQL query with.
+    :param handler: (optional) the function that will be applied to the cursor.
+    :param split_statements: (optional) if split single SQL string into statements (default: False).
+    :param return_last: (optional) if return the result of only last statement (default: True).
+    """
+
+    template_fields: Sequence[str] = ('sql', 'parameters')
+    template_ext: Sequence[str] = ('.sql',)
+    ui_color = '#cdaaed'
+
+    def __init__(
+        self,
+        *,
+        sql: str | list[str],
+        autocommit: bool = False,
+        parameters: Mapping | Iterable | None = None,
+        handler: Callable[[Any], Any] = fetch_all_handler,
+        split_statements: bool = False,
+        return_last: bool = True,

Review Comment:
   This parameter works only with `do_xcom_push=True`.
   I have two thoughts on this:
   1. If `return_last=True` should we under the hood set  `do_xcom_push=True` ?
   2. Assuming we go with (1) then probably the default of `return_last` should be False?
   
   My goal here is to prevent the undesired state of  `do_xcom_push=False`  with `return_last=True`.
   If user set `return_last=True` we know for sure xcom needs to be pushed.
   if user set `return_last=False` we don't know what is the user wish for xcom so we need to also look for `do_xcom_push` value.



-- 
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