'Getting the time component of the query'

def get_timestamp_expression(self, time_grain):

    expr = (self.expression or self.column_name)
    if ((not self.expression) and (not time_grain)):
        return column(expr, type_=DateTime).label(DTTM_ALIAS)
    if time_grain:
        pdf = self.python_date_format
        if (pdf in ('epoch_s', 'epoch_ms')):
            db_spec = self.table.database.db_engine_spec
            if (pdf == 'epoch_s'):
                expr = db_spec.epoch_to_dttm().format(col=expr)
            elif (pdf == 'epoch_ms'):
                expr = db_spec.epoch_ms_to_dttm().format(col=expr)
        grain = self.table.database.grains_dict().get(time_grain, '{col}')
        expr = grain.function.format(col=expr)
    return literal_column(expr, type_=DateTime).label(DTTM_ALIAS)
