Table function#

Table function#

Contains table function related classes.

class pystarburst.table_function.TableFunctionCall(func_name: str | Iterable[str], *func_arguments: ColumnOrName, **func_named_arguments: ColumnOrName)#

Bases: object

Represents a table function call. A table function call has the function names, positional arguments, named arguments and the partitioning information.

The constructor of this class is not supposed to be called directly. Instead, use call_table_function(), which will create an instance of this class. Or use table_function() to create a Callable object and call it to create an instance of this class.

alias(*aliases: str) TableFunctionCall#

Alias the output columns from the output of this table function call.

Parameters:

aliases – An iterable of unique column names that do not collide with column names after join with the main table.

Raises:

ValueError – Raises error when the aliases are not unique after being canonicalized.

arguments: Iterable[ColumnOrName]#

The positional arguments used to call this table function.

as_(*aliases: str) TableFunctionCall#

Alias the output columns from the output of this table function call.

Parameters:

aliases – An iterable of unique column names that do not collide with column names after join with the main table.

Raises:

ValueError – Raises error when the aliases are not unique after being canonicalized.

name: str#

The table function name

named_arguments: Dict[str, ColumnOrName]#

The named arguments used to call this table function.

over(*, partition_by: ColumnOrName | Iterable[ColumnOrName] | None = None, order_by: ColumnOrName | Iterable[ColumnOrName] | None = None) TableFunctionCall#

Specify the partitioning plan for this table function call when you lateral join this table function.

When a query does a lateral join on a table function, the query feeds data to the table function row by row. Before rows are passed to table functions, the rows can be grouped into partitions. Partitioning has two main benefits:

  • Partitioning allows Trino to divide up the workload to improve parallelization and thus performance.

  • Partitioning allows Trino to process all rows with a common characteristic as a group. You can return results that are based on all rows in the group, not just on individual rows.

Refer to table functions and partitions for more information.

Parameters:
  • partition_by – Specify the partitioning column(s). It tells the table function to partition by these columns.

  • order_by – Specify the order by column(s). It tells the table function to process input rows with this order within a partition.

Note that if this function is called but both partition_by and order_by are None, the table function call will put all input rows into a single partition. If this function isn’t called at all, the Trino cluster will use implicit partitioning.