From 91f7a356be30335f924ca6be23560348134c47ed Mon Sep 17 00:00:00 2001 From: Ankit Chaurasia <8670962+sunank200@users.noreply.github.com> Date: Tue, 9 Aug 2022 15:47:20 +0545 Subject: [PATCH] Add doc string with details about schema and database for Postgres (#618) * Add details about not fetching schema details from airflow connections --- src/astro/databases/postgres.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/astro/databases/postgres.py b/src/astro/databases/postgres.py index 2119e7ee4..1eab3d1d8 100644 --- a/src/astro/databases/postgres.py +++ b/src/astro/databases/postgres.py @@ -40,7 +40,18 @@ def hook(self) -> PostgresHook: @property def default_metadata(self) -> Metadata: - """Fill in default metadata values for table objects addressing postgres databases""" + """ + Fill in default metadata values for table objects addressing Postgres databases. + + Currently, Schema is not being fetched from airflow connection for Postgres because, in Postgres, databases and + schema are different concepts: https://www.postgresql.org/docs/current/ddl-schemas.html + The PostgresHook only exposes schema: + https://airflow.apache.org/docs/apache-airflow-providers-postgres/stable/_api/airflow/providers/postgres/hooks/postgres/index.html + However, implementation-wise, it seems that if the PostgresHook receives a schema during initialization, + but it uses it as a database in the connection to Postgres: + https://github.com/apache/airflow/blob/main/airflow/providers/postgres/hooks/postgres.py#L96 + """ + # TODO: Change airflow PostgresHook to fetch database and schema separately database = self.hook.get_connection(self.conn_id).schema return Metadata(database=database, schema=self.DEFAULT_SCHEMA)