eladkal commented on code in PR #54475:
URL: https://github.com/apache/airflow/pull/54475#discussion_r2277580233
##########
providers/common/sql/src/airflow/providers/common/sql/hooks/sql.py:
##########
@@ -804,10 +806,15 @@ def _make_common_data_structure(self, result: T |
Sequence[T]) -> tuple | list[t
return cast("list[tuple]", result)
return cast("tuple", result)
+ def _truncate_text(self,text:str) -> str:
+ if self._max_log_sql_str is None or len(text) <= self._max_log_sql_str
+ return text
+ return text[:self._max_log_sql_str] + '.......'
+
def _run_command(self, cur, sql_statement, parameters):
"""Run a statement using an already open cursor."""
if self.log_sql:
- self.log.info("Running statement: %s, parameters: %s",
sql_statement, parameters)
+ self.log.info("Running statement: %s, parameters: %s",
self._truncate_text(sql_statement), parameters)
Review Comment:
I don't understand this implementation.
We already have `log_sql` parameter in `DbApiHook` that is being used in the
`if`
https://github.com/apache/airflow/blob/64e7408cd35cce3ae8a90b2cf17b154e0d1fde67/providers/common/sql/src/airflow/providers/common/sql/hooks/sql.py#L144
The problem is that this some functions don't allow to modify it's value
thus the statement is always printed. I think the right solution is to expose
the parameter in `SQLExecuteQueryOperator` thus users can decide if they want
to log the statement
--
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]