Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #110 and #107 #111

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Fixes #110 and #107 #111

wants to merge 5 commits into from

Conversation

mpgreg
Copy link
Contributor

@mpgreg mpgreg commented Apr 29, 2023

Addes a new attribute and operator arg for database override and parses data_asset_name for either TABLE, SCHEMA.TABLE or DATABASE.SCHEMA.TABLE.

Due to differences in how schema and database are used across database providers it may not be possible to use BaseHook to get hook and conn attributes for all variants. This PR allows redshift and postgres users to specify db and schema either as operator args or fully-qualified data_asset_name arg.

@@ -112,6 +112,8 @@ class GreatExpectationsOperator(BaseOperator):
:type return_json_dict: bool
:param use_open_lineage: If True (default), creates an OpenLineage action if an OpenLineage environment is found
:type use_open_lineage: bool
:param database: If provided, overwrites the default database provided by the connection
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not get these values from the connection extras?
I feel in general the connection should be self sufficient and exposing these parameters in the operators is separating related things(to the connection) out. Anything that is provided in the extras can override the values for database/schema, etc, no?

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could get the database from self.conn.schema. The Airflow has database name in the web UI, but it's saved as 'schema` column.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this whole database == schema and schema == database thing with the postgres provider to be an antipattern which is confusing for developers. One reason for this override is to clear that up. Also it may be desireable to set a different db/schema for a particular set of expectations rather than use the same for all.

# Schema parameter always takes priority
# If a schema and db are passed as part of the data_asset_name, use that schema/db
if self.data_asset_name:
# Check if data_asset_name is in the form "SCHEMA.TABLE" or "DATABASE.TABLE.SCHEMA"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo here

Suggested change
# Check if data_asset_name is in the form "SCHEMA.TABLE" or "DATABASE.TABLE.SCHEMA"
# Check if data_asset_name is in the form "SCHEMA.TABLE" or "DATABASE.SCHEMA.TABLE"

@freefood89
Copy link

freefood89 commented Nov 8, 2024

@mpgreg Would you be interested in continuing on this PR? If not I can resume from where you started.

@zhongxiao37 @pankajkoti Is there anything other than the typo and the merge conflict that needs to be fixed?

@jroach-astronomer
Copy link
Member

@pankajkoti, I have a team that would like the same functionality. I'd like to go ahead and implement this next week if possible. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants