Lee-W commented on code in PR #56298:
URL: https://github.com/apache/airflow/pull/56298#discussion_r2428262589
##########
providers/presto/src/airflow/providers/presto/hooks/presto.py:
##########
@@ -150,6 +150,35 @@ def get_conn(self) -> Connection:
return presto_conn
+ @property
+ def sqlalchemy_url(self) -> URL:
+ """Return a `sqlalchemy.engine.URL` object constructed from the
connection."""
+ conn = self.get_connection(self.get_conn_id())
+ extra = conn.extra_dejson or {}
+ catalog = extra.get("catalog", "hive")
+ schema = conn.schema
+
+ query = {"protocol": extra.get("protocol", "http"), "source":
extra.get("source", "airflow")}
+
+ if schema:
+ query["schema"] = schema
+
+ url_query_params = {k: v for k, v in query.items() if v is not None}
+ host = str(conn.host) if conn.host else "test_host"
+ return URL.create(
+ drivername="presto",
+ username=conn.login or "",
+ password=conn.password or "",
+ host=host,
+ port=conn.port,
+ database=catalog,
+ query=url_query_params,
+ )
Review Comment:
```suggestion
conn = self.get_connection(self.get_conn_id())
extra = conn.extra_dejson or {}
query = {
"protocol": extra.get("protocol", "http"),
"source": extra.get("source", "airflow"),
"schema": conn.schema or None
}
url_query_params = {k: v for k, v in query.items() if v is not None}
return URL.create(
drivername="presto",
username=conn.login or "",
password=conn.password or "",
host=str(conn.host) if conn.host else "test_host",
port=conn.port,
database=extra.get("catalog", "hive"),
query=url_query_params,
)
```
would like to confirm what is this "test_host"? is it preserved by Presto?
--
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]