Return this :class:`_functions.FunctionElement` as a column expression that selects from itself as a FROM clause. E.g.: .. sourcecode:: pycon+sql >>> from sqlalchemy import select, func >>> gs = func.generate_series(1, 5, -1).column_valued()
(
self, name: Optional[str] = None, joins_implicitly: bool = False
)
| 351 | return new_func.alias(name=name, joins_implicitly=joins_implicitly) |
| 352 | |
| 353 | def column_valued( |
| 354 | self, name: Optional[str] = None, joins_implicitly: bool = False |
| 355 | ) -> TableValuedColumn[_T]: |
| 356 | """Return this :class:`_functions.FunctionElement` as a column expression that |
| 357 | selects from itself as a FROM clause. |
| 358 | |
| 359 | E.g.: |
| 360 | |
| 361 | .. sourcecode:: pycon+sql |
| 362 | |
| 363 | >>> from sqlalchemy import select, func |
| 364 | >>> gs = func.generate_series(1, 5, -1).column_valued() |
| 365 | >>> print(select(gs)) |
| 366 | {printsql}SELECT anon_1 |
| 367 | FROM generate_series(:generate_series_1, :generate_series_2, :generate_series_3) AS anon_1 |
| 368 | |
| 369 | This is shorthand for:: |
| 370 | |
| 371 | gs = func.generate_series(1, 5, -1).alias().column |
| 372 | |
| 373 | :param name: optional name to assign to the alias name that's generated. |
| 374 | If omitted, a unique anonymizing name is used. |
| 375 | |
| 376 | :param joins_implicitly: when True, the "table" portion of the column |
| 377 | valued function may be a member of the FROM clause without any |
| 378 | explicit JOIN to other tables in the SQL query, and no "cartesian |
| 379 | product" warning will be generated. May be useful for SQL functions |
| 380 | such as ``func.json_array_elements()``. |
| 381 | |
| 382 | .. versionadded:: 1.4.46 |
| 383 | |
| 384 | .. seealso:: |
| 385 | |
| 386 | :ref:`tutorial_functions_column_valued` - in the :ref:`unified_tutorial` |
| 387 | |
| 388 | :ref:`postgresql_column_valued` - in the :ref:`postgresql_toplevel` documentation |
| 389 | |
| 390 | :meth:`_functions.FunctionElement.table_valued` |
| 391 | |
| 392 | """ # noqa: 501 |
| 393 | |
| 394 | return self.alias(name=name, joins_implicitly=joins_implicitly).column |
| 395 | |
| 396 | @util.ro_non_memoized_property |
| 397 | def columns( |