Taragolis commented on PR #27796: URL: https://github.com/apache/airflow/pull/27796#issuecomment-1326013117
> but I could not figure out a case where this could go wrong, so I figured that is OK to get it in. Just check and seems like nothing actually bad happen because we have replace from `postgresql` to `postgres` during parsing Airflow Connection URI to URI Object. So PostgreSQL connection is unique connection which have some fixes in core parts. https://github.com/apache/airflow/blob/b18f3190c6c157301cb7d29c439dddbb9a8dbf14/airflow/models/connection.py#L182-L188 ```python import os from airflow.models.connection import Connection from airflow.providers.common.sql.operators.sql import BaseSQLOperator PG_CONN_ID = "pg_conn" conn = Connection( conn_id=PG_CONN_ID, conn_type="postgres", host="foo.bar", login="spam", password="egg", ) print(f"AIRFLOW_CONN_{conn.conn_id.upper()}='{conn.get_uri()}'") # Current Impl: AIRFLOW_CONN_PG_CONN='postgres://spam:[email protected]' # This PR Impl: AIRFLOW_CONN_PG_CONN='postgresql://spam:[email protected]' for ix, conn_url in enumerate(["postgres://spam:[email protected]", "postgresql://spam:[email protected]"], start=1): conn_parsed = Connection(conn_id="dummy", uri=conn_url) print(f"{ix}. Airflow Connection URI {conn_url!r}, parsed conn type {conn_parsed.conn_type!r}") # 1. Airflow Connection URI 'postgres://spam:[email protected]', parsed conn type 'postgres' # 2. Airflow Connection URI 'postgresql://spam:[email protected]', parsed conn type 'postgres' os.environ[f"AIRFLOW_CONN_{PG_CONN_ID.upper()}"] = conn_url op = BaseSQLOperator(task_id="sample", conn_id=PG_CONN_ID) hook = op.get_db_hook() print(f"{ix}. Hook: {type(hook)}, URI {hook.get_uri()}") # 1. Hook: <class 'airflow.providers.postgres.hooks.postgres.PostgresHook'>, URI postgresql://spam:[email protected] # 2. Hook: <class 'airflow.providers.postgres.hooks.postgres.PostgresHook'>, URI postgresql://spam:[email protected] ``` > There were few people trying to do the same and reported similar issue I hear about `https` schema for HTTP connection and questions why Connection.get_uri() does not generate "https://foo.bar" -- 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]
