def __get_partitions(): to_delete = [] db_name = "" table_name = "" glue = Glue() token = None partitions_to_delete = [] while True: response = glue.get_partitions(db_name, table_name, token) token = response["NextToken"] if "NextToken" in response else None partitions = response["Partitions"] idx = 0 for partition in partitions: idx += 1 values = partition["Values"] if idx >= 25: glue.delete_partitions(db_name, table_name, partitions_to_delete) partitions_to_delete = [] idx = 0 partitions_to_delete.append({"Values": values}) if token is None or len(token) == 0: break response = glue.delete_partitions(db_name, table_name, partitions_to_delete)
def __update_partitions2(paths): to_delete = [] db_name = "" table_name = "" for path in paths: to_delete.append(path.source) to_delete.append(path.buildid) to_delete.append(str(path.year)) to_delete.append(str(path.month)) to_delete.append(str(path.day)) to_delete.append(str(path.hour)) to_delete.append(path.platform) to_delete.append(path.event) to_delete.append(path.schema) break glue = Glue() print glue.delete_partitions(db_name, table_name, to_delete)