jason810496 commented on code in PR #48917:
URL: https://github.com/apache/airflow/pull/48917#discussion_r2035496533


##########
providers/trino/src/airflow/providers/trino/hooks/trino.py:
##########
@@ -322,3 +323,38 @@ def get_openlineage_database_dialect(self, _):
     def get_openlineage_default_schema(self):
         """Return Trino default schema."""
         return trino.constants.DEFAULT_SCHEMA
+
+    def get_uri(self) -> str:
+        """Return the Trino URI for the connection."""
+        conn = self.connection
+        uri = "trino://"
+
+        auth_part = ""
+        if conn.login:
+            auth_part = quote_plus(conn.login)
+            if conn.password:
+                auth_part = f"{auth_part}:{quote_plus(conn.password)}"
+            auth_part = f"{auth_part}@"
+
+        host_part = conn.host or "localhost"
+        if conn.port:
+            host_part = f"{host_part}:{conn.port}"
+
+        schema_part = ""
+        if conn.schema:
+            schema_part = f"/{quote_plus(conn.schema)}"
+            extra_schema = conn.extra_dejson.get("schema")
+            if extra_schema:
+                schema_part = f"{schema_part}/{quote_plus(extra_schema)}"
+
+        uri = f"{uri}{auth_part}{host_part}{schema_part}"
+
+        extra = conn.extra_dejson.copy()
+        if "schema" in extra:
+            extra.pop("schema")
+
+        query_params = {k: str(v) for k, v in extra.items() if v is not None}
+        if query_params:
+            uri = f"{uri}?{urlencode(query_params)}"

Review Comment:
   Just to double-check:  
   `TrinoHook` does set `conn_type` to `"trino"`, and with that, the default 
`get_uri` implementation uses the same logic as in 
https://github.com/apache/airflow/blob/093d701b7a7deb4555705099be4da5adec493351/task-sdk/src/airflow/sdk/definitions/connection.py#L61
   
   So I’m wondering—do we actually need to override `get_uri` in this case?  
   Or is there a specific Trino-related edge case that I might have overlooked?
   
   > For the previous MySQL case, there were indeed special considerations to 
handle, but I don’t see such requirements for Trino.



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