foo_q = session.query(Foo.id.label('foo_id'), Foo.version.label(
    'foo_version'), Foo.revision.label('foo_revision'), foo_max_time_q.c.
    foo_max_time.label('foo_max_time')).join(foo_max_time_q, foo_max_time_q
    .c.foo_id == Foo.id)
print(foo_q.__str__())
Sqlalchemy: subquery in FROM must have an alias