From 500ed897d0ab332a0617d43f1cd6080e6a1bf4e2 Mon Sep 17 00:00:00 2001 From: Minutis Date: Thu, 24 Oct 2019 23:04:45 +0300 Subject: [PATCH] Build --connect parameter only if port and schema are defined --- airflow/contrib/hooks/sqoop_hook.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/airflow/contrib/hooks/sqoop_hook.py b/airflow/contrib/hooks/sqoop_hook.py index e8e2feb3e62e83..ea9ad430129906 100644 --- a/airflow/contrib/hooks/sqoop_hook.py +++ b/airflow/contrib/hooks/sqoop_hook.py @@ -147,11 +147,12 @@ def _prepare_command(self, export=False): if self.hcatalog_table: connection_cmd += ["--hcatalog-table", self.hcatalog_table] - connection_cmd += ["--connect", "{}:{}/{}".format( - self.conn.host, - self.conn.port, - self.conn.schema - )] + connect_str = self.conn.host + if self.conn.port: + connect_str += ":{}".format(self.conn.port) + if self.conn.schema: + connect_str += "/{}".format(self.conn.schema) + connection_cmd += ["--connect", connect_str] return connection_cmd