Pyasma commented on code in PR #56298:
URL: https://github.com/apache/airflow/pull/56298#discussion_r2428421490


##########
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:
   Thanks for the review, @Lee-W.
   That was my mistake — while testing, I unintentionally added a fallback that 
shouldn’t be there. Presto itself doesn’t provide any fallback for host, so in 
production the code should raise an error if it’s missing. I’ll remove the test 
fallbacks to make the hook safe and correct.



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

Reply via email to