'Turn this :class:`.TextClause` object into a :class:`.TextAsFrom`
object that can be embedded into another statement.
This function essentially bridges the gap between an entirely
textual SELECT statement and the SQL expression language concept
of a "selectable"::
from sqlalchemy.sql import column, text
stmt = text("SELECT id, name FROM some_table")
stmt = stmt.columns(column(\'id\'), column(\'name\')).alias(\'st\')
stmt = select([mytable]).\
select_from(
mytable.join(stmt, mytable.c.name == stmt.c.name)
).where(stmt.c.id > 5)
Above, we used untyped :func:`.column` elements.  These can also have
types specified, which will impact how the column behaves in expressions
as well as determining result set behavior::
stmt = text("SELECT id, name, timestamp FROM some_table")
stmt = stmt.columns(
column(\'id\', Integer),
column(\'name\', Unicode),
column(\'timestamp\', DateTime)
for id, name, timestamp in connection.execute(stmt):
print(id, name, timestamp)
Keyword arguments allow just the names and types of columns to be specified,
where the :func:`.column` elements will be generated automatically::
stmt = text("SELECT id, name, timestamp FROM some_table")
stmt = stmt.columns(
id=Integer,
name=Unicode,
timestamp=DateTime
for id, name, timestamp in connection.execute(stmt):
print(id, name, timestamp)
The :meth:`.TextClause.columns` method provides a direct
route to calling :meth:`.FromClause.alias` as well as :meth:`.SelectBase.cte`
against a textual SELECT statement::
stmt = stmt.columns(id=Integer, name=String).cte(\'st\')
stmt = select([sometable]).where(sometable.c.id == stmt.c.id)
.. versionadded:: 0.9.0 :func:`.text` can now be converted into a fully
featured "selectable" construct using the :meth:`.TextClause.columns`
method.  This method supersedes the ``typemap`` argument to
:func:`.text`.'

@util.dependencies(u'sqlalchemy.sql.selectable')
def columns(self, selectable, *cols, **types):

    input_cols = ([(ColumnClause(col.key, types.pop(col.key)) if (col.key in types) else col) for col in cols] + [ColumnClause(key, type_) for (key, type_) in types.items()])
    return selectable.TextAsFrom(self, input_cols)
