# pysparky.enabler

*module*

[View source](https://github.com/PySparky/pysparky-pyspark-helper/blob/327582f8b776fe7638082ce4b5be8153d3ce63d3/pysparky/enabler.py#L1-L1)

## pysparky.enabler.ensure_column

*function*

```python
def ensure_column(*columns: ColumnOrName) -> tuple[Column, ...]
```

Enables PySpark functions to accept either column names (as strings) or Column objects.

Parameters:
columns (ColumnOrName): Column names (as strings) or Column objects to be converted.

Returns:
tuple[Column]: A tuple of Column objects.

Example:
``` py
>>> ensure_column("col1", "col2", F.col("col3"))
(Column<b'col1'>, Column<b'col2'>, Column<b'col3'>)
```

[View source](https://github.com/PySparky/pysparky-pyspark-helper/blob/327582f8b776fe7638082ce4b5be8153d3ce63d3/pysparky/enabler.py#L9-L30)

## pysparky.enabler.ensure_list

*function*

```python
def ensure_list(single_or_list: Any | list[Any]) -> list[Any]
```

Ensures the input is returned as a list.

If the input is not already a list, it wraps the input in a list.
If the input is already a list, it returns the input unchanged.

**Parameters**

- `single_or_list` (`Union[Any, List[Any]]`) — The input which can be a single item or a list of items.

**Returns**

- (`list[Any]`) — List[Any]: A list containing the input item(s).

> **Example**
>
> ``` py
> >>> ensure_list(5)
> 
> >>> ensure_list([1, 2, 3])
> [1, 2, 3]
> >>> ensure_list("hello")
> ["hello"]
> ```

[View source](https://github.com/PySparky/pysparky-pyspark-helper/blob/327582f8b776fe7638082ce4b5be8153d3ce63d3/pysparky/enabler.py#L33-L57)
