Skip to content

Commit

Permalink
Merge branch 'main' into appendDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarsharma2 authored Aug 9, 2022
2 parents d245411 + 91f7a35 commit 05771c5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/astro/databases/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 05771c5

Please sign in to comment.