{"record":{"id":"1f24c37a4ab52890","repo":"pola-rs/polars","slug":"strategy-strategy-r-is-not-supported","errorCode":null,"errorMessage":"strategy {strategy!r} is not supported","messagePattern":"strategy (.+?) is not supported","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/expr/expr.py","lineNumber":5544,"sourceCode":"                    b = b + step\n                    partition_df = df[a:b, :]\n                    partitions.append(get_lazy_promise(partition_df))\n\n                from polars.functions.lazy import _collect_all_eager\n\n                out = [df.to_series() for df in _collect_all_eager(partitions)]\n                return F.concat(out, rechunk=False)\n\n            return self.map_batches(\n                wrap_threading,\n                agg_list=False,\n                return_dtype=return_dtype,\n                returns_scalar=False,\n                is_elementwise=True,\n            )\n        else:\n            msg = f\"strategy {strategy!r} is not supported\"\n            raise ValueError(msg)\n\n    @deprecated(\n        \"`Expr.flatten()` is deprecated and will be removed in version 2.0. \"\n        \"Use `Expr.list.explode(keep_nulls=False, empty_as_null=False)` instead.\"\n    )\n    def flatten(self) -> Expr:\n        \"\"\"\n        Flatten a list or string column.\n\n        Alias for :func:`Expr.list.explode`.\n\n        .. deprecated:: 1.38\n            `Expr.flatten()` is deprecated and will be removed in version 2.0.\n            Use `Expr.list.explode(keep_nulls=False, empty_as_null=False)` instead,\n            which provides the behavior you likely expect.\n\n        Examples\n        --------","sourceCodeStart":5526,"sourceCodeEnd":5562,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/expr/expr.py#L5526-L5562","documentation":"Expr.map_elements validates its `strategy` argument and only accepts 'thread_local' (default) or 'threading'. Any other string — including typos like 'threads' or 'parallel', or the value None passed explicitly through a variable — reaches the final else branch and raises ValueError before any data is processed. The 'threading' strategy chunks the Series across the rayon thread pool and is itself marked unstable.","triggerScenarios":"pl.col('a').map_elements(f, strategy='multiprocessing'), strategy=None passed via a config variable, or a misspelled value like 'threadin'.","commonSituations":"Attempting Python-level parallelism with map_elements and guessing a strategy name; config files that default the field to None; copying strategy names from other libraries (pandas 'processes'/'threads').","solutions":["Use strategy='threading' for thread-based parallelism, or omit the argument for 'thread_local'.","If you need process-based parallelism, it is not supported here — implement it outside polars (partition the frame yourself) or use native expressions.","Check for a None default in your config layer and only forward strategy when set."],"exampleFix":"# before\npl.col('a').map_elements(f, strategy='threads')\n\n# after\npl.col('a').map_elements(f, strategy='threading')","handlingStrategy":"validation","validationCode":"if strategy is not None:\n    assert strategy in ('thread_local', 'threading'), f'bad map_elements strategy: {strategy!r}'","typeGuard":"def is_map_strategy(s: str) -> bool:\n    return s in ('thread_local', 'threading')","tryCatchPattern":"try:\n    out = expr.map_elements(f, strategy=strat)\nexcept ValueError as e:\n    if 'strategy' in str(e):\n        out = expr.map_elements(f, strategy='thread_local')\n    else:\n        raise","preventionTips":["Remember the only valid strategies are 'thread_local' and 'threading'.","First try replacing map_elements with native polars expressions — they parallelize in Rust without any strategy flag.","Never let an unvalidated config string flow into keyword arguments."],"tags":["validation","polars","expression","concurrency","map-elements"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}