bach.Series.materialize

materialize

(node_name='manual_materialize', limit=None, distinct=False, materialization=Materialization.CTE)

[source]

Create a copy of this Series with as base_node the current Series’s state.

This effectively adds a node to the underlying SqlModel graph. Generally adding nodes increases the size of the generated SQL query. But this can be useful if the current Series contains expressions that you want to evaluate before further expressions are build on top of them. This might make sense for very large expressions, or for non-deterministic expressions (e.g. see SeriesUuid.random()). Additionally, materializing as a temporary table can improve performance in some instances.

Note this function does NOT query the database or materializes any data in the database. It merely changes the underlying SqlModel graph, which gets executed by data transfer functions (e.g. to_pandas())

Parameters

  • node_name (str) – The name of the node that’s going to be created
  • limit (Optional[Union[int, slice]]) – The limit (slice, int) to apply.
  • distinct (bool) – Apply distinct statement if distinct=True
  • materialization (Union[sql_models.model.Materialization, str]) – Set the materialization of the SqlModel in the graph. Only Materialization.CTE / ‘cte’ and Materialization.TEMP_TABLE / ‘temp_table’ are supported.

Returns

Series with the current Series’s state as base_node

Return type

bach.series.series.Series

note

Calling materialize() resets the order of the series. Call sort_values() again on the result if order is important.

Argument inplace should be always False.