in athena_glue_service_logs/utils.py [0:0]
def get_first_hivecompatible_date_in_prefix(self, partition_keys, prefix=None):
"""A method to return the first date in a given prefix, when using hive-compatible partitions"""
first_key = self._get_first_key_in_prefix(prefix)
# Verify we have a matching format
regexp = "/" + '/'.join(["%s=\d+" % key for key in partition_keys]) + "/"
if re.search(regexp, first_key) is None:
raise Exception("No Hive-compatible date partitions found in prefix: s3://%s/%s" % (self.s3_bucket, prefix))
# Do we want to return ['Y', 'M', 'D'] or ['year=Y', 'month=M', 'day=D'?
date_tuple = [part.split('=')[1] for part in first_key.split('/')[-4:-1]]
return date_tuple