# pysparky_config.composition

*module*

Deterministic composition for string-valued Spark configuration maps.

[View source](https://github.com/PySparky/pysparky-config/blob/af4b54281ec8606184de09177ebf2ae4c49d57f0/src/pysparky_config/composition.py#L1-L1)

## pysparky_config.composition.compose_spark_configs

*function*

```python
def compose_spark_configs(*configs: Mapping[str, str], overrides: Mapping[str, str] | None = None) -> dict[str, str]
```

Compose Spark config maps with explicit scalar conflict handling.

Equal scalar values are kept once. Different scalar values raise ``ValueError``
unless the key appears in ``overrides``. ``spark.jars.packages`` and
``spark.sql.extensions`` are merged as comma-separated lists in first-seen
order, with exact duplicate entries removed. Package coordinates that name the
same group and artifact at different versions raise ``ValueError``.

The input mappings are not modified. Keys keep their first-seen order; an
explicit override changes a value without moving its key. The function uses
only the standard library and does not validate runtime compatibility or
initialize Spark.

**Raises**

- `TypeError` — If an input or override is not a string-to-string mapping.
- `ValueError` — If a scalar conflict is unresolved, a list entry is malformed,
a package coordinate is incompatible, or an override targets a list
setting or unknown key.

[View source](https://github.com/PySparky/pysparky-config/blob/af4b54281ec8606184de09177ebf2ae4c49d57f0/src/pysparky_config/composition.py#L50-L123)
