'Returns segment metadata from the latest segment'

def latest_metadata(self):

    client = self.cluster.get_pydruid_client()
    results = client.time_boundary(datasource=self.datasource_name)
    if (not results):
        return
    max_time = results[0]['result']['maxTime']
    max_time = dparse(max_time)
    lbound = (max_time - timedelta(days=7)).isoformat()
    rbound = max_time.isoformat()
    if (not self.version_higher(self.cluster.druid_version, '0.8.2')):
        rbound = (max_time - timedelta(1)).isoformat()
    segment_metadata = None
    try:
        segment_metadata = client.segment_metadata(datasource=self.datasource_name, intervals=((lbound + '/') + rbound), merge=self.merge_flag, analysisTypes=conf.get('DRUID_ANALYSIS_TYPES'))
    except Exception as e:
        logging.warning('Failed    first    attempt    to    get    latest    segment')
        logging.exception(e)
    if (not segment_metadata):
        lbound = datetime(1901, 1, 1).isoformat()[:10]
        rbound = datetime(2050, 1, 1).isoformat()[:10]
        if (not self.version_higher(self.cluster.druid_version, '0.8.2')):
            rbound = datetime.now().isoformat()
        try:
            segment_metadata = client.segment_metadata(datasource=self.datasource_name, intervals=((lbound + '/') + rbound), merge=self.merge_flag, analysisTypes=conf.get('DRUID_ANALYSIS_TYPES'))
        except Exception as e:
            logging.warning('Failed    2nd    attempt    to    get    latest    segment')
            logging.exception(e)
    if segment_metadata:
        return segment_metadata[(-1)]['columns']
