gopidesupavan commented on code in PR #39923:
URL: https://github.com/apache/airflow/pull/39923#discussion_r1621294477
##########
airflow/providers/amazon/aws/hooks/glue.py:
##########
@@ -430,3 +431,105 @@ def create_or_update_glue_job(self) -> str | None:
self.conn.create_job(**config)
return self.job_name
+
+
+class GlueDataQualityHook(AwsBaseHook):
+ """
+ Interact with AWS Glue Data Quality.
+
+ Provide thick wrapper around
:external+boto3:py:class:`boto3.client("glue") <Glue.Client>`.
+
+ Additional arguments (such as ``aws_conn_id``) may be specified and
+ are passed down to the underlying AwsBaseHook.
+
+ .. seealso::
+ - :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ """
+
+ def __init__(
+ self,
+ *args,
+ **kwargs,
+ ):
+ kwargs["client_type"] = "glue"
+ super().__init__(*args, **kwargs)
+
+ def has_data_quality_ruleset(self, name: str) -> bool:
+ try:
+ self.conn.get_data_quality_ruleset(Name=name)
+ return True
+ except self.conn.exceptions.EntityNotFoundException:
+ return False
+
+ def update_glue_data_quality_ruleset(self, config: dict[str, Any]) -> None:
+ if self.has_data_quality_ruleset(config["Name"]):
+ self.log.info("Updating AWS Glue data quality ruleset with: %s",
config)
+ self.conn.update_data_quality_ruleset(**config)
+ else:
+ raise AirflowException(f"AWS Glue data quality ruleset
{config['Name']} not exists to update")
+
+ def create_glue_data_quality_ruleset(self, config: dict[str, Any]) -> None:
+ if not self.has_data_quality_ruleset(config["Name"]):
+ self.log.info("Creating AWS Glue data quality ruleset with: %s",
config)
+ self.conn.create_data_quality_ruleset(**config)
+ else:
+ raise AirflowException(
+ f"AWS Glue data quality ruleset {config['Name']} already
exists with same name."
+ )
Review Comment:
Agree , these are kind of wrappers, i have now removed those and calling
directly inside operator execute method.
`self.hook.conn.create_data_quality_ruleset(**config)`
`self.hook.conn.update_data_quality_ruleset(**config)`
Thank you.
--
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]