Acehaidrey commented on a change in pull request #9472: URL: https://github.com/apache/airflow/pull/9472#discussion_r443822020
########## File path: airflow/providers/apache/hive/hooks/hive.py ########## @@ -775,6 +775,20 @@ def table_exists(self, table_name, db='default'): except Exception: # pylint: disable=broad-except return False + def drop_partitions(self, table_name, part_vals, delete_data=False, db='default'): + """ + Drop partitions matching param_names input + >>> hh = HiveMetastoreHook() + >>> hh.drop_partitions(db='airflow', table_name='static_babynames', part_vals="['2020-05-01']") + True + """ + if self.table_exists(table_name, db): + with self.metastore as client: + return client.drop_partition(db, table_name, part_vals, delete_data) + else: + self.log.info("Table %s.%s does not exist!" % (db, table_name)) Review comment: maybe make a log message about the partition existing. do we want to check that too before we try to drop the partition? There is a function in the hook for this too. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org