From 4d0279a03d499762216ebd0e20fa98777d31256c Mon Sep 17 00:00:00 2001 From: XD-DENG Date: Tue, 2 Oct 2018 15:30:43 +0800 Subject: [PATCH] [AIRFLOW-3139] include parameters into log.info in SQL operators, if any For all SQL-operators based on DbApiHook, sql command itself is printed into log.info. But if parameters are used for the sql command, the parameters would not be included in the printing. This makes the log less useful. This commit ensures that the parameters are also printed into the log.info, if any. --- airflow/hooks/dbapi_hook.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/airflow/hooks/dbapi_hook.py b/airflow/hooks/dbapi_hook.py index 5b50ade34e486..bb2c20c188c0c 100644 --- a/airflow/hooks/dbapi_hook.py +++ b/airflow/hooks/dbapi_hook.py @@ -163,10 +163,11 @@ def run(self, sql, autocommit=False, parameters=None): for s in sql: if sys.version_info[0] < 3: s = s.encode('utf-8') - self.log.info(s) if parameters is not None: + self.log.info("{} with parameters {}".format(s, parameters)) cur.execute(s, parameters) else: + self.log.info(s) cur.execute(s) # If autocommit was set to False for db that supports autocommit,